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);
26 printf_s(
"lic : %d\r\n", ret);
30 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
31 else { printf_s(
"handle created\r\n"); }
35 printf_s(
"load: %d\r\n", ret);
39 printf_s(
"par : %d category=%d\r\n", ret, model_category);
44 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
48 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
51 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, w, h);
52 if (NULL == hdst) { printf_s(
"hdst allocation error"); }
56 printf_s(
"pred: %d\r\n", ret);
57 if (F_ERR_NONE == ret) {
59 DOUBLE* maxs = (DOUBLE*)fnOAL_calloc(
sizeof(DOUBLE), 1);
60 DOUBLE* mins = (DOUBLE*)fnOAL_calloc(
sizeof(DOUBLE), 1);
64 ret = fnFIE_img_minmaxdens(hdst,mins, maxs);
65 max_cate_id = (INT)maxs[0];
67 if (0 == max_cate_id) { printf_s(
"all pixels are background"); }
69 else { printf_s(
"there are some masks, largest category id = %d\r\n", max_cate_id); }
70 if (NULL != maxs) { fnOAL_free(maxs); }
71 if (NULL != mins) { fnOAL_free(mins); }
80 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
81 if (NULL != hdst) { fnFIE_free_object(hdst); }
87int smp_semseg_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
90 std::chrono::system_clock::time_point start, end;
102 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
103 printf_s(
"img: %d\r\n", ret);
104 if (F_ERR_NONE != ret) {
goto finally; }
108 printf_s(
"lic : %d\r\n", ret);
112 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
113 else { printf_s(
"handle created\r\n"); }
117 printf_s(
"load: %d\r\n", ret);
121 printf_s(
"par : %d category=%d\r\n", ret, model_category);
125 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, fnFIE_img_get_width(hsrc), fnFIE_img_get_height(hsrc));
126 if (NULL == hdst) { printf_s(
"hdst allocation error"); }
128 printf_s(
"--- start ---\r\n");
129 printf_s(
"ret, elapsed[msec], scores\r\n");
131 for (
int i = 0; i < bench_iter; i++) {
135 start = std::chrono::system_clock::now();
141 end = std::chrono::system_clock::now();
143 if (F_ERR_NONE != ret) {
144 printf_s(
"pred. err: %d\r\n", ret);
149 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
152 printf_s(
"%04d, %.3e\r\n", i, elapsed);
154 printf_s(
"--- finish ---\r\n");
161 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
162 if (NULL != hdst) { fnFIE_free_object(hdst); }
168int smp_semseg_with_fie(
const char* model_name,
const char* img_name,
const INT category_num)
170 INT ret = F_ERR_NONE;
173 FHANDLE hmask = NULL;
184 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
185 printf_s(
"img: %d\r\n", ret);
191 printf_s(
"lic : %d\r\n", ret);
195 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n");
goto finally; }
196 else { printf_s(
"handle created\r\n"); }
200 printf_s(
"load: %d\r\n", ret);
201 if (F_ERR_NONE != ret) {
goto finally; }
205 printf_s(
"par : %d category=%d\r\n", ret, model_category);
209 hdst = fnFIE_img_root_alloc(F_IMG_US16, 1, w, h);
210 if (NULL == hdst) { printf_s(
"hdst allocation error");
goto finally; }
214 printf_s(
"pred(original): %d\r\n", ret);
215 if (F_ERR_NONE != ret) {
goto finally; }
218 hmask = fnFIE_img_root_alloc(F_IMG_BIN, 1, w, h);
219 if (NULL == hmask) { printf_s(
"hmask allocation error");
goto finally; }
222 for (
int i_cate = 1; i_cate <= category_num; i_cate++) {
224 ret = fnFIE_band_threshold(hdst, hmask, (DOUBLE)i_cate, (DOUBLE)i_cate);
225 if (F_ERR_NONE != ret) {
continue; }
236 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
237 if (NULL != hdst) { fnFIE_free_object(hdst); }
238 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:1680
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1659
MODEL_CATEGORY
モデルの種別
Definition: fv_pdl.h:46
INT fnPDL_check_license()
ライセンス確認
Definition: check_licence.cpp:158
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:1628
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2110
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1501
INT FVALGAPI fnPDL_predict_segmentation(const H_MODEL hmodel, const FHANDLE hsrc, FHANDLE hdst)
推論の実行 ( セグメンテーション )
Definition: prediction_cpp.cpp:1989
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1446
@ SEMANTIC_SEGMENTATION
Definition: fv_pdl.h:58