6int smp_mvcnn_simple(
const char*model_name,
const char* img_folder)
13 FHANDLE* hsrcs = NULL;
26 printf_s(
"lic : %d\r\n", ret);
27 if (F_ERR_NONE != ret) {
goto finally; }
33 printf_s(
"failed to create handle\r\n");
36 else { printf_s(
"handle created\r\n"); }
40 printf_s(
"load: %d\r\n", ret);
41 if (F_ERR_NONE != ret) {
goto finally; }
45 printf_s(
"par : %d category=%d\r\n", ret, model_category);
46 if (F_ERR_NONE != ret) {
goto finally; }
48 ret = F_ERR_INVALID_OBJECT;
49 printf_s(
"unmatch model\r\n");
55 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
56 if (F_ERR_NONE != ret) {
goto finally; }
60 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
61 if (F_ERR_NONE != ret) {
goto finally; }
65 printf_s(
"# of views=%d\r\n", n_views);
66 if (F_ERR_NONE != ret) {
goto finally; }
69 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
72 printf_s(
"malloc error\r\n");
77 for (i_img = 0; i_img < n_views; i_img++) {
78 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
79 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
80 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
81 if (F_ERR_NONE != ret) {
goto finally; }
87 printf_s(
"pred: %d\r\n", ret);
88 if (F_ERR_NONE != ret) {
goto finally; }
89 if (NULL != scores && 0 < n_scores) {
91 printf_s(
" # of scores = %zd\r\n", n_scores);
92 for (i_score = 0; i_score < n_scores; i_score++) {
93 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
108 for (i_img = 0; i_img < n_views; i_img++) {
109 fnFIE_free_object(hsrcs[i_img]);
113 if (NULL != scores) { fnOAL_free(scores); }
119int smp_mvcnn_benchmark(
const char*model_name,
const char* img_folder,
const int bench_iter)
122 std::chrono::system_clock::time_point start, end;
124 INT ret = F_ERR_NONE;
128 FHANDLE* hsrcs = NULL;
130 FLOAT* scores = NULL;
138 printf_s(
"lic : %d\r\n", ret);
139 if (F_ERR_NONE != ret) {
goto finally; }
143 if (NULL == hmodel) {
144 ret = F_ERR_NOMEMORY;
145 printf_s(
"failed to create handle\r\n");
148 else { printf_s(
"handle created\r\n"); }
152 printf_s(
"load: %d\r\n", ret);
153 if (F_ERR_NONE != ret) {
goto finally; }
157 printf_s(
"par : %d category=%d\r\n", ret, model_category);
158 if (F_ERR_NONE != ret) {
goto finally; }
160 ret = F_ERR_INVALID_OBJECT;
161 printf_s(
"unmatch model\r\n");
167 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
168 if (F_ERR_NONE != ret) {
goto finally; }
172 printf_s(
"# of views=%d\r\n", n_views);
173 if (F_ERR_NONE != ret) {
goto finally; }
176 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
178 ret = F_ERR_NOMEMORY;
179 printf_s(
"malloc error\r\n");
184 for (i_img = 0; i_img < n_views; i_img++) {
185 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
186 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
187 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
188 if (F_ERR_NONE != ret) {
goto finally; }
195 printf_s(
"--- start ---\r\n");
196 printf_s(
"number, elapsed[msec], scores\r\n");
197 for (
int i = 0; i < bench_iter; i++) {
201 start = std::chrono::system_clock::now();
207 end = std::chrono::system_clock::now();
209 if (F_ERR_NONE != ret) {
210 printf_s(
"pred. err: %d\r\n", ret);
215 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
218 printf_s(
"%04d, %.3e", i, elapsed);
219 for (
int i_score = 0; i_score < n_scores; i_score++) {
220 printf_s(
", %.6e", scores[i_score]);
224 printf_s(
"--- finish ---\r\n");
236 for (i_img = 0; i_img < n_views; i_img++) {
237 fnFIE_free_object(hsrcs[i_img]);
241 if (NULL != scores) { fnOAL_free(scores); }
247int smp_mvcnn_with_fie(
const char*model_name,
const char* img_folder)
249 INT ret = F_ERR_NONE;
253 FHANDLE* hsrcs = NULL;
254 FHANDLE* hfiltereds = NULL;
256 FLOAT* scores = NULL;
264 printf_s(
"lic : %d\r\n", ret);
265 if (F_ERR_NONE != ret) {
goto finally; }
269 if (NULL == hmodel) {
270 ret = F_ERR_NOMEMORY;
271 printf_s(
"failed to create handle\r\n");
274 else { printf_s(
"handle created\r\n"); }
278 printf_s(
"load: %d\r\n", ret);
279 if (F_ERR_NONE != ret) {
goto finally; }
283 printf_s(
"par : %d category=%d\r\n", ret, model_category);
284 if (F_ERR_NONE != ret) {
goto finally; }
286 ret = F_ERR_INVALID_OBJECT;
287 printf_s(
"unmatch model\r\n");
293 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
294 if (F_ERR_NONE != ret) {
goto finally; }
298 printf_s(
"# of views=%d\r\n", n_views);
299 if (F_ERR_NONE != ret) {
goto finally; }
302 hsrcs = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
304 ret = F_ERR_NOMEMORY;
305 printf_s(
"malloc error\r\n");
310 for (i_img = 0; i_img < n_views; i_img++) {
311 std::string image_path = std::string(img_folder) + std::to_string(i_img) +
".bmp";
312 ret = fnFIE_load_bmp(image_path.c_str(), &(hsrcs[i_img]), F_COLOR_IMG_TYPE_UC8);
313 printf_s(
"img ( #=%d ): %d\r\n", i_img, ret);
314 if (F_ERR_NONE != ret) {
goto finally; }
324 printf_s(
"pred: %d\r\n", ret);
325 if (F_ERR_NONE != ret) {
goto finally; }
326 if (NULL != scores && 0 < n_scores) {
328 printf_s(
" # of scores = %zd\r\n", n_scores);
329 for (i_score = 0; i_score < n_scores; i_score++) {
330 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
339 hfiltereds = (FHANDLE*)fnOAL_calloc(n_views,
sizeof(FHANDLE));
340 if (NULL == hfiltereds) {
341 ret = F_ERR_NOMEMORY;
342 printf_s(
"malloc error ( filtered images )\r\n");
347 for (i_img = 0; i_img < n_views; i_img++) {
348 hfiltereds[i_img] = fnFIE_img_root_alloc(F_IMG_UC8, ch, w, h);
349 if (NULL == hfiltereds[i_img]) {
350 ret = F_ERR_NOMEMORY;
351 printf_s(
"malloc error ( filtered images )\r\n");
358 for (i_img = 0; i_img < n_views; i_img++) {
359 FHANDLE hsrc = hsrcs[i_img];
360 FHANDLE hdst = hfiltereds[i_img];
361 ret = fnFIE_average(hsrc, hdst, 0, 0);
362 if (F_ERR_NONE != ret) {
goto finally; }
368 printf_s(
"pred(average): %d\r\n", ret);
369 if (F_ERR_NONE != ret) {
goto finally; }
370 if (NULL != scores && 0 < n_scores) {
372 printf_s(
" # of scores = %zd\r\n", n_scores);
373 for (i_score = 0; i_score < n_scores; i_score++) {
374 printf_s(
" label%d: %.6e\r\n", i_score, scores[i_score]);
386 for (i_img = 0; i_img < n_views; i_img++) {
387 fnFIE_free_object(hsrcs[i_img]);
391 if (NULL != hfiltereds) {
393 for (i_img = 0; i_img < n_views; i_img++) {
394 fnFIE_free_object(hfiltereds[i_img]);
396 fnOAL_free(hfiltereds);
398 if (NULL != scores) { fnOAL_free(scores); }
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
INT FVALGAPI fnPDL_get_how_many_views(const H_MODEL hmodel, INT *num_views)
モデルパラメータの取得
Definition: prediction_cpp.cpp:2013
INT FVALGAPI fnPDL_predict_multi_images(const H_MODEL hmodel, INT num_images, FHANDLE *hsrcs, FLOAT **scores, size_t *num_scores)
推論の実行 ( 多視点画像分類、多視点アノマリー検出 )
Definition: prediction_cpp.cpp:2295
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
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1755
@ MULTI_VIEW_CNN
Definition: fv_pdl.h:54