#include <error.h>
#include <argp.h>
+#include <iostream>
+#include <chrono>
#define MAX_ARGS 2
MEDIA_VISION_FUNCTION_LEAVE();
}
-void perform_detect(struct arguments *arguments)
+int perform_detect(struct arguments *arguments)
{
MEDIA_VISION_FUNCTION_ENTER();
unsigned int image_height = 0;
int int_value = MV_BARCODE_DETECT_ATTR_TARGET_ALL;
mv_rectangle_s roi = { {0, 0}, 0, 0 };
+ int err = MEDIA_VISION_ERROR_NONE;
- int err = load_image_to_buffer(arguments->source,
+ err = load_image_to_buffer(arguments->source,
&data_buffer, &buffer_size, &image_width, &image_height);
if (MEDIA_VISION_ERROR_NONE != err) {
}
err = mv_create_engine_config(&mv_engine_config);
- if (MEDIA_VISION_ERROR_NONE != err)
+ if (MEDIA_VISION_ERROR_NONE != err) {
LOGE("Errors were occurred during creating the media engine config : %i", err);
+ goto out;
+ }
if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
mv_engine_config_get_int_attribute(
roi.width = image_width;
roi.height = image_height;
err = mv_barcode_detect(source, mv_engine_config, roi, barcode_detected_cb, NULL);
- if (MEDIA_VISION_ERROR_NONE != err) {
+ if (MEDIA_VISION_ERROR_NONE != err)
LOGE("Errors were occurred during barcode detection!!! code : %i", err);
- }
out:
if (MEDIA_VISION_ERROR_NONE != err)
printf("-1\n");
}
MEDIA_VISION_FUNCTION_LEAVE();
+ return err;
}
static error_t parse_opt (int key, char *arg, struct argp_state *state)
struct arguments arguments;
argp_parse (&argp, argc, argv, 0, 0, &arguments);
- clock_gettime(CLOCK_MONOTONIC, &s_tspec);
- perform_detect(&arguments);
- clock_gettime(CLOCK_MONOTONIC, &e_tspec);
+ std::chrono::system_clock::time_point StartTime = std::chrono::system_clock::now();
+ int err = perform_detect(&arguments);
+ std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - StartTime);
+ std::cout << ms.count() << "ms" << std::endl;
- struct timespec diffspec = diff(s_tspec, e_tspec);
- unsigned long timeDiff = gettotalmillisec(diffspec);
- printf("%lums\n", timeDiff);
+ if (err != MEDIA_VISION_ERROR_NONE)
+ printf("ERROR: Action is finished with error code: %i\n", err);
LOGI("Media Vision Assessment-Barcode is closed.");
#include <error.h>
#include <argp.h>
+#include <iostream>
+#include <chrono>
#define MAX_ARGS 3
return MEDIA_VISION_ERROR_NONE;
}
-void perform_detect(struct arguments *arguments)
+int perform_detect(struct arguments *arguments)
{
MEDIA_VISION_FUNCTION_ENTER();
}
err = mv_create_engine_config(&mv_engine_config);
- if (MEDIA_VISION_ERROR_NONE != err)
+ if (MEDIA_VISION_ERROR_NONE != err) {
LOGE("Errors were occurred during creating the media engine config : %i", err);
+ goto out;
+ }
mv_engine_config_set_string_attribute(
mv_engine_config,
}
err = mv_face_detect(source, mv_engine_config, on_face_detected_cb, NULL);
- if (MEDIA_VISION_ERROR_NONE != err) {
+ if (MEDIA_VISION_ERROR_NONE != err)
LOGE("Errors were occurred during face detection!!! code : %i", err);
- }
+
out:
if (MEDIA_VISION_ERROR_NONE != err)
printf("-1\n");
}
MEDIA_VISION_FUNCTION_LEAVE();
+ return err;
}
static error_t parse_opt (int key, char *arg, struct argp_state *state)
int main(int argc, char *argv[])
{
- struct timespec s_tspec;
- struct timespec e_tspec;
-
LOGI("Media Vision Assessment-Face is launched.");
struct arguments arguments;
argp_parse (&argp, argc, argv, 0, 0, &arguments);
- clock_gettime(CLOCK_MONOTONIC, &s_tspec);
- perform_detect(&arguments);
- clock_gettime(CLOCK_MONOTONIC, &e_tspec);
+ std::chrono::system_clock::time_point StartTime = std::chrono::system_clock::now();
+ int err = perform_detect(&arguments);
+ std::chrono::milliseconds ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - StartTime);
+ std::cout << ms.count() << "ms" << std::endl;
- struct timespec diffspec = diff(s_tspec, e_tspec);
- unsigned long timeDiff = gettotalmillisec(diffspec);
- printf("%lums\n", timeDiff);
+ if (err != MEDIA_VISION_ERROR_NONE)
+ printf("ERROR: Action is finished with error code: %i\n", err);
LOGI("Media Vision Assessment-Face is closed.");