#include <libavcodec/avcodec.h>
#include <libavutil/pixfmt.h>
+#include <curses.h>
+
+#define MINX 0
+#define MINY 0
+#define MANUAL 0
+#define AUTO 1
+#define SLEEP_INTERVAL 1
+
typedef struct {
mv_barcode_type_e type;
mv_barcode_qr_ecc_e ecc;
MV_TS_GENERATE_TO_SOURCE_FCN
} generation_fcn_e;
+static int current_y = MINY;
+static int mode = MANUAL;
+
int convert_rgb_to(unsigned char *src_buffer, unsigned char **dst_buffer,
image_data_s image_data, mv_colorspace_e dst_colorspace,
unsigned long *cvt_buffer_size)
bool _mv_engine_config_supported_attribute(mv_config_attribute_type_e attribute_type,
const char *attribute_name, void *user_data)
{
- printf("Callback call for engine configuration attribute\n");
+ mvprintw(current_y++, MINX, "Callback call for engine configuration attribute");
if (user_data == NULL)
return false;
if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
mv_engine_config_get_double_attribute(
mv_engine_config, attribute_name, &double_value)) {
- printf("Default double attribute %s wasn't set in engine\n",
+ mvprintw(current_y++, MINX, "Default double attribute %s wasn't set in engine",
attribute_name);
return false;
}
- printf("Default double attribute %s was set to %f in engine\n",
+ mvprintw(current_y++, MINX, "Default double attribute %s was set to %f in engine",
attribute_name, double_value);
break;
case MV_ENGINE_CONFIG_ATTR_TYPE_INTEGER:
if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
mv_engine_config_get_int_attribute(
mv_engine_config, attribute_name, &int_value)) {
- printf("Default integer attribute %s wasn't set in engine\n",
+ mvprintw(current_y++, MINX, "Default integer attribute %s wasn't set in engine",
attribute_name);
return false;
}
- printf("Default interget attribute %s was set to %d in engine\n",
+ mvprintw(current_y++, MINX, "Default interget 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_bool_attribute(
mv_engine_config, attribute_name, &bool_value)) {
- printf("Default bool attribute %s wasn't set in engine\n",
+ mvprintw(current_y++, MINX, "Default bool attribute %s wasn't set in engine",
attribute_name);
return false;
}
- printf("Default bool attribute %s was set to %s in engine\n",
+ mvprintw(current_y++, MINX, "Default bool attribute %s was set to %s in engine",
attribute_name, bool_value ? "TRUE" : "FALSE");
break;
case MV_ENGINE_CONFIG_ATTR_TYPE_STRING:
if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
mv_engine_config_get_string_attribute(
mv_engine_config, attribute_name, &str_value)) {
- printf("Default string ttribute %s wasn't set in engine\n",
+ mvprintw(current_y++, MINX, "Default string ttribute %s wasn't set in engine",
attribute_name);
return false;
}
- printf("Default string attribute %s was set to %s in engine\n",
+ mvprintw(current_y++, MINX, "Default string attribute %s was set to %s in engine",
attribute_name, str_value);
if (str_value != NULL) {
free(str_value);
}
break;
default:
- printf("Not supported attribute type\n");
+ mvprintw(current_y++, MINX, "Not supported attribute type");
return false;
}
{
MEDIA_VISION_FUNCTION_ENTER();
- printf("%i barcodes were detected on the image.\n", number_of_barcodes);
+ mvprintw(current_y++, MINX, "%i barcodes were detected on the image.", number_of_barcodes);
if (number_of_barcodes > 0) {
int is_source_data_loaded = 0;
MEDIA_VISION_ERROR_NONE != mv_source_get_height(source, &(image_data.image_height)) ||
MEDIA_VISION_ERROR_NONE != mv_source_get_colorspace(source, &(image_data.image_colorspace)) ||
user_data == NULL) {
- printf("ERROR: Creating out image is impossible.\n");
+ mvprintw(current_y++, MINX, "ERROR : Creating out image is impossible.");
} else {
file_name = ((barcode_model_s *)user_data)->out_file_name;
draw_buffer = ((barcode_model_s *)user_data)->out_buffer_ptr;
str_type = "Undetected";
break;
}
- printf("\tBarcode %i : type is %s\n", i, str_type);
+ mvprintw(current_y++, MINX, "\tBarcode %i : type is %s", i, str_type);
if (cur_message != NULL)
- printf("\t message is %s\n", cur_message);
+ mvprintw(current_y++, MINX, "\t message is %s", cur_message);
else
- printf("\t message wasn't detected\n");
+ mvprintw(current_y++, MINX, "\t message wasn't detected");
if (is_source_data_loaded == 1) {
int minX = 0;
if (file_name != NULL &&
MEDIA_VISION_ERROR_NONE == save_image_from_buffer(file_name, draw_buffer, &image_data, 100))
- printf("Image was generated as %s\n", file_name);
+ mvprintw(current_y++, MINX, "Image was generated as %s", file_name);
else
- printf("ERROR: Failed to generate output file. Check file name and permissions. \n");
+ mvprintw(current_y++, MINX, "ERROR : Failed to generate output file. Check file name and permissions.");
- printf("\n");
+ current_y++;
}
MEDIA_VISION_FUNCTION_LEAVE();
int 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);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during creating the media engine "
+ "config : %i", err);
MEDIA_VISION_FUNCTION_LEAVE();
return err;
MV_BARCODE_GENERATE_ATTR_TEXT,
model.is_hrt);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occured during set integer attribute to "
- "media engine config: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occured during set integer attribute to "
+ "media engine config : %i", err);
goto cleanup;
}
MV_BARCODE_GENERATE_ATTR_COLOR_FRONT,
model.front_color);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occured during set string attribute to "
- "media engine config: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to "
+ "media engine config : %i", err);
goto cleanup;
}
MV_BARCODE_GENERATE_ATTR_COLOR_BACK,
model.back_color);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occured during set string attribute to "
- "media engine config: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to "
+ "media engine config : %i", err);
goto cleanup;
}
err = mv_barcode_generate_image(mv_engine_config, model.message,
model.mode, model.ecc, model.version,
model.file_name, model.out_image_format);
if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Errors were occurred during generate image error: %i\n",
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during generate image error : %i",
err);
cleanup:
if (MEDIA_VISION_ERROR_NONE != err) {
int err2 = mv_destroy_engine_config(mv_engine_config);
if (MEDIA_VISION_ERROR_NONE != err2)
- printf("ERROR: Errors were occurred during destroying the media engine config: %i\n",
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during destroying the media engine config : %i",
err2);
} else {
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",
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during destroying the media engine config : %i",
err);
}
MEDIA_VISION_FUNCTION_LEAVE();
mv_source_h source = NULL;
int err = mv_create_source(&source);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when trying to create Media Vision "
- "source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when trying to create Media Vision "
+ "source. Error code : %i", err);
MEDIA_VISION_FUNCTION_LEAVE();
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);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during creating the media engine "
+ "config : %i", err);
goto clean_source;
}
MV_BARCODE_GENERATE_ATTR_COLOR_FRONT,
model.front_color);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occured during set string attribute to "
- "media engine config: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occured 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) {
- printf("ERROR: Errors were occured during set string attribute to "
- "media engine config: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occured during set string attribute to "
+ "media engine config : %i", err);
goto clean_all;
}
source);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred during generation barcode to the "
- "Media Vision source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred during generation barcode to the "
+ "Media Vision source. Error code : %i", err);
goto clean_all;
}
err = mv_source_get_buffer(source, &data_buffer, &buffer_size);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when trying to get buffer from "
- "Media Vision source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when trying to get buffer from "
+ "Media Vision source. Error code : %i", err);
goto clean_all;
}
err = mv_source_get_width(source, &image_width);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when trying to get width of "
- "Media Vision source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when trying to get width of "
+ "Media Vision source. Error code : %i", err);
goto clean_all;
}
err = mv_source_get_height(source, &image_height);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when trying to get height of "
- "Media Vision source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when trying to get height of "
+ "Media Vision source. Error code : %i", err);
goto clean_all;
}
err = mv_source_get_colorspace(source, &image_colorspace);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when trying to get colorspace of "
- "Media Vision source. Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when trying to get colorspace of "
+ "Media Vision source. Error code : %i", err);
goto clean_all;
}
}
err = save_image_from_buffer(jpeg_file_name, data_buffer, &image_data, 100);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Error occurred when try to save image from buffer."
- "Error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when try to save image from buffer."
+ "Error code : %i", err);
}
free(jpeg_file_name);
clean_all:
if (MEDIA_VISION_ERROR_NONE != err) {
int err2 = mv_destroy_engine_config(mv_engine_config);
if (MEDIA_VISION_ERROR_NONE != err2)
- printf("ERROR: Errors were occurred during destroying the media engine config: %i\n",
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during destroying the media engine config : %i",
err2);
} else {
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",
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during destroying the media engine config : %i",
err);
}
clean_source:
if (MEDIA_VISION_ERROR_NONE != err) {
int err2 = mv_destroy_source(source);
if (MEDIA_VISION_ERROR_NONE != err2)
- printf("ERROR: Error occurred when try to destroy Media Vision source. Error code: %i\n",
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when try to destroy Media Vision source. Error code : %i",
err2);
} else {
err = mv_destroy_source(source);
if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Error occurred when try to destroy Media Vision source. Error code: %i\n",
+ mvprintw(current_y++, MINX, "ERROR : Error occurred when try to destroy Media Vision source. Error code : %i",
err);
}
MEDIA_VISION_FUNCTION_LEAVE();
int err = load_image_to_buffer(
model.file_name, &data_buffer, &buffer_size, &image_data);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occurred during opening the file!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during opening the file!!! code : %i", err);
if (data_buffer != NULL)
destroy_loaded_buffer(data_buffer);
unsigned long converted_buffer_size = 0;
err = convert_rgb_to(data_buffer, &converted_buffer, image_data, model.colorspace, &converted_buffer_size);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Can't convert to the selected colorspace!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Can't convert to the selected colorspace!!! code : %i", err);
if (data_buffer != NULL)
destroy_loaded_buffer(data_buffer);
mv_engine_config_h mv_engine_config = NULL;
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);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during creating the media engine config : %i", err);
mv_engine_config_foreach_supported_attribute(_mv_engine_config_supported_attribute, mv_engine_config);
MV_BARCODE_DETECT_ATTR_TARGET,
MV_BARCODE_DETECT_ATTR_TARGET_2D_BARCODE);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occurred during target attribute"
- "configuration: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during target attribute"
+ "configuration : %i", err);
}
mv_source_h source;
err = mv_create_source(&source);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occurred during creating the source!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during creating the source!!! code : %i", err);
if (data_buffer != NULL)
destroy_loaded_buffer(data_buffer);
err = mv_source_fill_by_buffer(source, converted_buffer, converted_buffer_size,
image_data.image_width, image_data.image_height, model.colorspace);
if (MEDIA_VISION_ERROR_NONE != err) {
- printf("ERROR: Errors were occurred during filling the source!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during filling the source!!! code : %i", err);
if (data_buffer != NULL)
destroy_loaded_buffer(data_buffer);
destroy_loaded_buffer(data_buffer);
if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Errors were occurred during barcode detection!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during barcode detection!!! code : %i", err);
err = mv_destroy_source(source);
if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Errors were occurred during destroying the source!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during destroying the source!!! code : %i", err);
err = mv_destroy_engine_config(mv_engine_config);
if (MEDIA_VISION_ERROR_NONE != err)
- printf("ERROR: Error were occurred during destroying the source!!! code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Error were occurred during destroying the source!!! code : %i", err);
MEDIA_VISION_FUNCTION_LEAVE();
{
MEDIA_VISION_FUNCTION_ENTER();
- printf("\n");
- printf("%s ", prompt);
-
- if (scanf("\n") != 0) {
- MEDIA_VISION_FUNCTION_LEAVE();
- return -1;
- }
+ mvaddstr(current_y++, MINX, prompt);
char buffer[max_len];
- int last_char = 0;
- buffer[last_char] = '\0';
- buffer[sizeof(buffer) - 1] = ~'\0';
- if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
+ int err = getnstr(buffer, max_len);
+ if (err != OK) {
+ LOGE("getnstr failed with error code (0x%08x)", err);
MEDIA_VISION_FUNCTION_LEAVE();
return -1;
}
- size_t real_string_len = strlen(buffer);
- buffer[real_string_len - 1] = '\0';
+
+ size_t string_len = strlen(buffer);
+ buffer[string_len] = '\0';
+ size_t real_string_len = string_len + 1;
*string = (char*)malloc(real_string_len * sizeof(char));
if (*string == NULL) {
MEDIA_VISION_FUNCTION_LEAVE();
}
strncpy(*string, buffer, real_string_len);
-
size_t str_len = strlen(*string);
+ if (mode == AUTO)
+ sleep(SLEEP_INTERVAL);
+
MEDIA_VISION_FUNCTION_LEAVE();
return str_len;
{
MEDIA_VISION_FUNCTION_ENTER();
- printf("\n");
- printf("%s ", prompt);
+ char buffer[20];
+ mvaddstr(current_y++, MINX, prompt);
- if (scanf("%20zu", size) == 0) {
- if (scanf("%*[^\n]%*c") != 0) {
- printf("ERROR: Reading the input line error.\n");
- MEDIA_VISION_FUNCTION_LEAVE();
- return -1;
- }
- printf("ERROR: Incorrect input.\n");
+ int err = getnstr(buffer, 20);
+ if (err != OK) {
+ LOGE("getnstr failed with error code (0x%08x)", err);
MEDIA_VISION_FUNCTION_LEAVE();
return -1;
}
-
+ *size = atoi(buffer);
int ret = (*size > max_size ? -1 : 0);
+ if (mode == AUTO)
+ sleep(SLEEP_INTERVAL);
+
MEDIA_VISION_FUNCTION_LEAVE();
return ret;
{
MEDIA_VISION_FUNCTION_ENTER();
- printf("\n");
- printf("%s ", prompt);
+ char buffer[20];
+ mvaddstr(current_y++, MINX, prompt);
- if (scanf("%20i", value) == 0) {
- if (scanf("%*[^\n]%*c") != 0) {
- printf("ERROR: Reading the input line error.\n");
- MEDIA_VISION_FUNCTION_LEAVE();
- return -1;
- }
- printf("ERROR: Incorrect input.\n");
+ int err = getnstr(buffer, 20);
+ if (err != OK) {
+ LOGE("getnstr failed with error code (0x%08x)", err);
MEDIA_VISION_FUNCTION_LEAVE();
return -1;
}
-
+ *value = atoi(buffer);
int ret = (*value < min_value || *value > max_value ? -1 : 0);
+ if (mode == AUTO)
+ sleep(SLEEP_INTERVAL);
+
MEDIA_VISION_FUNCTION_LEAVE();
return ret;
{
MEDIA_VISION_FUNCTION_ENTER();
- printf("***************************\n");
- printf("* %23s *\n", title);
- printf("*-------------------------*\n");
+ erase();
+ refresh();
+
+ current_y = MINY;
+ mvaddstr(current_y++, MINX, "***************************");
+ mvprintw(current_y++, MINX, "* %23s *", title);
+ mvaddstr(current_y++, MINX, "*-------------------------*");
int i = 0;
- for (i = 0; i < cnt; ++i)
- printf("* %2i. %19s *\n", options[i], names[i]);
+ for (i = 0; i < cnt; ++i) {
+ mvprintw(current_y++, MINX, "* %2i. %19s *", options[i], names[i]);
+ }
+ mvaddstr(current_y++, MINX, "***************************");
- printf("***************************\n\n");
+ char buf[256];
int selection = 0;
- printf("Your choise: ");
- if (scanf("%20i", &selection) == 0) {
- if (scanf("%*[^\n]%*c") != 0) {
- printf("ERROR: Reading the input line error.\n");
- MEDIA_VISION_FUNCTION_LEAVE();
- return -1;
- }
- printf("ERROR: Incorrect input.\n");
- }
+ bool condition = false;
+ refresh();
+ do {
+ mvaddstr(current_y++, MINX, "Your Choice : ");
+ getstr(&buf);
+ selection = atoi(buf);
+ condition = selection > options[cnt-1];
+ if (condition)
+ mvprintw(current_y++, MINX, "You pressed invalid menu, try again");
+
+ refresh();
+ } while (condition);
+
+ if (mode == AUTO)
+ sleep(SLEEP_INTERVAL);
MEDIA_VISION_FUNCTION_LEAVE();
MEDIA_VISION_FUNCTION_ENTER();
while (sel_opt == 0) {
- sel_opt = show_menu("Select barcode type:", options, names, 8);
+ sel_opt = show_menu("Select barcode type : ", options, names, 8);
switch (sel_opt) {
case 1:
MEDIA_VISION_FUNCTION_ENTER();
while (sel_opt == 0) {
- sel_opt = show_menu("Select encoding mode:", options, names, 4);
+ sel_opt = show_menu("Select encoding mode : ", options, names, 4);
switch (sel_opt) {
case 1:
selected_mode = MV_BARCODE_QR_MODE_NUMERIC;
MEDIA_VISION_FUNCTION_ENTER();
while (sel_opt == 0) {
- sel_opt = show_menu("Select ECC level:", options, names, 4);
+ sel_opt = show_menu("Select ECC level : ", options, names, 4);
switch (sel_opt) {
case 1:
selected_ecc = MV_BARCODE_QR_ECC_LOW;
while (sel_opt == 0) {
const int options[2] = {1, 40};
const char *names[2] = { "1..", "..40" };
- sel_opt = show_menu("Select QR version:", options, names, 2);
+ sel_opt = show_menu("Select QR version : ", options, names, 2);
if (sel_opt < 1 || sel_opt > 40)
sel_opt = 0;
}
MEDIA_VISION_FUNCTION_ENTER();
while (sel_opt == 0) {
- sel_opt = show_menu("Select API function:", options, names, 2);
+ sel_opt = show_menu("Select API function : ", options, names, 2);
switch (sel_opt) {
case 1:
ret_fcn_type = MV_TS_GENERATE_TO_IMAGE_FCN;
MEDIA_VISION_FUNCTION_ENTER();
while (sel_opt == 0) {
- sel_opt = show_menu("Select file format:", options, names, 3);
+ sel_opt = show_menu("Select file format : ", options, names, 3);
switch (sel_opt) {
case 1:
image_format = MV_BARCODE_IMAGE_FORMAT_BMP;
MEDIA_VISION_COLORSPACE_INVALID,
NULL, NULL, NULL, NULL, NULL, NULL };
- while (input_string("Input file name to be analyzed:", 1024, &(detect_model.file_name)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input file name to be analyzed : ", 1024, &(detect_model.file_name)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode input image has been specified");
mv_rectangle_s roi = { {0, 0}, 0, 0 };
- while (input_int("Input x coordinate for ROI top left vertex:", 0, 10000, &(roi.point.x)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_int("Input x coordinate for ROI top left vertex : ", 0, 10000, &(roi.point.x)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
- while (input_int("Input y coordinate for ROI top left vertex:", 0, 10000, &(roi.point.y)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_int("Input y coordinate for ROI top left vertex : ", 0, 10000, &(roi.point.y)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
- while (input_int("Input ROI width:", 0, 10000, &(roi.width)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_int("Input ROI width : ", 0, 10000, &(roi.width)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
- while (input_int("Input ROI height:", 0, 10000, &(roi.height)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_int("Input ROI height : ", 0, 10000, &(roi.height)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Region of interest (ROI) to detect barcode into has been specified");
- while (input_string("Input file name to be generated:", 1024, &(detect_model.out_file_name)) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input file name to be generated : ", 1024, &(detect_model.out_file_name)) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode output image has been specified");
"RGB888", "RGBA" };
while (true) {
- int sel_opt = show_menu("Select colorspace to test detector on:", options, names, 11);
+ int sel_opt = show_menu("Select colorspace to test detector on : ", options, names, 11);
if (sel_opt < MEDIA_VISION_COLORSPACE_Y800 ||
sel_opt > MEDIA_VISION_COLORSPACE_RGBA)
continue;
LOGI("Barcode output image format has been selected");
}
- while (input_string("Input message:", 7089, &generate_model.message) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input message : ", 7089, &generate_model.message) == -1)
+ mvaddstr(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode message has been specified");
- while (input_string("Input file name:", 1024, &generate_model.file_name) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input file name : ", 255, &generate_model.file_name) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode output file name has been specified");
- while (input_string("Input foreground color (ex:black is 000000):", 1024, &generate_model.front_color) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input foreground color (ex:black is 000000) : ", 6, &generate_model.front_color) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Foreground color is %s", generate_model.front_color);
- while (input_string("Input background color (ex:white is ffffff):", 1024, &generate_model.back_color) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_string("Input background color (ex:white is ffffff) : ", 6, &generate_model.back_color) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Background color is %s", generate_model.back_color);
if (gen_fcn == MV_TS_GENERATE_TO_IMAGE_FCN) {
- while (input_size("Input image width:", 10000, &generate_model.width) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_size("Input image width : ", 10000, &generate_model.width) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode output file width has been specified");
- while (input_size("Input image height:", 10000, &generate_model.height) == -1)
- printf("Incorrect input! Try again.\n");
+ while (input_size("Input image height : ", 10000, &generate_model.height) == -1)
+ mvprintw(current_y++, MINX, "Incorrect input! Try again.");
LOGI("Barcode output file height has been specified");
}
if (err != MEDIA_VISION_ERROR_NONE) {
LOGE("Barcode generation failed with error code (0x%08x)", err);
- printf("ERROR: Errors were occurred during barcode generation!!!\n");
+ mvprintw(current_y++, MINX, "ERROR : Errors were occurred during barcode generation!!!");
MEDIA_VISION_FUNCTION_LEAVE();
return err;
}
LOGI("Barcode output file has been generated");
- printf("\nBarcode image was successfully generated.\n");
+ current_y++;
+ mvprintw(current_y++, MINX, "Barcode image was successfully generated.");
+ current_y++;
+ mvprintw(current_y++, MINX, "Press any key to continue...");
+ getch();
MEDIA_VISION_FUNCTION_LEAVE();
return 0;
}
-int main(void)
+void print_usage(char *exe_name)
+{
+ if (!exe_name){
+ fprintf(stderr, current_y++, MINX, "critical error!!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ printf("usage >>\n");
+ printf("\t$ ./%s [--auto] (default mode is manual)\n", exe_name);
+ endwin();
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char *argv[])
{
LOGI("Media Vision Testsuite is launched.");
const int options[2] = { 1, 2 };
const char *names[2] = { "Generate", "Detect" };
+ initscr();
+
+ if (argc > 1 && argv[1] != 0){
+ if (strncmp(argv[1], "--auto", 6) == 0){
+ system("mv_barcode_test_suite_auto");
+ endwin();
+ return 0;
+ } else if (strncmp(argv[1], "--interval", 10) == 0){
+ mode = 1;
+ } else
+ print_usage(argv[0]);
+ } else if (argc == 1){
+ mode = 0;
+ mvaddstr(MINY, MINX, "launched by MANUAL test mode\n");
+ mvaddstr(MINY + 1, MINX, "press any key to continue...");
+ refresh();
+ getch();
+ }
+
while (sel_opt == 0) {
- sel_opt = show_menu("Select action:", options, names, 2);
+ sel_opt = show_menu("Select action : ", options, names, 2);
switch (sel_opt) {
case 1:
LOGI("Start the barcode generation flow");
int do_another = 0;
if (err != MEDIA_VISION_ERROR_NONE)
- printf("ERROR: Action is finished with error code: %i\n", err);
+ mvprintw(current_y++, MINX, "ERROR : Action is finished with error code : %i", err);
sel_opt = 0;
const int options_last[2] = { 1, 2 };
}
LOGI("Media Vision Testsuite is closed.");
+ endwin();
return err;
}