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);
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);
44 printf_s(
"par : %d category=%d\r\n", ret, model_category);
46 ret = F_ERR_INVALID_OBJECT;
47 printf_s(
"unmatch model\r\n");
53 printf_s(
"ret : %d backend=%d\r\n", ret, model_backend);
57 printf_s(
"par : %d ch=%d w=%d h=%d\r\n", ret, ch, w, h);
61 printf_s(
"pred: %d\r\n", ret);
62 if (NULL != detections && 0 < num_detections) {
64 printf_s(
" # of detections = %zd\r\n", num_detections);
65 for (i_det = 0; i_det < num_detections; i_det++) {
67 DBOX_T box = detection.
box;
68 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
69 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
81 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
82 if (NULL != detections) { fnOAL_free(detections); }
88int smp_objdet_benchmark(
const char* model_name,
const char* img_name,
const int bench_iter)
91 std::chrono::system_clock::time_point start, end;
98 size_t num_detections;
104 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
105 printf_s(
"img: %d\r\n", ret);
106 if (F_ERR_NONE != ret) {
goto finally; }
110 printf_s(
"lic : %d\r\n", ret);
114 if (NULL == hmodel) {
115 ret = F_ERR_NOMEMORY;
116 printf_s(
"failed to create handle\r\n");
119 else { printf_s(
"handle created\r\n"); }
123 printf_s(
"load: %d\r\n", ret);
127 printf_s(
"par : %d category=%d\r\n", ret, model_category);
129 ret = F_ERR_INVALID_OBJECT;
130 printf_s(
"unmatch model\r\n");
134 printf_s(
"--- start ---\r\n");
135 printf_s(
"ret, elapsed[msec], num_detections\r\n");
137 for (
int i = 0; i < bench_iter; i++) {
141 start = std::chrono::system_clock::now();
147 end = std::chrono::system_clock::now();
149 if (F_ERR_NONE != ret) {
150 printf_s(
"pred. err: %d\r\n", ret);
155 elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() / (double)1000;
158 printf_s(
"%04d, %.3e, %zd\r\n", i, elapsed, num_detections);
161 fnOAL_free(detections);
164 printf_s(
"--- finish ---\r\n");
172 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
173 if (NULL != detections) { fnOAL_free(detections); }
179int smp_objdet_with_fie(
const char* model_name,
const char* img_name)
181 INT ret = F_ERR_NONE;
186 size_t num_detections;
188 FHANDLE hfiltered = NULL;
196 ret = fnFIE_load_img_file(img_name, &hsrc, F_COLOR_IMG_TYPE_UC8);
197 printf_s(
"img: %d\r\n", ret);
203 printf_s(
"lic : %d\r\n", ret);
207 if (NULL == hmodel) {
208 ret = F_ERR_NOMEMORY;
209 printf_s(
"failed to create handle\r\n");
212 else { printf_s(
"handle created\r\n"); }
216 printf_s(
"load: %d\r\n", ret);
217 if (F_ERR_NONE != ret) {
goto finally; }
221 printf_s(
"par : %d category=%d\r\n", ret, model_category);
223 ret = F_ERR_INVALID_OBJECT;
224 printf_s(
"unmatch model\r\n");
234 printf_s(
"pred(original): %d\r\n", ret);
235 if (F_ERR_NONE != ret) {
goto finally; }
236 if (NULL != detections && 0 < num_detections) {
238 printf_s(
" # of detections = %zd\r\n", num_detections);
239 for (i_det = 0; i_det < num_detections; i_det++) {
241 DBOX_T box = detection.
box;
242 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
243 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
246 fnOAL_free(detections);
254 ret = fnFIE_img_get_params(hsrc, &ch, &type, &step, &w, &h);
255 if (F_ERR_NONE != ret) {
goto finally; }
256 hfiltered = fnFIE_img_root_alloc(type, ch, w, h);
257 if (NULL == hfiltered) { ret = F_ERR_NOMEMORY;
goto finally; }
258 ret = fnFIE_average(hsrc, hfiltered, 0, 0);
259 if (F_ERR_NONE != ret) {
goto finally; }
263 printf_s(
"pred(average): %d\r\n", ret);
264 if (F_ERR_NONE != ret) {
goto finally; }
265 if (NULL != detections && 0 < num_detections) {
267 printf_s(
" # of detections = %zd\r\n", num_detections);
268 for (i_det = 0; i_det < num_detections; i_det++) {
270 DBOX_T box = detection.
box;
271 printf_s(
" label: %d, score %.2f, box: (st=(%.1f,%.1f), ed=(%.1f,%.1f))\r\n",
272 detection.
class_id, detection.
score, box.st.x, box.st.y, box.ed.x, box.ed.y);
283 if (NULL != hsrc) { fnFIE_free_object(hsrc); }
284 if (NULL != hfiltered) { fnFIE_free_object(hfiltered); }
285 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: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_predict_object_detection(const H_MODEL hmodel, const FHANDLE hsrc, F_OD_RESULT **detections, size_t *num_detections)
推論の実行 ( 物体検出 )
Definition: prediction_cpp.cpp:2394
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
@ OBJECT_DETECTION
Definition: fv_pdl.h:62
物体検出結果
Definition: fv_pdl.h:92
INT class_id
Definition: fv_pdl.h:98
DBOX_T box
Definition: fv_pdl.h:94
FLOAT score
Definition: fv_pdl.h:96