*/
typedef struct {
unsigned int trigger_id; /**< Unique event trigger identifier */
- const char *event_type; /**< Type of the event */
+ char *event_type; /**< Type of the event */
int number_of_roi_points; /**< Number of ROI (Region of interest) points */
mv_point_s *roi; /**< ROI points array */
} mv_surveillance_event_trigger_s;
static int check_source_roi_quadrangle(mv_quadrangle_s *roi, mv_source_h source)
{
- int ret = MEDIA_VISION_ERROR_NONE;
-
- if (roi) {
- unsigned int src_w = 0;
- unsigned int src_h = 0;
-
- ret = mv_source_get_width(source, &src_w);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("mv_source_get_width fail");
- return ret;
- }
-
- ret = mv_source_get_height(source, &src_h);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("mv_source_get_height fail");
- return ret;
- }
-
- int idx = 0;
- while (idx < 4) {
- if (roi->points[idx].x < 0 || roi->points[idx].y < 0 ||
- roi->points[idx].x > src_w || roi->points[idx].y > src_h) {
- LOGE("roi is out of area on source");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
- ++idx;
+ int ret;
+ unsigned int src_w, src_h;
+ if (roi == NULL) {
+ LOGE("roi is null");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ ret = mv_source_get_width(source, &src_w);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_source_get_width fail");
+ return ret;
+ }
+ ret = mv_source_get_height(source, &src_h);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_source_get_height fail");
+ return ret;
+ }
+ for (int idx = 0; idx < 4; idx++) {
+ if (roi->points[idx].x < 0 || roi->points[idx].y < 0 ||
+ roi->points[idx].x > src_w || roi->points[idx].y > src_h) {
+ LOGE("roi is out of area on source");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
}
-
return ret;
}
-static int check_source_roi(mv_rectangle_s *roi, mv_source_h source)
+static int check_source_roi(const mv_rectangle_s *roi, mv_source_h source)
{
- int ret = MEDIA_VISION_ERROR_NONE;
-
- if (roi) {
- unsigned int src_w = 0;
- unsigned int src_h = 0;
-
- ret = mv_source_get_width(source, &src_w);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("mv_source_get_width fail");
- return ret;
- }
-
- ret = mv_source_get_height(source, &src_h);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("mv_source_get_height fail");
- return ret;
- }
-
- if (roi->width <= 0 || roi->height <= 0) {
- LOGE("roi has negative width or height");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (roi->point.x < 0 || roi->point.y < 0 ||
- (roi->point.x + roi->width) > src_w ||
- (roi->point.y + roi->height) > src_h) {
- LOGE("roi is out of area on source");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
+ int ret;
+ unsigned int src_w, src_h;
+ if (roi == NULL) {
+ LOGE("roi is null");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ if (roi->width <= 0 || roi->height <= 0) {
+ LOGE("roi width, height must be positive value");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+ ret = mv_source_get_width(source, &src_w);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_source_get_width fail");
+ return ret;
+ }
+ ret = mv_source_get_height(source, &src_h);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_source_get_height fail");
+ return ret;
+ }
+ if (roi->point.x < 0 || roi->point.y < 0 ||
+ (roi->point.x + roi->width) > src_w ||
+ (roi->point.y + roi->height) > src_h) {
+ LOGE("roi is out of area on source");
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
-
return ret;
}
int ret = check_source_roi(face_location, source);
if (MEDIA_VISION_ERROR_NONE != ret) {
- LOGE("Errors occured when check source and ROI");
+ LOGE("Errors occurred when check source and ROI");
return ret;
}
int ret = check_source_roi(example_location, source);
if (MEDIA_VISION_ERROR_NONE != ret) {
- LOGE("Errors occured when check source and ROI");
+ LOGE("Errors occurred when check source and ROI");
return ret;
}
int ret = check_source_roi_quadrangle(location, source);
if (MEDIA_VISION_ERROR_NONE != ret) {
- LOGE("Errors occured when check source and tracking start location");
+ LOGE("Errors occurred when check source and tracking start location");
return ret;
}
MEDIA_VISION_FUNCTION_ENTER();
if (number_of_points <= 0) {
- LOGE("number of points shoulde be larger than zero");
+ LOGE("number of points should be larger than zero");
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
#include <libswscale/swscale.h>
#include <libavcodec/avcodec.h>
attribute_name);
return false;
}
- mvprintw(current_y++, MINX, "Default interget attribute %s was set to %d in engine",
+ mvprintw(current_y++, MINX, "Default integer attribute %s was set to %d in engine",
attribute_name, int_value);
break;
case MV_ENGINE_CONFIG_ATTR_TYPE_BOOLEAN:
if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
mv_engine_config_get_string_attribute(
mv_engine_config, attribute_name, &str_value)) {
- mvprintw(current_y++, MINX, "Default string ttribute %s wasn't set in engine",
+ mvprintw(current_y++, MINX, "Default string attribute %s wasn't set in engine",
attribute_name);
return false;
}
MV_BARCODE_GENERATE_ATTR_COLOR_FRONT,
model.front_color);
if (MEDIA_VISION_ERROR_NONE != err) {
- mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to "
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during set string attribute to "
"media engine config : %i", err);
goto clean_all;
}
MV_BARCODE_GENERATE_ATTR_COLOR_BACK,
model.back_color);
if (MEDIA_VISION_ERROR_NONE != err) {
- mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to "
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during set string attribute to "
"media engine config : %i", err);
goto clean_all;
}
const image_data_s image_data = { image_width, image_height, image_colorspace };
- char *jpeg_file_name = "";
+ char *jpeg_file_name;
if (0 == strcmp(model.file_name + strlen(model.file_name) - 4, ".jpg") ||
0 == strcmp(model.file_name + strlen(model.file_name) - 5, ".jpeg")) {
- jpeg_file_name = (char*)malloc(strlen(model.file_name) + 1);
+ jpeg_file_name = strdup(model.file_name);
if (jpeg_file_name == NULL) {
err = MEDIA_VISION_ERROR_OUT_OF_MEMORY;
goto clean_all;
}
-
- strncpy(jpeg_file_name, model.file_name, strlen(model.file_name) + 1);
- jpeg_file_name[strlen(model.file_name)] = '\0';
} else {
jpeg_file_name = (char*)malloc(strlen(model.file_name) + 5);
if (jpeg_file_name == NULL) {
err = MEDIA_VISION_ERROR_OUT_OF_MEMORY;
goto clean_all;
}
-
- strncpy(jpeg_file_name, model.file_name, strlen(model.file_name) + 5);
- strncpy(jpeg_file_name + strlen(model.file_name), ".jpg", 5);
- jpeg_file_name[strlen(model.file_name) + 4] = '\0';
+ strcpy(jpeg_file_name, model.file_name);
+ strcat(jpeg_file_name, ".jpg");
}
err = save_image_from_buffer(jpeg_file_name, data_buffer, &image_data, 100);
if (MEDIA_VISION_ERROR_NONE != err) {
int perform_mv_face_recognition_model_query_labels(mv_face_recognition_model_h model)
{
int *learned_labels = NULL;
- int learned_labels_n = 0;
+ unsigned int learned_labels_n = 0;
- const int err = mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n);
+ int err = mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n);
if (MEDIA_VISION_ERROR_NONE != err) {
free(learned_labels);
return err;
}
- int i = 0;
printf(TEXT_YELLOW "Recognition model had been learned for the following labels: "
TEXT_RESET "\n" TEXT_GREEN);
- for (i = 0; i < learned_labels_n; ++i)
+ for (unsigned i = 0; i < learned_labels_n; ++i)
printf("%i, ", learned_labels[i]);
printf(TEXT_RESET "\n");
int perform_model_evaluation(mv_face_recognition_model_h model)
{
int *learned_labels = NULL;
- int learned_labels_n = 0;
+ unsigned learned_labels_n = 0;
mv_face_recognition_model_query_labels(model, &learned_labels, &learned_labels_n);
int i = 0;
-
printf(TEXT_YELLOW "Evaluating model had been learned for the following labels: "
TEXT_RESET "\n" TEXT_GREEN);
for (i = 0; i < learned_labels_n; ++i)
err = mv_face_recognition_model_destroy(recognition_model);
if (MEDIA_VISION_ERROR_NONE != err) {
printf(TEXT_RED
- "Error with code %i was occurred during destoy"
+ "Error with code %i was occurred during destroy"
TEXT_RESET "\n", err);
}
} else {
void *user_data)
{
if (number_of_faces < 1) {
- printf(TEXT_RED "Unfortunatly, no faces were detected on the\n"
+ printf(TEXT_RED "Unfortunately, no faces were detected on the\n"
"preparation frame. You has to specify bounding\n"
"quadrangles for tracking without advices."
TEXT_RESET "\n");
"generated from \"%s\"",
(char*)source);
} else if (OBJECT_TYPE_IMAGE_TRACKING_MODEL == object_type) {
- snprintf(
- target->origin_label,
- testing_object_maximum_label_length,
- "generated from image object which is %s",
- ((testing_object_h)source)->actual_label);
+ strcpy(target->origin_label, "generated from image object which is ");
+ strcat(target->origin_label, ((testing_object_h)source)->actual_label);
} else {
snprintf(
target->origin_label,
strncpy(target->origin_label, source_object->origin_label, testing_object_maximum_label_length);
target->cloning_counter = source_object->cloning_counter + 1;
- char number_of_cloning[10];
+ char number_of_cloning[20];
number_of_cloning[0] = '\0';
if (1 < target->cloning_counter) {
- snprintf(number_of_cloning, 10, "%s%i%s",
+ snprintf(number_of_cloning, 20, "%s%i%s",
"(x", target->cloning_counter, ")");
}
snprintf(type_name, 20, "unknown object");
snprintf(target->actual_label, testing_object_maximum_label_length,
- "%s%s%s%s%s%s",
+ "%s%s%s%s%s",
"cloned ", number_of_cloning,
" from ", type_name,
- " which is ", target->origin_label);
+ " which is ");
+ strcat(target->actual_label, target->origin_label);
break;
}
case SOURCE_TYPE_EMPTY: {
char *path_to_image = NULL;
char *path_to_generated_image = NULL;
- image_data_s image_data = {0};
while (input_string("Input path for tracking:",
1024, &path_to_image) == -1) {
"Tracking cases",
"Exit" };
- mv_image_object_h current_object = NULL;
-
while (1) {
char exit = 'n';
int sel_opt = show_menu("Select action:", options, names, 3);