5int smp_objdet_simple(
const char* model_name,
const char* img_name)
13 size_t num_detections;
20 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
21 printf_s(
"img: %d\r\n", ret);
27 printf_s(
"lic : %d\r\n", ret);
31 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
32 else { printf_s(
"handle created\r\n"); }
36 printf_s(
"load: %d\r\n", ret);
40 printf_s(
"par : %d category=%d\r\n", ret, model_category);
45 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
49 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
53 printf_s(
"pred: %d\r\n", ret);
54 if (NULL != detections && 0 < num_detections) {
56 printf_s(
" # of detections = %zd\r\n", num_detections);
57 for (i_det = 0; i_det < num_detections; i_det++) {
59 DBOX_T box = detection.
box;
60 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
61 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
71 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
72 if (NULL != detections) { fnOAL_free(detections); }
78int smp_objdet_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
81 std::chrono::system_clock::time_point start, end;
88 size_t num_detections;
94 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
95 printf_s(
"img: %d\r\n", ret);
96 if (F_ERR_NONE != ret) {
goto finally; }
100 printf_s(
"lic : %d\r\n", ret);
104 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n"); }
105 else { printf_s(
"handle created\r\n"); }
109 printf_s(
"load: %d\r\n", ret);
113 printf_s(
"par : %d category=%d\r\n", ret, model_category);
116 printf_s(
"--- start ---\r\n");
117 printf_s(
"ret, elapsed[msec], num_detections\r\n");
119 for (
int i = 0; i < bench_iter; i++) {
123 start = std::chrono::system_clock::now();
129 end = std::chrono::system_clock::now();
131 if (F_ERR_NONE != ret) {
132 printf_s(
"pred. err: %d\r\n", ret);
137 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
140 printf_s(
"%04d, %.3e, %zd\r\n", i, elapsed, num_detections);
143 fnOAL_free(detections);
146 printf_s(
"--- finish ---\r\n");
153 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
154 if (NULL != detections) { fnOAL_free(detections); }
160int smp_objdet_with_fie(
const char* model_name,
const char* img_name)
162 INT ret = F_ERR_NONE;
167 size_t num_detections;
169 FHANDLE hfiltered = NULL;
177 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
178 printf_s(
"img: %d\r\n", ret);
184 printf_s(
"lic : %d\r\n", ret);
188 if (NULL == hmodel) { printf_s(
"failed to create handle\r\n");
goto finally; }
189 else { printf_s(
"handle created\r\n"); }
193 printf_s(
"load: %d\r\n", ret);
194 if (F_ERR_NONE != ret) {
goto finally; }
198 printf_s(
"par : %d category=%d\r\n", ret, model_category);
199 if (
CLASSIFICATION != model_category) { printf_s(
"unmatch model"); }
207 printf_s(
"pred(original): %d\r\n", ret);
208 if (F_ERR_NONE != ret) {
goto finally; }
209 if (NULL != detections && 0 < num_detections) {
211 printf_s(
" # of detections = %zd\r\n", num_detections);
212 for (i_det = 0; i_det < num_detections; i_det++) {
214 DBOX_T box = detection.
box;
215 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
216 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
219 fnOAL_free(detections);
227 ret = fnFIE_img_get_params(hsrc, &ch, &type, &step, &w, &h);
228 if (F_ERR_NONE != ret) {
goto finally; }
229 hfiltered = fnFIE_img_root_alloc(type, ch, w, h);
230 if (NULL == hfiltered) { ret = F_ERR_NOMEMORY;
goto finally; }
231 ret = fnFIE_average(hsrc, hfiltered, 0, 0);
232 if (F_ERR_NONE != ret) {
goto finally; }
236 printf_s(
"pred(average): %d\r\n", ret);
237 if (F_ERR_NONE != ret) {
goto finally; }
238 if (NULL != detections && 0 < num_detections) {
240 printf_s(
" # of detections = %zd\r\n", num_detections);
241 for (i_det = 0; i_det < num_detections; i_det++) {
243 DBOX_T box = detection.
box;
244 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
245 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
255 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
256 if (NULL != hfiltered) { fnFIE_free_object(hfiltered); }
257 if (NULL != detections) { fnOAL_free(detections); }
INT FVALGAPI fnPDL_get_input_image_size(const H_MODEL hmodel, INT *channels, INT *width, INT *height)
モデルパラメータの取得
Definition: prediction_cpp.cpp:1914
INT FVALGAPI fnPDL_get_model_backend(const H_MODEL hmodel, MODEL_BACKEND *model_backend)
モデルのバックエンドの取得
Definition: prediction_cpp.cpp:1893
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:1862
VOID FVALGAPI fnPDL_dispose(H_MODEL hmodel)
モデルハンドルの解放
Definition: prediction_cpp.cpp:2440
INT FVALGAPI fnPDL_predict_object_detection(const H_MODEL hmodel, const FHANDLE hsrc, F_OD_RESULT **detections, size_t *num_detections)
推論の実行 ( 物体検出 )
Definition: prediction_cpp.cpp:2319
INT FVALGAPI fnPDL_load_model(const CHAR *filename, H_MODEL hmodel)
モデルの読み込み
Definition: prediction_cpp.cpp:1735
VOID * H_MODEL
モデルハンドル
Definition: fv_pdl.h:18
H_MODEL *FVALGAPI fnPDL_create_handle()
モデルハンドルの生成
Definition: prediction_cpp.cpp:1680
@ SEMANTIC_SEGMENTATION
Definition: fv_pdl.h:58
@ CLASSIFICATION
Definition: fv_pdl.h:50
物体検出結果
Definition: fv_pdl.h:88
INT class_id
Definition: fv_pdl.h:94
DBOX_T box
Definition: fv_pdl.h:90
FLOAT score
Definition: fv_pdl.h:92