diff options
author | AlejandroColomar <colomar.6.4.3@gmail.com> | 2018-11-07 18:31:19 +0100 |
---|---|---|
committer | AlejandroColomar <colomar.6.4.3@gmail.com> | 2018-11-07 18:31:19 +0100 |
commit | 6a322a3e5ffa6614e856cc9edd941344c2c5bd78 (patch) | |
tree | e0fb9a138510a768687a0b7daafa39c28309ea0b | |
parent | 5212b3901516b46e2ef4197532fade697e0f38df (diff) |
Reorder functions to the order used in openCV;
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | modules/image/inc/img_cv.hpp | 2 | ||||
-rw-r--r-- | modules/image/inc/img_iface.h | 2 | ||||
-rw-r--r-- | modules/image/inc/img_iface.hpp | 78 | ||||
-rw-r--r-- | modules/image/src/img_cv.cpp | 53 | ||||
-rw-r--r-- | modules/image/src/img_iface.cpp | 99 | ||||
-rw-r--r-- | modules/user/inc/user_iface.h | 2 | ||||
-rw-r--r-- | modules/user/inc/user_iface.hpp | 2 | ||||
-rw-r--r-- | modules/user/src/user_clui.c | 44 | ||||
-rw-r--r-- | modules/user/src/user_tui.c | 50 |
10 files changed, 133 insertions, 201 deletions
@@ -1,6 +1,6 @@ #!/usr/bin/make -f VERSION = 2 -PATCHLEVEL = ~b4 +PATCHLEVEL = ~b5 SUBLEVEL = EXTRAVERSION = NAME = diff --git a/modules/image/inc/img_cv.hpp b/modules/image/inc/img_cv.hpp index 6a2af65..c381612 100644 --- a/modules/image/inc/img_cv.hpp +++ b/modules/image/inc/img_cv.hpp @@ -37,9 +37,9 @@ IMG_CV_ACT_ROTATE_ORTO,
IMG_CV_ACT_ROTATE,
IMG_CV_ACT_ADAPTIVE_THRESHOLD,
- IMG_CV_ACT_THRESHOLD,
IMG_CV_ACT_CVT_COLOR,
IMG_CV_ACT_DISTANCE_TRANSFORM,
+ IMG_CV_ACT_THRESHOLD,
IMG_CV_ACT_HISTOGRAM,
IMG_CV_ACT_HISTOGRAM_C3,
IMG_CV_ACT_CONTOURS,
diff --git a/modules/image/inc/img_iface.h b/modules/image/inc/img_iface.h index 4e6ecbc..c2421e5 100644 --- a/modules/image/inc/img_iface.h +++ b/modules/image/inc/img_iface.h @@ -49,9 +49,9 @@ IMG_IFACE_ACT_ROTATE,
IMG_IFACE_ACT_ROTATE_2RECT,
IMG_IFACE_ACT_ADAPTIVE_THRESHOLD,
- IMG_IFACE_ACT_THRESHOLD,
IMG_IFACE_ACT_CVT_COLOR,
IMG_IFACE_ACT_DISTANCE_TRANSFORM,
+ IMG_IFACE_ACT_THRESHOLD,
IMG_IFACE_ACT_HISTOGRAM,
IMG_IFACE_ACT_HISTOGRAM_C3,
IMG_IFACE_ACT_CONTOURS,
diff --git a/modules/image/inc/img_iface.hpp b/modules/image/inc/img_iface.hpp index 371864d..5f6cfa3 100644 --- a/modules/image/inc/img_iface.hpp +++ b/modules/image/inc/img_iface.hpp @@ -55,9 +55,9 @@ IMG_IFACE_ACT_ROTATE,
IMG_IFACE_ACT_ROTATE_2RECT,
IMG_IFACE_ACT_ADAPTIVE_THRESHOLD,
- IMG_IFACE_ACT_THRESHOLD,
IMG_IFACE_ACT_CVT_COLOR,
IMG_IFACE_ACT_DISTANCE_TRANSFORM,
+ IMG_IFACE_ACT_THRESHOLD,
IMG_IFACE_ACT_HISTOGRAM,
IMG_IFACE_ACT_HISTOGRAM_C3,
IMG_IFACE_ACT_CONTOURS,
@@ -122,24 +122,58 @@ ******* structs **************************************************************
******************************************************************************/
/* img_cv --------------------------------------------------------------------*/
+ struct Img_Iface_Data_Pixel_Value {
+ unsigned char *val;
+ int x;
+ int y;
+ };
+
+ struct Img_Iface_Data_SetROI {
+ class cv::Rect_ <int> rect;
+ };
+
struct Img_Iface_Data_Component {
int cmp;
};
- struct Img_Iface_Data_Adaptive_Thr {
+ struct Img_Iface_Data_Dilate_Erode {
+ int i;
+ };
+
+ struct Img_Iface_Data_Smooth {
int method;
- int thr_typ;
int ksize;
};
- struct Img_Iface_Data_Threshold {
+ struct Img_Iface_Data_Sobel {
+ int dx;
+ int dy;
+ int ksize;
+ };
+
+ struct Img_Iface_Data_Rotate_Orto {
+ int n;
+ };
+
+ struct Img_Iface_Data_Rotate {
+ class cv::Point_ <float> center;
+ double angle;
+ };
+
+ struct Img_Iface_Data_Adaptive_Thr {
+ int method;
int thr_typ;
- int thr_val;
+ int ksize;
};
+
struct Img_Iface_Data_Cvt_Color {
int method;
};
+ struct Img_Iface_Data_Threshold {
+ int thr_typ;
+ int thr_val;
+ };
struct Img_Iface_Data_Histogram {
class cv::Mat *hist_c0;
@@ -148,21 +182,6 @@ class cv::Mat *hist_img;
};
- struct Img_Iface_Data_Smooth {
- int method;
- int ksize;
- };
-
- struct Img_Iface_Data_Dilate_Erode {
- int i;
- };
-
- struct Img_Iface_Data_Sobel {
- int dx;
- int dy;
- int ksize;
- };
-
struct Img_Iface_Data_Contours {
std::vector <std::vector <class cv::Point_ <int>>> *contours;
class cv::Mat *hierarchy;
@@ -186,25 +205,6 @@ bool show;
};
- struct Img_Iface_Data_Rotate_Orto {
- int n;
- };
-
- struct Img_Iface_Data_Rotate {
- class cv::Point_ <float> center;
- double angle;
- };
-
- struct Img_Iface_Data_SetROI {
- class cv::Rect_ <int> rect;
- };
-
- struct Img_Iface_Data_Pixel_Value {
- unsigned char *val;
- int x;
- int y;
- };
-
/* img_zbar -------------------------------------------------------------------*/
struct Img_Iface_Data_Decode {
enum zbar::zbar_symbol_type_e code_type;
diff --git a/modules/image/src/img_cv.cpp b/modules/image/src/img_cv.cpp index ca6cbf0..db425e6 100644 --- a/modules/image/src/img_cv.cpp +++ b/modules/image/src/img_cv.cpp @@ -52,13 +52,10 @@ static void img_cv_sobel (class cv::Mat *imgptr, void *data); static void img_cv_rotate_orto (class cv::Mat *imgptr, void *data);
static void img_cv_rotate (class cv::Mat *imgptr, void *data);
/* Miscellaneous image transformations */
- /* threshold */
static void img_cv_adaptive_thr (class cv::Mat *imgptr, void *data);
-static void img_cv_threshold (class cv::Mat *imgptr, void *data);
- /* color */
static void img_cv_cvt_color (class cv::Mat *imgptr, void *data);
- /* transforms */
static void img_cv_distance_transform (class cv::Mat *imgptr);
+static void img_cv_threshold (class cv::Mat *imgptr, void *data);
/* Histograms */
static void img_cv_histogram (class cv::Mat *imgptr, void *data);
static void img_cv_histogram_c3 (class cv::Mat *imgptr, void *data);
@@ -120,17 +117,15 @@ void img_cv_act (class cv::Mat *imgptr, int action, void *data) case IMG_CV_ACT_ADAPTIVE_THRESHOLD:
img_cv_adaptive_thr(imgptr, data);
break;
- case IMG_CV_ACT_THRESHOLD:
- img_cv_threshold(imgptr, data);
- break;
-
case IMG_CV_ACT_CVT_COLOR:
img_cv_cvt_color(imgptr, data);
break;
-
case IMG_CV_ACT_DISTANCE_TRANSFORM:
img_cv_distance_transform(imgptr);
break;
+ case IMG_CV_ACT_THRESHOLD:
+ img_cv_threshold(imgptr, data);
+ break;
case IMG_CV_ACT_HISTOGRAM:
img_cv_histogram(imgptr, data);
@@ -407,26 +402,6 @@ static void img_cv_adaptive_thr (class cv::Mat *imgptr, void *data) 0);
}
-static void img_cv_threshold (class cv::Mat *imgptr, void *data)
-{
- /* Data */
- struct Img_Iface_Data_Threshold *data_cast;
- data_cast = (struct Img_Iface_Data_Threshold *)data;
-
- /* Threshold type */
- int thr_typ;
- thr_typ = data_cast->thr_typ;
- /* Threshold value */
- int thr_val;
- thr_val = data_cast->thr_val;
- if (thr_val == -1) {
- thr_typ |= cv::THRESH_OTSU;
- }
-
- /* Threshold */
- cv::threshold(*imgptr, *imgptr, thr_val, 0xFF, thr_typ);
-}
-
static void img_cv_cvt_color (class cv::Mat *imgptr, void *data)
{
/* Data */
@@ -454,6 +429,26 @@ static void img_cv_distance_transform (class cv::Mat *imgptr) imgtmp.release();
}
+static void img_cv_threshold (class cv::Mat *imgptr, void *data)
+{
+ /* Data */
+ struct Img_Iface_Data_Threshold *data_cast;
+ data_cast = (struct Img_Iface_Data_Threshold *)data;
+
+ /* Threshold type */
+ int thr_typ;
+ thr_typ = data_cast->thr_typ;
+ /* Threshold value */
+ int thr_val;
+ thr_val = data_cast->thr_val;
+ if (thr_val == -1) {
+ thr_typ |= cv::THRESH_OTSU;
+ }
+
+ /* Threshold */
+ cv::threshold(*imgptr, *imgptr, thr_val, 0xFF, thr_typ);
+}
+
static void img_cv_histogram (class cv::Mat *imgptr, void *data)
{
/* Data */
diff --git a/modules/image/src/img_iface.cpp b/modules/image/src/img_iface.cpp index 0dc0342..3876619 100644 --- a/modules/image/src/img_iface.cpp +++ b/modules/image/src/img_iface.cpp @@ -100,13 +100,10 @@ static void img_iface_rotate_orto (void *data); static void img_iface_rotate (void *data);
static void img_iface_rotate_2rect (void *data);
/* Miscellaneous image transformations */
- /* threshold */
static void img_iface_adaptive_thr (void *data);
-static void img_iface_threshold (void *data);
- /* color */
static void img_iface_cvt_color (void *data);
- /* transforms */
static void img_iface_distance_transform (void);
+static void img_iface_threshold (void *data);
/* Histograms */
static void img_iface_histogram (void *data);
static void img_iface_histogram_c3 (void *data);
@@ -264,21 +261,18 @@ void img_iface_act (int action, void *data) img_iface_rotate_2rect(data);
break;
/* Miscellaneous image transformations */
- /* threshold */
case IMG_IFACE_ACT_ADAPTIVE_THRESHOLD:
img_iface_adaptive_thr(data);
break;
- case IMG_IFACE_ACT_THRESHOLD:
- img_iface_threshold(data);
- break;
- /* color */
case IMG_IFACE_ACT_CVT_COLOR:
img_iface_cvt_color(data);
break;
- /* transforms */
case IMG_IFACE_ACT_DISTANCE_TRANSFORM:
img_iface_distance_transform();
break;
+ case IMG_IFACE_ACT_THRESHOLD:
+ img_iface_threshold(data);
+ break;
/* Histograms */
case IMG_IFACE_ACT_HISTOGRAM:
img_iface_histogram(data);
@@ -865,7 +859,6 @@ static void img_iface_rotate_2rect (void *data) }
/* ----- ------- Miscellaneous image transformations */
-/* ----- ------- ------- threshold */
static void img_iface_adaptive_thr (void *data)
{
/* Must have 1 channel */
@@ -911,48 +904,6 @@ static void img_iface_adaptive_thr (void *data) img_cv_act(&image_copy_tmp, IMG_CV_ACT_ADAPTIVE_THRESHOLD, data);
}
-static void img_iface_threshold (void *data)
-{
- /* Must have 1 channel */
- if (image_copy_tmp.channels() != 1) {
- /* Write into log */
- snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
- "! Invalid input");
- user_iface_log.lvl[user_iface_log.len] = 1;
- (user_iface_log.len)++;
-
- return;
- }
-
- /* Data */
- struct Img_Iface_Data_Threshold data_tmp;
- if (!data) {
- /* Ask user */
- char title [80];
- snprintf(title, 80, "Type: BIN=0, BIN_INV=1, TRUNC=2, TOZ=3, TOZ_INV=4");
- data_tmp.thr_typ = user_iface_getint(0, 0, 4, title, NULL);
-
- snprintf(title, 80, "Value: 0 to 255 (or -1 for Otsu's algorithm)");
- data_tmp.thr_val = user_iface_getint(-1, 0, 255, title, NULL);
-
- data = (void *)&data_tmp;
- }
-
- /* Write into log */
- struct Img_Iface_Data_Threshold *data_cast;
- data_cast = (struct Img_Iface_Data_Threshold *)data;
- snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
- "Threshold typ=%i, val=%i",
- data_cast->thr_typ,
- data_cast->thr_val);
- user_iface_log.lvl[user_iface_log.len] = 1;
- (user_iface_log.len)++;
-
- /* Filter: threshold */
- img_cv_act(&image_copy_tmp, IMG_CV_ACT_THRESHOLD, data);
-}
-
-/* ----- ------- ------- color */
static void img_iface_cvt_color (void *data)
{
/* Must have at least 3 channels */
@@ -992,7 +943,6 @@ static void img_iface_cvt_color (void *data) img_cv_act(&image_copy_tmp, IMG_CV_ACT_CVT_COLOR, data);
}
-/* ----- ------- ------- transforms */
static void img_iface_distance_transform (void)
{
/* Must have 1 channel */
@@ -1016,6 +966,47 @@ static void img_iface_distance_transform (void) img_cv_act(&image_copy_tmp, IMG_CV_ACT_DISTANCE_TRANSFORM, NULL);
}
+static void img_iface_threshold (void *data)
+{
+ /* Must have 1 channel */
+ if (image_copy_tmp.channels() != 1) {
+ /* Write into log */
+ snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
+ "! Invalid input");
+ user_iface_log.lvl[user_iface_log.len] = 1;
+ (user_iface_log.len)++;
+
+ return;
+ }
+
+ /* Data */
+ struct Img_Iface_Data_Threshold data_tmp;
+ if (!data) {
+ /* Ask user */
+ char title [80];
+ snprintf(title, 80, "Type: BIN=0, BIN_INV=1, TRUNC=2, TOZ=3, TOZ_INV=4");
+ data_tmp.thr_typ = user_iface_getint(0, 0, 4, title, NULL);
+
+ snprintf(title, 80, "Value: 0 to 255 (or -1 for Otsu's algorithm)");
+ data_tmp.thr_val = user_iface_getint(-1, 0, 255, title, NULL);
+
+ data = (void *)&data_tmp;
+ }
+
+ /* Write into log */
+ struct Img_Iface_Data_Threshold *data_cast;
+ data_cast = (struct Img_Iface_Data_Threshold *)data;
+ snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
+ "Threshold typ=%i, val=%i",
+ data_cast->thr_typ,
+ data_cast->thr_val);
+ user_iface_log.lvl[user_iface_log.len] = 1;
+ (user_iface_log.len)++;
+
+ /* Filter: threshold */
+ img_cv_act(&image_copy_tmp, IMG_CV_ACT_THRESHOLD, data);
+}
+
/* ----- ------- Histograms */
static void img_iface_histogram (void *data)
{
diff --git a/modules/user/inc/user_iface.h b/modules/user/inc/user_iface.h index d69fbda..098a7a0 100644 --- a/modules/user/inc/user_iface.h +++ b/modules/user/inc/user_iface.h @@ -55,9 +55,9 @@ USER_IFACE_ACT_ROTATE,
USER_IFACE_ACT_ROTATE_2RECT,
USER_IFACE_ACT_ADAPTIVE_THRESHOLD,
- USER_IFACE_ACT_THRESHOLD,
USER_IFACE_ACT_CVT_COLOR,
USER_IFACE_ACT_DISTANCE_TRANSFORM,
+ USER_IFACE_ACT_THRESHOLD,
USER_IFACE_ACT_HISTOGRAM,
USER_IFACE_ACT_HISTOGRAM_C3,
USER_IFACE_ACT_CONTOURS,
diff --git a/modules/user/inc/user_iface.hpp b/modules/user/inc/user_iface.hpp index 14457a7..3a2c034 100644 --- a/modules/user/inc/user_iface.hpp +++ b/modules/user/inc/user_iface.hpp @@ -55,9 +55,9 @@ USER_IFACE_ACT_ROTATE,
USER_IFACE_ACT_ROTATE_2RECT,
USER_IFACE_ACT_ADAPTIVE_THRESHOLD,
- USER_IFACE_ACT_THRESHOLD,
USER_IFACE_ACT_CVT_COLOR,
USER_IFACE_ACT_DISTANCE_TRANSFORM,
+ USER_IFACE_ACT_THRESHOLD,
USER_IFACE_ACT_HISTOGRAM,
USER_IFACE_ACT_HISTOGRAM_C3,
USER_IFACE_ACT_CONTOURS,
diff --git a/modules/user/src/user_clui.c b/modules/user/src/user_clui.c index e722f4c..a4fa8ed 100644 --- a/modules/user/src/user_clui.c +++ b/modules/user/src/user_clui.c @@ -271,40 +271,16 @@ static int usr_input (void) /* Miscellaneous image transformations */
switch (ch[4]) {
case '0':
- /* Threshold */
- switch (ch[5]) {
- case '0':
- action = USER_IFACE_ACT_ADAPTIVE_THRESHOLD;
- break;
- case '1':
- action = USER_IFACE_ACT_THRESHOLD;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_ADAPTIVE_THRESHOLD;
break;
case '1':
- /* Color */
- switch (ch[5]) {
- case '0':
- action = USER_IFACE_ACT_CVT_COLOR;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_CVT_COLOR;
break;
case '2':
- /* Transforms */
- switch (ch[5]) {
- case '0':
- action = USER_IFACE_ACT_DISTANCE_TRANSFORM;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_DISTANCE_TRANSFORM;
+ break;
+ case '3':
+ action = USER_IFACE_ACT_THRESHOLD;
break;
default:
action = USER_IFACE_ACT_FOO;
@@ -479,10 +455,10 @@ static void show_help (void) printf(" - Rotate ortogonally: %s\n", "f1110");
printf(" - Rotate: %s\n", "f1111");
printf(" - Rotate 2rect_rot: %s\n", "f1112");
- printf(" - Adaptive threshold: %s\n", "f11200");
- printf(" - Threshold: %s\n", "f11201");
- printf(" - Cvt color: %s\n", "f11210");
- printf(" - Distance transform: %s\n", "f11220");
+ printf(" - Adaptive threshold: %s\n", "f1120");
+ printf(" - Threshold: %s\n", "f1121");
+ printf(" - Cvt color: %s\n", "f1122");
+ printf(" - Distance transform: %s\n", "f1123");
printf(" - Histogram: %s\n", "f1130");
printf(" - Histogram (3 chan): %s\n", "f1131");
printf(" - Contours: %s\n", "f1140");
diff --git a/modules/user/src/user_tui.c b/modules/user/src/user_tui.c index d0e7257..696a1de 100644 --- a/modules/user/src/user_tui.c +++ b/modules/user/src/user_tui.c @@ -378,46 +378,16 @@ static int usr_input (void) switch (ch) {
case '0':
- /* Threshold */
- ch = wgetch(win_log);
-
- switch (ch) {
- case '0':
- action = USER_IFACE_ACT_ADAPTIVE_THRESHOLD;
- break;
- case '1':
- action = USER_IFACE_ACT_THRESHOLD;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_ADAPTIVE_THRESHOLD;
break;
case '1':
- /* Color */
- ch = wgetch(win_log);
-
- switch (ch) {
- case '0':
- action = USER_IFACE_ACT_CVT_COLOR;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_CVT_COLOR;
break;
case '2':
- /* Transforms */
- ch = wgetch(win_log);
-
- switch (ch) {
- case '0':
- action = USER_IFACE_ACT_DISTANCE_TRANSFORM;
- break;
- default:
- action = USER_IFACE_ACT_FOO;
- break;
- }
+ action = USER_IFACE_ACT_DISTANCE_TRANSFORM;
+ break;
+ case '3':
+ action = USER_IFACE_ACT_THRESHOLD;
break;
default:
action = USER_IFACE_ACT_FOO;
@@ -617,10 +587,10 @@ static void show_help (void) mvwprintw(win_help, r++, c, " - Rotate ortogonally: %s", "f1110");
mvwprintw(win_help, r++, c, " - Rotate: %s", "f1111");
mvwprintw(win_help, r++, c, " - Rotate 2rect_rot: %s", "f1112");
- mvwprintw(win_help, r++, c, " - Adaptive threshold: %s", "f11200");
- mvwprintw(win_help, r++, c, " - Threshold: %s", "f11201");
- mvwprintw(win_help, r++, c, " - Cvt color: %s", "f11210");
- mvwprintw(win_help, r++, c, " - Distance transform: %s", "f11220");
+ mvwprintw(win_help, r++, c, " - Adaptive threshold: %s", "f1120");
+ mvwprintw(win_help, r++, c, " - Threshold: %s", "f1121");
+ mvwprintw(win_help, r++, c, " - Cvt color: %s", "f1122");
+ mvwprintw(win_help, r++, c, " - Distance transform: %s", "f1123");
mvwprintw(win_help, r++, c, " - Histogram: %s", "f1130");
mvwprintw(win_help, r++, c, " - Histogram (3 chan): %s", "f1131");
mvwprintw(win_help, r++, c, " - Contours: %s", "f1140");
|