5int smp_semseg_simple(
const char* model_name,
const char* img_name)
19 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
20 printf_s(
"img: %d\r\n", ret);
21 if (F_ERR_NONE != ret) {
goto finally; }
27 printf_s(
"lic : %d\r\n", ret);
28 if (F_ERR_NONE != ret) {
goto finally; }
34 printf_s(
"failed to create handle\r\n");
37 else { printf_s(
"handle created\r\n"); }
41 printf_s(
"load: %d\r\n", ret);
42 if (F_ERR_NONE != ret) {
goto finally; }
46 printf_s(
"par : %d category=%d\r\n", ret, model_category);
47 if (F_ERR_NONE != ret) {
goto finally; }
49 ret = F_ERR_INVALID_OBJECT;
50 printf_s(
"unmatch model\r\n");
56 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
57 if (F_ERR_NONE != ret) {
goto finally; }
61 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
62 if (F_ERR_NONE != ret) {
goto finally; }
65 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, w, h);
68 printf_s(
"hdst allocation error\r\n");
74 printf_s(
"pred: %d\r\n", ret);
75 if (F_ERR_NONE != ret) {
goto finally; }
84 ret = fnFIE_img_minmaxdens(hdst, mins, maxs);
85 if (F_ERR_NONE != ret) {
goto finally; }
86 max_cate_id = (INT)maxs[0];
88 if (0 == max_cate_id) { printf_s(
"all pixels are background\r\n"); }
90 else { printf_s(
"there are some masks, largest category id = %d\r\n", max_cate_id); }
101 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
102 if (NULL != hdst) { fnFIE_free_object(hdst); }
108int smp_semseg_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
111 std::chrono::system_clock::time_point start, end;
113 INT ret = F_ERR_NONE;
123 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
124 printf_s(
"img: %d\r\n", ret);
125 if (F_ERR_NONE != ret) {
goto finally; }
129 printf_s(
"lic : %d\r\n", ret);
130 if (F_ERR_NONE != ret) {
goto finally; }
134 if (NULL == hmodel) {
135 ret = F_ERR_NOMEMORY;
136 printf_s(
"failed to create handle\r\n");
139 else { printf_s(
"handle created\r\n"); }
143 printf_s(
"load: %d\r\n", ret);
144 if (F_ERR_NONE != ret) {
goto finally; }
148 printf_s(
"par : %d category=%d\r\n", ret, model_category);
149 if (F_ERR_NONE != ret) {
goto finally; }
151 ret = F_ERR_INVALID_OBJECT;
152 printf_s(
"unmatch model\r\n");
157 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, fnFIE_img_get_width(hsrc), fnFIE_img_get_height(hsrc));
159 ret = F_ERR_NOMEMORY;
160 printf_s(
"hdst allocation error\r\n");
164 printf_s(
"--- start ---\r\n");
165 printf_s(
"ret, elapsed[msec], scores\r\n");
167 for (
int i = 0; i < bench_iter; i++) {
171 start = std::chrono::system_clock::now();
177 end = std::chrono::system_clock::now();
179 if (F_ERR_NONE != ret) {
180 printf_s(
"pred. err: %d\r\n", ret);
185 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
188 printf_s(
"%04d, %.3e\r\n", i, elapsed);
190 printf_s(
"--- finish ---\r\n");
198 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
199 if (NULL != hdst) { fnFIE_free_object(hdst); }
205int smp_semseg_with_fie(
const char* model_name,
const char* img_name,
const INT category_num)
207 INT ret = F_ERR_NONE;
210 FHANDLE hmask = NULL;
221 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
222 printf_s(
"img: %d\r\n", ret);
223 if (F_ERR_NONE != ret) {
goto finally; }
229 printf_s(
"lic : %d\r\n", ret);
230 if (F_ERR_NONE != ret) {
goto finally; }
234 if (NULL == hmodel) {
235 ret = F_ERR_NOMEMORY;
236 printf_s(
"failed to create handle\r\n");
239 else { printf_s(
"handle created\r\n"); }
243 printf_s(
"load: %d\r\n", ret);
244 if (F_ERR_NONE != ret) {
goto finally; }
248 printf_s(
"par : %d category=%d\r\n", ret, model_category);
249 if (F_ERR_NONE != ret) {
goto finally; }
251 ret = F_ERR_INVALID_OBJECT;
252 printf_s(
"unmatch model\r\n");
257 ret = fnFIE_img_get_params(hsrc, &ch, &type, &step, &w, &h);
258 if (F_ERR_NONE != ret) {
goto finally; }
259 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, w, h);
261 ret = F_ERR_NOMEMORY;
262 printf_s(
"hdst allocation error\r\n");
268 printf_s(
"pred: %d\r\n", ret);
269 if (F_ERR_NONE != ret) {
goto finally; }
272 hmask = fnFIE_img_root_alloc(F_IMG_BIN, 1, w, h);
274 ret = F_ERR_NOMEMORY;
275 printf_s(
"hmask allocation error\r\n");
280 for (
int i_cate = 1; i_cate <= category_num; i_cate++) {
282 ret = fnFIE_band_threshold(hdst, hmask, (DOUBLE)i_cate, (DOUBLE)i_cate);
283 if (F_ERR_NONE != ret) {
continue; }
284 printf_s(
"category=%d: hmask written\r\n", i_cate);
295 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
296 if (NULL != hdst) { fnFIE_free_object(hdst); }
297 if (NULL != hmask) { fnFIE_free_object(hmask); }
INT FVALGAPI fnPDL_get_input_image_size(const H_MODEL hmodel, INT *channels, INT *width, INT *height)
モデルパラメータの取得
Definition: prediction_cpp.cpp:1989
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1968
MODEL_CATEGORY
モデルの種別
Definition: fv_pdl.h:46
INT fnPDL_check_license()
ライセンス確認
Definition: check_licence.cpp:160
MODEL_BACKEND
推論バックエンド
Definition: fv_pdl.h:30
INT FVALGAPI fnPDL_get_model_category(const H_MODEL hmodel, MODEL_CATEGORY *model_category)
モデルの種別の取得
Definition: prediction_cpp.cpp:1937
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2556
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1810
INT FVALGAPI fnPDL_predict_segmentation(const H_MODEL hmodel, const FHANDLE hsrc, FHANDLE hdst)
推論の実行 ( セグメンテーション )
Definition: prediction_cpp.cpp:2347
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1755
@ SEMANTIC_SEGMENTATION
Definition: fv_pdl.h:58