summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTae-Young Chung <ty83.chung@samsung.com>2015-12-07 18:43:12 +0900
committerTae-Young Chung <ty83.chung@samsung.com>2015-12-07 18:44:24 +0900
commit973b06c23ed5871967646e3451a3d33c8c9decb2 (patch)
tree877cc3dd012da4c8bb0fc0cc91437154e1a25da3
parentf17f579e5ff90af5193047584801729e12836a74 (diff)
downloadmediavision-973b06c23ed5871967646e3451a3d33c8c9decb2.tar.gz
mediavision-973b06c23ed5871967646e3451a3d33c8c9decb2.tar.bz2
mediavision-973b06c23ed5871967646e3451a3d33c8c9decb2.zip
Fixed a bug and remained Svace issues in barcode, face, image modules
1. Fixed the bug of setTolerantError() 2. Fixed remained Svace issues Change-Id: I8db590814dbd28b32cfadcc3c0f0ed6c89113aab Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
-rw-r--r--mv_face/face/src/FaceEyeCondition.cpp8
-rw-r--r--mv_face/face/src/FaceRecognitionModel.cpp2
-rw-r--r--mv_image/image/src/Features/FeatureMatcher.cpp2
-rw-r--r--mv_image/image/src/Tracking/ImageContourStabilizator.cpp2
-rw-r--r--mv_image/image/src/mv_image_open.cpp11
-rw-r--r--packaging/capi-media-vision.spec2
-rw-r--r--test/testsuites/barcode/barcode_test_suite.c54
-rw-r--r--test/testsuites/common/testsuite_common/mv_testsuite_common.c6
-rw-r--r--test/testsuites/face/face_test_suite.c32
-rw-r--r--test/testsuites/image/image_test_suite.c34
10 files changed, 111 insertions, 42 deletions
diff --git a/mv_face/face/src/FaceEyeCondition.cpp b/mv_face/face/src/FaceEyeCondition.cpp
index 53c835ba..22039405 100644
--- a/mv_face/face/src/FaceEyeCondition.cpp
+++ b/mv_face/face/src/FaceEyeCondition.cpp
@@ -64,13 +64,13 @@ void FaceEyeCondition::splitEyes(
const double xRightEyeCenter = (2 * eyeAreaRight.x + eyeAreaRight.width) / 2.;
const double yRightEyeCenter = (2 * eyeAreaRight.y + eyeAreaRight.height) / 2.;
- const cv::Rect leftEyeRect(xLeftEyeCenter - eyeAreaLeft.width / 4,
- yLeftEyeCenter - eyeAreaLeft.height / 4,
+ const cv::Rect leftEyeRect((int)(xLeftEyeCenter - (double)eyeAreaLeft.width / 4),
+ (int)(yLeftEyeCenter - (double)eyeAreaLeft.height / 4),
eyeAreaLeft.width / 2,
eyeAreaLeft.height / 2);
- const cv::Rect rightEyeRect(xRightEyeCenter - eyeAreaRight.width / 4,
- yRightEyeCenter - eyeAreaRight.height / 4,
+ const cv::Rect rightEyeRect((int)(xRightEyeCenter - (double)eyeAreaRight.width / 4),
+ (int)(yRightEyeCenter - (double)eyeAreaRight.height / 4),
eyeAreaRight.width / 2,
eyeAreaRight.height / 2);
diff --git a/mv_face/face/src/FaceRecognitionModel.cpp b/mv_face/face/src/FaceRecognitionModel.cpp
index 1c0c55c4..394e067a 100644
--- a/mv_face/face/src/FaceRecognitionModel.cpp
+++ b/mv_face/face/src/FaceRecognitionModel.cpp
@@ -38,7 +38,7 @@ int CopyOpenCVAlgorithmParameters(const cv::Ptr<cv::FaceRecognizer>& srcAlg,
{
char tempPath[1024];
- sprintf(tempPath, "/tmp/alg_copy_%p_%p", srcAlg.obj, dstAlg.obj);
+ snprintf(tempPath, 1024, "/tmp/alg_copy_%p_%p", srcAlg.obj, dstAlg.obj);
srcAlg->save(tempPath);
dstAlg->load(tempPath);
diff --git a/mv_image/image/src/Features/FeatureMatcher.cpp b/mv_image/image/src/Features/FeatureMatcher.cpp
index dbf72dff..0d00d10b 100644
--- a/mv_image/image/src/Features/FeatureMatcher.cpp
+++ b/mv_image/image/src/Features/FeatureMatcher.cpp
@@ -227,7 +227,7 @@ float FeatureMatcher::getTolerantError() const
void FeatureMatcher::setTolerantError(float tolerantError)
{
- m_affectingPart = std::max(0.f, std::min(1.f, tolerantError));
+ m_tolerantError = std::max(0.f, std::min(1.f, tolerantError));
}
size_t FeatureMatcher::getMinimumMatchesNumber() const
diff --git a/mv_image/image/src/Tracking/ImageContourStabilizator.cpp b/mv_image/image/src/Tracking/ImageContourStabilizator.cpp
index 00a25a03..a745cecb 100644
--- a/mv_image/image/src/Tracking/ImageContourStabilizator.cpp
+++ b/mv_image/image/src/Tracking/ImageContourStabilizator.cpp
@@ -31,6 +31,8 @@ ImageContourStabilizator::ImageContourStabilizator() :
void ImageContourStabilizator::reset(void)
{
+ m_tolerantShift = 0.0f;
+ m_tolerantShiftExtra = 0.0f;
m_isPrepared = false;
m_tempContourIndex = -1;
m_currentHistoryAmount = 0;
diff --git a/mv_image/image/src/mv_image_open.cpp b/mv_image/image/src/mv_image_open.cpp
index df17707c..53d46bb9 100644
--- a/mv_image/image/src/mv_image_open.cpp
+++ b/mv_image/image/src/mv_image_open.cpp
@@ -411,6 +411,8 @@ int mv_image_recognize_open(
convertSourceMV2GrayCV(source, scene),
"Failed to convert mv_source.");
+ int ret = MEDIA_VISION_ERROR_NONE;
+
MediaVision::Image::FeaturesExtractingParams featuresExtractingParams;
extractSceneFeaturesExtractingParams(engine_cfg, featuresExtractingParams);
@@ -431,6 +433,11 @@ int mv_image_recognize_open(
if (isRecognized && (resultContour.size() ==
MediaVision::Image::NumberOfQuadrangleCorners)) {
resultLocations[objectNum] = new mv_quadrangle_s;
+ if (resultLocations[objectNum] == NULL) {
+ ret = MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ goto ErrorExit;
+ }
+
for (size_t pointNum = 0u;
pointNum < MediaVision::Image::NumberOfQuadrangleCorners;
++pointNum) {
@@ -452,6 +459,8 @@ int mv_image_recognize_open(
number_of_objects,
user_data);
+ErrorExit:
+
for (int objectNum = 0; objectNum < number_of_objects; ++objectNum) {
if (resultLocations[objectNum] != NULL) {
delete resultLocations[objectNum];
@@ -459,7 +468,7 @@ int mv_image_recognize_open(
}
}
- return MEDIA_VISION_ERROR_NONE;
+ return ret;
}
int mv_image_track_open(
diff --git a/packaging/capi-media-vision.spec b/packaging/capi-media-vision.spec
index 90fc7f2f..3b297595 100644
--- a/packaging/capi-media-vision.spec
+++ b/packaging/capi-media-vision.spec
@@ -1,6 +1,6 @@
Name: capi-media-vision
Summary: Media Vision library for Tizen Native API
-Version: 0.3.1
+Version: 0.3.2
Release: 0
Group: Multimedia/Framework
License: Apache-2.0 and BSD-2.0
diff --git a/test/testsuites/barcode/barcode_test_suite.c b/test/testsuites/barcode/barcode_test_suite.c
index 93894613..52f845f6 100644
--- a/test/testsuites/barcode/barcode_test_suite.c
+++ b/test/testsuites/barcode/barcode_test_suite.c
@@ -443,8 +443,15 @@ int generate_barcode_to_source(barcode_model_s model)
LOGI("Call the mv_barcode_generate_source() function");
+ mv_engine_config_h mv_engine_config;
+ err = mv_create_engine_config(&mv_engine_config);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occurred during creating the media engine "
+ "config: %i\n", err);
+ }
+
err = mv_barcode_generate_source(
- NULL,
+ mv_engine_config,
model.message,
model.type,
model.mode,
@@ -462,6 +469,12 @@ int generate_barcode_to_source(barcode_model_s model)
"Error code: %i\n", err2);
}
+ const int err3 = mv_destroy_engine_config(mv_engine_config);
+ if (MEDIA_VISION_ERROR_NONE != err3) {
+ printf("ERROR: Errors were occurred during destroying the media engine "
+ "config: %i\n", err3);
+ }
+
MEDIA_VISION_FUNCTION_LEAVE();
return err;
@@ -509,6 +522,12 @@ int generate_barcode_to_source(barcode_model_s model)
"source. Error code: %i\n", err);
}
+ err = mv_destroy_engine_config(mv_engine_config);
+ if (MEDIA_VISION_ERROR_NONE != err) {
+ printf("ERROR: Errors were occurred during destroying the media engine "
+ "config: %i\n", err);
+ }
+
MEDIA_VISION_FUNCTION_LEAVE();
return MEDIA_VISION_ERROR_INTERNAL;
@@ -520,12 +539,26 @@ int generate_barcode_to_source(barcode_model_s model)
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);
- strcpy(jpeg_file_name, model.file_name);
+ if (jpeg_file_name == NULL) {
+ mv_destroy_source(source);
+ mv_destroy_engine_config(mv_engine_config);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ 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);
- strcpy(jpeg_file_name, model.file_name);
- strcpy(jpeg_file_name + strlen(model.file_name), ".jpg");
+ if (jpeg_file_name == NULL) {
+ mv_destroy_source(source);
+ mv_destroy_engine_config(mv_engine_config);
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ 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';
}
@@ -539,6 +572,12 @@ int generate_barcode_to_source(barcode_model_s model)
"Error code: %i\n", err2);
}
+ const int err3 = mv_destroy_engine_config(mv_engine_config);
+ if (MEDIA_VISION_ERROR_NONE != err3) {
+ printf("ERROR: Errors were occurred during destroying the media engine "
+ "config: %i\n", err);
+ }
+
MEDIA_VISION_FUNCTION_LEAVE();
return err;
@@ -656,7 +695,12 @@ int input_string(const char *prompt, size_t max_len, char **string)
size_t real_string_len = strlen(buffer);
buffer[real_string_len - 1] = '\0';
*string = (char*)malloc(real_string_len * sizeof(char));
- strcpy(*string, buffer);
+ if (*string == NULL) {
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return -1;
+ }
+
+ strncpy(*string, buffer, real_string_len);
size_t str_len = strlen(*string);
diff --git a/test/testsuites/common/testsuite_common/mv_testsuite_common.c b/test/testsuites/common/testsuite_common/mv_testsuite_common.c
index 8e229c5e..6ebd567b 100644
--- a/test/testsuites/common/testsuite_common/mv_testsuite_common.c
+++ b/test/testsuites/common/testsuite_common/mv_testsuite_common.c
@@ -103,7 +103,11 @@ int input_string(const char *prompt, size_t max_len, char **string)
size_t real_string_len = strlen(buffer);
buffer[real_string_len - 1] = '\0';
*string = (char*)malloc(real_string_len * sizeof(char));
- strcpy(*string, buffer);
+ if (*string == NULL) {
+ return -1;
+ }
+
+ strncpy(*string, buffer, real_string_len);
return strlen(*string);
}
diff --git a/test/testsuites/face/face_test_suite.c b/test/testsuites/face/face_test_suite.c
index 9da75543..6afbf5ad 100644
--- a/test/testsuites/face/face_test_suite.c
+++ b/test/testsuites/face/face_test_suite.c
@@ -545,7 +545,7 @@ int perform_mv_face_recognition_model_add_face_example(
if (file_name[0] == '.')
continue;
- sprintf(file_path, "%s/%s", in_file_name, file_name);
+ snprintf(file_path, 1024, "%s/%s", in_file_name, file_name);
err = add_single_example(model, file_path, NULL, &face_label);
if (MEDIA_VISION_ERROR_NONE != err) {
@@ -918,7 +918,7 @@ int perform_model_evaluation(mv_face_recognition_model_h model)
if (file_name[0] == '.')
continue;
- sprintf(file_path, "%s/%s", directories[i], file_name);
+ snprintf(file_path, 1024, "%s/%s", directories[i], file_name);
err = load_mv_source_from_file(file_path, source);
if (MEDIA_VISION_ERROR_NONE != err) {
printf(TEXT_RED "Failed to test on example from %s. "
@@ -1056,11 +1056,10 @@ int perform_recognize()
"Error with code %i was occurred during destoy"
TEXT_RESET "\n", err);
}
-
- return err;
} else {
- return MEDIA_VISION_ERROR_NONE;
+ err = MEDIA_VISION_ERROR_NONE;
}
+ break;
default:
sel_opt = 0;
printf("ERROR: Incorrect option was selected.\n");
@@ -1069,8 +1068,12 @@ int perform_recognize()
print_action_result(names[sel_opt - 1], err, notification_type);
- sel_opt = 0;
+ if (sel_opt != 11) {
+ sel_opt = 0;
+ }
}
+
+ return err;
}
int perform_mv_face_tracking_model_save(mv_face_tracking_model_h model)
@@ -1415,13 +1418,13 @@ int perform_mv_face_tracking_model_prepare(mv_face_tracking_model_h model)
char str_prompt[100];
while (idx < 4) {
++idx;
- sprintf(str_prompt, "Specify point %i x coordinate: x%i = ",
+ snprintf(str_prompt, 100, "Specify point %i x coordinate: x%i = ",
idx - 1, idx);
while (-1 == input_int(str_prompt, INT_MIN, INT_MAX,
&(roi.points[idx - 1].x))) {
printf("Incorrect input! Try again.\n");
}
- sprintf(str_prompt, "Specify point %i y coordinate: y%i = ",
+ snprintf(str_prompt, 100, "Specify point %i y coordinate: y%i = ",
idx - 1, idx);
while (-1 == input_int(str_prompt, INT_MIN, INT_MAX,
&(roi.points[idx - 1].y))) {
@@ -1533,7 +1536,7 @@ void track_cb(
}
char file_path[1024];
- sprintf(file_path, "%s/%05d.jpg", track_output_dir, track_frame_counter);
+ snprintf(file_path, 1024, "%s/%05d.jpg", track_output_dir, track_frame_counter);
if (MEDIA_VISION_ERROR_NONE == save_image_from_buffer(
file_path, out_buffer, &image_data, 100)) {
printf("Frame %i was outputted as %s\n", track_frame_counter, file_path);
@@ -1806,11 +1809,10 @@ int perform_track()
"Error with code %i was occurred during destroy"
TEXT_RESET "\n", err);
}
-
- return err;
} else {
- return MEDIA_VISION_ERROR_NONE;
+ err = MEDIA_VISION_ERROR_NONE;
}
+ break;
default:
sel_opt = 0;
printf("ERROR: Incorrect input.\n");
@@ -1819,8 +1821,12 @@ int perform_track()
print_action_result(names[sel_opt - 1], err, notification_type);
- sel_opt = 0;
+ if (sel_opt != 6) {
+ sel_opt = 0;
+ }
}
+
+ return err;
}
int perform_eye_condition_recognize()
diff --git a/test/testsuites/image/image_test_suite.c b/test/testsuites/image/image_test_suite.c
index 1cd9ba78..4e35f816 100644
--- a/test/testsuites/image/image_test_suite.c
+++ b/test/testsuites/image/image_test_suite.c
@@ -85,62 +85,66 @@ void testing_object_fill(
switch (source_type) {
case SOURCE_TYPE_GENERATION: {
if (OBJECT_TYPE_IMAGE_OBJECT == object_type) {
- sprintf(
+ snprintf(
target->origin_label,
+ testing_object_maximum_label_length,
"generated from \"%s\"",
(char*)source);
} else if (OBJECT_TYPE_IMAGE_TRACKING_MODEL == object_type) {
- sprintf(
+ snprintf(
target->origin_label,
+ testing_object_maximum_label_length,
"generated from image object which is %s",
((testing_object_h)source)->actual_label);
} else {
- sprintf(
+ snprintf(
target->origin_label,
+ testing_object_maximum_label_length,
"generated unknown type of testing object");
}
- strcpy(target->actual_label, target->origin_label);
+ strncpy(target->actual_label, target->origin_label, testing_object_maximum_label_length);
break;
}
case SOURCE_TYPE_LOADING: {
- sprintf(target->origin_label, "loaded from \"%s\"", (char*)source);
- strcpy(target->actual_label, target->origin_label);
+ snprintf(target->origin_label, testing_object_maximum_label_length, "loaded from \"%s\"", (char*)source);
+ strncpy(target->actual_label, target->origin_label, testing_object_maximum_label_length);
break;
}
case SOURCE_TYPE_CLONING: {
testing_object_h source_object = (testing_object_h)source;
- strcpy(target->origin_label, source_object->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];
number_of_cloning[0] = '\0';
if (1 < target->cloning_counter) {
- sprintf(number_of_cloning, "%s%i%s",
+ snprintf(number_of_cloning, 10, "%s%i%s",
"(x", target->cloning_counter, ")");
}
char type_name[20];
if (OBJECT_TYPE_IMAGE_OBJECT == object_type)
- sprintf(type_name, "image object");
+ snprintf(type_name, 20, "image object");
else if (OBJECT_TYPE_IMAGE_TRACKING_MODEL == object_type)
- sprintf(type_name, "tracking model");
+ snprintf(type_name, 20, "tracking model");
else
- sprintf(type_name, "unknown object");
+ snprintf(type_name, 20, "unknown object");
- sprintf(target->actual_label, "%s%s%s%s%s%s",
+ snprintf(target->actual_label, testing_object_maximum_label_length,
+ "%s%s%s%s%s%s",
"cloned ", number_of_cloning,
" from ", type_name,
" which is ", target->origin_label);
break;
}
case SOURCE_TYPE_EMPTY: {
- strcpy(target->origin_label, "created an empty");
- strcpy(target->actual_label, target->origin_label);
+ strncpy(target->origin_label, "created an empty", testing_object_maximum_label_length);
+ strncpy(target->actual_label, target->origin_label, testing_object_maximum_label_length);
break;
}
default: {
- strcpy(target->origin_label, "having unknown source");
+ strncpy(target->origin_label, "having unknown source", testing_object_maximum_label_length);
break;
}
}