summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-03 22:23:42 +0100
committerAlejandroColomar <colomar.6.4.3@gmail.com>2019-01-03 22:23:42 +0100
commit94db029813a084c7f9bf0e28136aa4336205b9bf (patch)
treee98dcc3caf849bc5c5c6e9a0510baaa0d8b93753
parent1effa04751a567bab5590e333eadadc1181b4e34 (diff)
parentddbe05a3b4bd4ec8b195f7526f886896ac0f9610 (diff)
Merge branch 'devel' into lighter
-rw-r--r--Makefile6
-rw-r--r--bin/Makefile5
-rw-r--r--modules/Makefile1
-rw-r--r--modules/image/inc/img_cv.hpp3
-rw-r--r--modules/image/inc/img_iface.h3
-rw-r--r--modules/image/inc/img_iface.hpp11
-rw-r--r--modules/image/src/img_alx.cpp60
-rw-r--r--modules/image/src/img_cv.cpp42
-rw-r--r--modules/image/src/img_iface.cpp92
-rw-r--r--modules/proc/inc/proc_common.hpp118
-rw-r--r--modules/proc/src/proc_coins.cpp2
-rw-r--r--modules/proc/src/proc_common.cpp15
-rw-r--r--modules/proc/src/proc_objects.cpp2
-rw-r--r--modules/proc/src/proc_resistor.cpp34
-rw-r--r--modules/user/inc/user_iface.h3
-rw-r--r--modules/user/inc/user_iface.hpp3
-rw-r--r--modules/user/src/user_clui.c8
-rw-r--r--modules/user/src/user_tui.c8
-rw-r--r--tmp/Makefile7
19 files changed, 264 insertions, 159 deletions
diff --git a/Makefile b/Makefile
index 2bee939..2d63163 100644
--- a/Makefile
+++ b/Makefile
@@ -216,21 +216,25 @@ libalx:
$(Q)$(MAKE) base -C $(LIBALX_DIR)
$(Q)$(MAKE) io -C $(LIBALX_DIR)
$(Q)$(MAKE) curses -C $(LIBALX_DIR)
+ @echo
PHONY += modules
modules: libalx
@echo ' MAKE modules'
$(Q)$(MAKE) -C $(MODULES_DIR)
+ @echo
PHONY += main
main: modules libalx
@echo ' MAKE main'
$(Q)$(MAKE) -C $(TMP_DIR)
+ @echo
PHONY += binary
binary: main
@echo ' MAKE binary'
$(Q)$(MAKE) -C $(BIN_DIR)
+ @echo
PHONY += install
install: uninstall
@@ -264,11 +268,13 @@ clean:
$(Q)$(MAKE) clean -C $(TMP_DIR)
@echo ' CLEAN bin'
$(Q)$(MAKE) clean -C $(BIN_DIR)
+ @echo
PHONY += mrproper
mrproper: clean
@echo ' CLEAN libalx'
$(Q)$(MAKE) clean -C $(LIBALX_DIR)
+ @echo
PHONY += help
help:
diff --git a/bin/Makefile b/bin/Makefile
index 5e0ff01..79add73 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -33,13 +33,12 @@ all: $(ALL)
$(BIN_NAME): $(MAIN_OBJS) $(MAIN_LIBS)
+ @echo " CXX $@"
$(Q)$(CXX) $(MAIN_OBJS) -o $@ $(STATIC_LIBS) $(LIBS)
- @echo " CXX $@"
- @echo ""
clean:
- @echo " RM $(ALL)"
+ @echo " RM $(ALL)"
$(Q)rm -f $(ALL)
################################################################################
diff --git a/modules/Makefile b/modules/Makefile
index 2e41afa..61b5871 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -46,7 +46,6 @@ all:
$(Q)$(MAKE) -C $(USR_DIR)
@echo ' MAKE modules.o'
$(Q)$(MAKE) -C $(TMP_DIR)
- @echo
PHONY += clean
diff --git a/modules/image/inc/img_cv.hpp b/modules/image/inc/img_cv.hpp
index a14371f..7412f46 100644
--- a/modules/image/inc/img_cv.hpp
+++ b/modules/image/inc/img_cv.hpp
@@ -24,7 +24,8 @@
IMG_CV_ACT_FOO = 0x000000u,
IMG_CV_ACT_CV = 0x000100u,
- IMG_CV_ACT_PIXEL_VALUE,
+ IMG_CV_ACT_PIXEL_GET,
+ IMG_CV_ACT_PIXEL_SET,
IMG_CV_ACT_SET_ROI,
IMG_CV_ACT_AND_2REF,
IMG_CV_ACT_NOT,
diff --git a/modules/image/inc/img_iface.h b/modules/image/inc/img_iface.h
index 00bf4d6..bfdbb70 100644
--- a/modules/image/inc/img_iface.h
+++ b/modules/image/inc/img_iface.h
@@ -52,7 +52,8 @@
IMG_IFACE_ACT_MEDIAN_VERTICAL,
IMG_IFACE_ACT_CV = 0x000100u,
- IMG_IFACE_ACT_PIXEL_VALUE,
+ IMG_IFACE_ACT_PIXEL_GET,
+ IMG_IFACE_ACT_PIXEL_SET,
IMG_IFACE_ACT_SET_ROI,
IMG_IFACE_ACT_SET_ROI_2RECT,
IMG_IFACE_ACT_AND_2REF,
diff --git a/modules/image/inc/img_iface.hpp b/modules/image/inc/img_iface.hpp
index a8b3a1f..c492537 100644
--- a/modules/image/inc/img_iface.hpp
+++ b/modules/image/inc/img_iface.hpp
@@ -61,7 +61,8 @@
IMG_IFACE_ACT_MEDIAN_VERTICAL,
IMG_IFACE_ACT_CV = 0x000100u,
- IMG_IFACE_ACT_PIXEL_VALUE,
+ IMG_IFACE_ACT_PIXEL_GET,
+ IMG_IFACE_ACT_PIXEL_SET,
IMG_IFACE_ACT_SET_ROI,
IMG_IFACE_ACT_SET_ROI_2RECT,
IMG_IFACE_ACT_AND_2REF,
@@ -153,12 +154,18 @@
******* structs **************************************************************
******************************************************************************/
/* img_cv --------------------------------------------------------------------*/
- struct Img_Iface_Data_Pixel_Value {
+ struct Img_Iface_Data_Pixel_Get {
unsigned char *val;
int x;
int y;
};
+ struct Img_Iface_Data_Pixel_Set {
+ unsigned char val;
+ int x;
+ int y;
+ };
+
struct Img_Iface_Data_SetROI {
class cv::Rect_ <int> rect;
};
diff --git a/modules/image/src/img_alx.cpp b/modules/image/src/img_alx.cpp
index 6f172fe..093ff69 100644
--- a/modules/image/src/img_alx.cpp
+++ b/modules/image/src/img_alx.cpp
@@ -1,5 +1,6 @@
/******************************************************************************
* Copyright (C) 2018 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: (GPL-2.0-only OR LGPL-3.0-only) *
******************************************************************************/
@@ -30,7 +31,7 @@
/******************************************************************************
- ******* static functions *****************************************************
+ ******* static functions (prototypes) ****************************************
******************************************************************************/
static void img_alx_local_max (class cv::Mat *imgptr);
static void img_alx_skeleton (class cv::Mat *imgptr);
@@ -43,10 +44,11 @@ static void img_alx_median_vertical (class cv::Mat *imgptr);
/******************************************************************************
- ******* main *****************************************************************
+ ******* global functions *****************************************************
******************************************************************************/
void img_alx_act (class cv::Mat *imgptr, int action, void *data)
{
+
switch (action) {
case IMG_ALX_ACT_LOCAL_MAX:
img_alx_local_max(imgptr);
@@ -79,7 +81,7 @@ void img_alx_act (class cv::Mat *imgptr, int action, void *data)
/******************************************************************************
- ******* static functions *****************************************************
+ ******* static functions (definitions) ***************************************
******************************************************************************/
static void img_alx_local_max (class cv::Mat *imgptr)
{
@@ -87,7 +89,6 @@ static void img_alx_local_max (class cv::Mat *imgptr)
int j;
int k;
int l;
- bool local_max;
/* Minimum distance between local maxima */
const int dist_min = 16;
/* Minimum value of local maxima */
@@ -108,30 +109,30 @@ static void img_alx_local_max (class cv::Mat *imgptr)
for (j = 0; j < imgptr->cols; j++) {
img_pix = imgptr->data + i * imgptr->step + j;
tmp_pix = imgtmp.data + i * imgptr->step + j;
- local_max = true;
+ *tmp_pix = 0;
if (*img_pix < val_min) {
- local_max = false;
+ goto next_pixel;
}
- for (k = i - dist_min; (k < i + dist_min+1) && local_max; k++) {
- for (l = j - dist_min; (l < j + dist_min+1) && local_max; l++) {
+ for (k = (i - dist_min); k < (i + dist_min + 1); k++) {
+ for (l = (j - dist_min); l < (j + dist_min + 1); l++) {
near_pix = imgptr->data + k * imgptr->step + l;
if ((k >= 0) && (k < imgptr->rows)) {
if ((l >= 0) && (l < imgptr->cols)) {
if (*img_pix < *near_pix) {
- local_max = false;
+ goto next_pixel;
}
}
}
}
}
- if (local_max) {
- *tmp_pix = *img_pix;
- } else {
- *tmp_pix = 0;
- }
+ *tmp_pix = *img_pix;
+ continue;
+
+next_pixel:
+ *tmp_pix = 0;
}
}
@@ -142,21 +143,14 @@ static void img_alx_local_max (class cv::Mat *imgptr)
static void img_alx_skeleton (class cv::Mat *imgptr)
{
- int i;
- int j;
- int k;
- int l;
- int r;
+ /* (Half of the) width of the skeleton */
+ const int width = 5;
int dist_x;
int dist_y;
- /* Width of the skeleton */
- const int width = 5;
- /* Minimum value of the skeleton */
- bool skeleton;
- int cnt_lo [width];
- int cnt_hi_or_eq [width];
+ bool skeleton;
+ int cnt_lo [width];
+ int cnt_hi_or_eq [width];
class cv::Mat imgtmp;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
/* pointer to a pixel near img_pix (in imgptr) */
@@ -164,6 +158,12 @@ static void img_alx_skeleton (class cv::Mat *imgptr)
/* pointer to a pixel (same position as img_pix, but in imgtmp) */
uint8_t *tmp_pix;
+ int i;
+ int j;
+ int k;
+ int l;
+ int r;
+
/* Tmp image copy */
imgptr->copyTo(imgtmp);
@@ -181,7 +181,6 @@ static void img_alx_skeleton (class cv::Mat *imgptr)
cnt_lo[r] = 0;
cnt_hi_or_eq[r] = 0;
}
- skeleton = false;
for (k = i - width; k <= i + width; k++) {
for (l = j - width; l <= j + width; l++) {
@@ -205,6 +204,7 @@ static void img_alx_skeleton (class cv::Mat *imgptr)
}
}
+ skeleton = false;
for (r = 0; r < width; r++) {
if (cnt_lo[r] > (cnt_hi_or_eq[r] + (1.6) * (r + 1))) {
skeleton = true;
@@ -229,7 +229,6 @@ static void img_alx_lines_horizontal (class cv::Mat *imgptr)
int i;
int j;
bool white;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
@@ -258,7 +257,6 @@ static void img_alx_lines_vertical (class cv::Mat *imgptr)
int i;
int j;
bool white;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
@@ -288,7 +286,6 @@ static void img_alx_mean_horizontal (class cv::Mat *imgptr)
int j;
uint32_t tmp;
uint8_t mean;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
@@ -313,7 +310,6 @@ static void img_alx_mean_vertical (class cv::Mat *imgptr)
int j;
uint32_t tmp;
uint8_t mean;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
@@ -338,7 +334,6 @@ static void img_alx_median_horizontal (class cv::Mat *imgptr)
int j;
uint8_t row [imgptr->cols];
uint8_t median;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
@@ -362,7 +357,6 @@ static void img_alx_median_vertical (class cv::Mat *imgptr)
int j;
uint8_t col [imgptr->rows];
uint8_t median;
-
/* pointer to a pixel (in imgptr) */
uint8_t *img_pix;
diff --git a/modules/image/src/img_cv.cpp b/modules/image/src/img_cv.cpp
index ce3e647..3a7c59b 100644
--- a/modules/image/src/img_cv.cpp
+++ b/modules/image/src/img_cv.cpp
@@ -34,7 +34,8 @@
******************************************************************************/
/* Core: The core functionality */
/* Pixel */
-static void img_cv_pixel_value (class cv::Mat *imgptr, void *data);
+static void img_cv_pixel_get (class cv::Mat *imgptr, void *data);
+static void img_cv_pixel_set (class cv::Mat *imgptr, void *data);
/* ROI */
static void img_cv_set_ROI (class cv::Mat *imgptr, void *data);
/* Operations on Arrays */
@@ -77,8 +78,11 @@ static void img_cv_hough_circles (class cv::Mat *imgptr, void *data);
void img_cv_act (class cv::Mat *imgptr, int action, void *data)
{
switch (action) {
- case IMG_CV_ACT_PIXEL_VALUE:
- img_cv_pixel_value(imgptr, data);
+ case IMG_CV_ACT_PIXEL_GET:
+ img_cv_pixel_get(imgptr, data);
+ break;
+ case IMG_CV_ACT_PIXEL_SET:
+ img_cv_pixel_set(imgptr, data);
break;
case IMG_CV_ACT_SET_ROI:
@@ -172,25 +176,45 @@ void img_cv_act (class cv::Mat *imgptr, int action, void *data)
******************************************************************************/
/* Core: The core functionality */
/* ----- Pixel */
-static void img_cv_pixel_value (class cv::Mat *imgptr, void *data)
+static void img_cv_pixel_get (class cv::Mat *imgptr, void *data)
{
+ struct Img_Iface_Data_Pixel_Get *data_cast;
+ unsigned char *val;
+ int x;
+ int y;
/* Data */
- struct Img_Iface_Data_Pixel_Value *data_cast;
- data_cast = (struct Img_Iface_Data_Pixel_Value *)data;
+ data_cast = (struct Img_Iface_Data_Pixel_Get *)data;
/* Value */
- unsigned char *val;
val = data_cast->val;
/* Position */
- int x;
x = data_cast->x;
- int y;
y = data_cast->y;
/* Get value */
*val = imgptr->at<unsigned char>(y, x);
}
+static void img_cv_pixel_set (class cv::Mat *imgptr, void *data)
+{
+ struct Img_Iface_Data_Pixel_Set *data_cast;
+ unsigned char val;
+ int x;
+ int y;
+
+ /* Data */
+ data_cast = (struct Img_Iface_Data_Pixel_Set *)data;
+
+ /* Value */
+ val = data_cast->val;
+ /* Position */
+ x = data_cast->x;
+ y = data_cast->y;
+
+ /* Set value */
+ imgptr->at<unsigned char>(y, x) = val;
+}
+
/* ----- ROI */
static void img_cv_set_ROI (class cv::Mat *imgptr, void *data)
{
diff --git a/modules/image/src/img_iface.cpp b/modules/image/src/img_iface.cpp
index ce87044..3bdcf09 100644
--- a/modules/image/src/img_iface.cpp
+++ b/modules/image/src/img_iface.cpp
@@ -102,7 +102,8 @@ static void img_iface_median_vertical (void);
/* img_cv */
/* Core: The core functionality */
/* Pixel */
-static void img_iface_pixel_value (void *data);
+static void img_iface_pixel_get (void *data);
+static void img_iface_pixel_set (void *data);
/* ROI */
static void img_iface_set_ROI (void *data);
static void img_iface_set_ROI_2rect (void *data);
@@ -267,8 +268,11 @@ void img_iface_act (int action, void *data)
/* img_cv */
/* Core: The core functionality */
/* Pixel */
- case IMG_IFACE_ACT_PIXEL_VALUE:
- img_iface_pixel_value(data);
+ case IMG_IFACE_ACT_PIXEL_GET:
+ img_iface_pixel_get(data);
+ break;
+ case IMG_IFACE_ACT_PIXEL_SET:
+ img_iface_pixel_set(data);
break;
/* ROI */
case IMG_IFACE_ACT_SET_ROI:
@@ -631,8 +635,13 @@ static void img_iface_median_vertical (void)
/* img_cv --------------------------------------------------------------------*/
/* ----- Core: The core functionality */
/* ----- ------- Pixel */
-static void img_iface_pixel_value (void *data)
+static void img_iface_pixel_get (void *data)
{
+ struct Img_Iface_Data_Pixel_Get data_tmp;
+ struct Img_Iface_Data_Pixel_Get *data_cast;
+ unsigned char val;
+ char title [80];
+
/* Must have 1 channel */
if (image_copy_tmp.channels() != 1) {
/* Write into log */
@@ -645,13 +654,10 @@ static void img_iface_pixel_value (void *data)
}
/* Data */
- struct Img_Iface_Data_Pixel_Value data_tmp;
- unsigned char val;
if (!data) {
data_tmp.val = &val;
/* Ask user */
- char title [80];
snprintf(title, 80, "x:");
data_tmp.x = user_iface_getint(0, 0,
image_copy_tmp.cols,
@@ -665,14 +671,13 @@ static void img_iface_pixel_value (void *data)
data = (void *)&data_tmp;
}
- /* Contours size */
- img_cv_act(&image_copy_tmp, IMG_CV_ACT_PIXEL_VALUE, data);
+ /* Get pixel value */
+ img_cv_act(&image_copy_tmp, IMG_CV_ACT_PIXEL_GET, data);
/* Write into log */
- struct Img_Iface_Data_Pixel_Value *data_cast;
- data_cast = (struct Img_Iface_Data_Pixel_Value *)data;
+ data_cast = (struct Img_Iface_Data_Pixel_Get *)data;
snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
- "Pixel value: (%i, %i): %i",
+ "Pixel get: (%i, %i): %i",
data_cast->x,
data_cast->y,
*(data_cast->val));
@@ -680,14 +685,67 @@ static void img_iface_pixel_value (void *data)
(user_iface_log.len)++;
}
+static void img_iface_pixel_set (void *data)
+{
+ struct Img_Iface_Data_Pixel_Set data_tmp;
+ struct Img_Iface_Data_Pixel_Set *data_cast;
+ char title [80];
+
+ /* 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 */
+ if (!data) {
+ /* Ask user */
+ snprintf(title, 80, "x:");
+ data_tmp.x = user_iface_getint(0, 0,
+ image_copy_tmp.cols,
+ title, NULL);
+
+ snprintf(title, 80, "y:");
+ data_tmp.y = user_iface_getint(0, 0,
+ image_copy_tmp.rows,
+ title, NULL);
+
+ snprintf(title, 80, "val:");
+ data_tmp.val = user_iface_getint(0, 0, 255,
+ title, NULL);
+
+ data = (void *)&data_tmp;
+ }
+
+ /* Set pixel value */
+ img_cv_act(&image_copy_tmp, IMG_CV_ACT_PIXEL_SET, data);
+
+ /* Write into log */
+ data_cast = (struct Img_Iface_Data_Pixel_Set *)data;
+ snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
+ "Pixel get: (%i, %i): %i",
+ data_cast->x,
+ data_cast->y,
+ data_cast->val);
+ user_iface_log.lvl[user_iface_log.len] = 1;
+ (user_iface_log.len)++;
+}
+
/* ----- ------- ROI */
static void img_iface_set_ROI (void *data)
{
- /* Data */
struct Img_Iface_Data_SetROI data_tmp;
+ struct Img_Iface_Data_SetROI *data_cast;
+ char title [80];
+
+ /* Data */
if (!data) {
/* Ask user */
- char title [80];
snprintf(title, 80, "Origin: x:");
data_tmp.rect.x = user_iface_getint(0, 0,
image_copy_tmp.cols,
@@ -714,7 +772,6 @@ static void img_iface_set_ROI (void *data)
}
/* Write into log */
- struct Img_Iface_Data_SetROI *data_cast;
data_cast = (struct Img_Iface_Data_SetROI *)data;
snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
"ROI: (%i,%i) w=%i,h=%i",
@@ -731,8 +788,10 @@ static void img_iface_set_ROI (void *data)
static void img_iface_set_ROI_2rect (void *data)
{
- /* Data */
struct Img_Iface_Data_SetROI data_tmp;
+ struct Img_Iface_Data_SetROI *data_cast;
+
+ /* Data */
if (!data) {
data_tmp.rect.x = rectangle.x;
data_tmp.rect.y = rectangle.y;
@@ -743,7 +802,6 @@ static void img_iface_set_ROI_2rect (void *data)
}
/* Write into log */
- struct Img_Iface_Data_SetROI *data_cast;
data_cast = (struct Img_Iface_Data_SetROI *)data;
snprintf(user_iface_log.line[user_iface_log.len], LOG_LINE_LEN,
"ROI: (%i,%i) w=%i,h=%i",
diff --git a/modules/proc/inc/proc_common.hpp b/modules/proc/inc/proc_common.hpp
index f31acde..85d5eb3 100644
--- a/modules/proc/inc/proc_common.hpp
+++ b/modules/proc/inc/proc_common.hpp
@@ -34,66 +34,64 @@ extern "C" {
/******************************************************************************
******* functions ************************************************************
******************************************************************************/
- void proc_apply (void);
- void proc_save_mem (int n);
- void proc_load_mem (int n);
- void proc_save_ref (void);
- void proc_save_file (void);
- void proc_save_update (void);
-
- void proc_local_max (void);
- void proc_skeleton (void);
- void proc_lines_vertical (void);
- void proc_median_horizontal (void);
- void proc_median_vertical (void);
-
- void proc_pixel_value (int x, int y, unsigned char *val);
- void proc_ROI (int x, int y, int w, int h);
- void proc_and_2ref (void);
- void proc_not (void);
- void proc_or_2ref (void);
- void proc_cmp (int cmp);
- void proc_dilate (int size);
- void proc_erode (int size);
- void proc_dilate_erode (int size);
- void proc_erode_dilate (int size);
- void proc_smooth (int method, int ksize);
- void proc_border (int size);
- void proc_rotate (
- double center_x,
- double center_y,
- double angle);
- void proc_adaptive_threshold (int method, int type, int ksize);
- void proc_cvt_color (int method);
- void proc_distance_transform (void);
- void proc_threshold (int type, int ksize);
- void proc_contours (
- std::vector <std::vector <class cv::Point_ <int>>> *contours,
- class cv::Mat *hierarchy);
- void proc_contours_size (
- std::vector <std::vector <class cv::Point_ <int>>> *contours,
- double *area,
- double *perimeter);
- void proc_bounding_rect (
- std::vector <class cv::Point_ <int>> *contour,
- class cv::Rect_ <int> *rect,
- bool show);
- void proc_fit_ellipse (
- std::vector <class cv::Point_ <int>> *contour,
- class cv::RotatedRect *rect,
- bool show);
- void proc_min_area_rect (
- std::vector <class cv::Point_ <int>> *contour,
- class cv::RotatedRect *rect,
- bool show);
-
- void proc_OCR (int lang, int conf);
- void proc_zbar (int type);
-
- void proc_show_img (void);
-
- void clock_start (void);
- void clock_stop (const char *txt);
+void proc_apply (void);
+void proc_save_mem (int n);
+void proc_load_mem (int n);
+void proc_save_ref (void);
+void proc_save_file (void);
+void proc_save_update (void);
+
+void proc_local_max (void);
+void proc_skeleton (void);
+void proc_lines_vertical (void);
+void proc_median_horizontal (void);
+void proc_median_vertical (void);
+
+void proc_pixel_get (int x, int y, unsigned char *val);
+void proc_pixel_set (int x, int y, unsigned char val);
+void proc_ROI (int x, int y, int w, int h);
+void proc_and_2ref (void);
+void proc_not (void);
+void proc_or_2ref (void);
+void proc_cmp (int cmp);
+void proc_dilate (int size);
+void proc_erode (int size);
+void proc_dilate_erode (int size);
+void proc_erode_dilate (int size);
+void proc_smooth (int method, int ksize);
+void proc_border (int size);
+void proc_rotate (double center_x, double center_y, double angle);
+void proc_adaptive_threshold (int method, int type, int ksize);
+void proc_cvt_color (int method);
+void proc_distance_transform (void);
+void proc_threshold (int type, int ksize);
+void proc_contours (
+ std::vector <std::vector <class cv::Point_ <int>>> *contours,
+ class cv::Mat *hierarchy);
+void proc_contours_size (
+ std::vector <std::vector <class cv::Point_ <int>>> *contours,
+ double *area,
+ double *perimeter);
+void proc_bounding_rect (
+ std::vector <class cv::Point_ <int>> *contour,
+ class cv::Rect_ <int> *rect,
+ bool show);
+void proc_fit_ellipse (
+ std::vector <class cv::Point_ <int>> *contour,
+ class cv::RotatedRect *rect,
+ bool show);
+void proc_min_area_rect (
+ std::vector <class cv::Point_ <int>> *contour,
+ class cv::RotatedRect *rect,
+ bool show);
+
+void proc_OCR (int lang, int conf);
+void proc_zbar (int type);
+
+void proc_show_img (void);
+
+void clock_start (void);
+void clock_stop (const char *txt);
/******************************************************************************
diff --git a/modules/proc/src/proc_coins.cpp b/modules/proc/src/proc_coins.cpp
index 1b9316e..71bbac2 100644
--- a/modules/proc/src/proc_coins.cpp
+++ b/modules/proc/src/proc_coins.cpp
@@ -257,7 +257,7 @@ static void coins_diameters_pix (void)
/* Get coins diameters in pixels */
for (i = 0; i < coins_n; i++) {
- proc_pixel_value(coins[i].x, coins[i].y,
+ proc_pixel_get(coins[i].x, coins[i].y,
&(coins[i].diameter_pix));
coins[i].diameter_pix *= 2;
}
diff --git a/modules/proc/src/proc_common.cpp b/modules/proc/src/proc_common.cpp
index 2fc2c35..86c137a 100644
--- a/modules/proc/src/proc_common.cpp
+++ b/modules/proc/src/proc_common.cpp
@@ -117,13 +117,22 @@ void proc_median_vertical (void)
proc_show_img();
}
-void proc_pixel_value (int x, int y, unsigned char *val)
+void proc_pixel_get (int x, int y, unsigned char *val)
{
- struct Img_Iface_Data_Pixel_Value data;
+ struct Img_Iface_Data_Pixel_Get data;
data.x = x;
data.y = y;
data.val = val;
- img_iface_act(IMG_IFACE_ACT_PIXEL_VALUE, (void *)&data);
+ img_iface_act(IMG_IFACE_ACT_PIXEL_GET, (void *)&data);
+}
+
+void proc_pixel_set (int x, int y, unsigned char val)
+{
+ struct Img_Iface_Data_Pixel_Set data;
+ data.x = x;
+ data.y = y;
+ data.val = val;
+ img_iface_act(IMG_IFACE_ACT_PIXEL_SET, (void *)&data);
}
void proc_ROI (int x, int y, int w, int h)
diff --git a/modules/proc/src/proc_objects.cpp b/modules/proc/src/proc_objects.cpp
index 9b39ce5..5c30a52 100644
--- a/modules/proc/src/proc_objects.cpp
+++ b/modules/proc/src/proc_objects.cpp
@@ -446,7 +446,7 @@ static void pattern_squares_len_get (void)
/* Get pattern square side lenght in pixels */
for (i = 0; i < squares_n; i++) {
- proc_pixel_value(pattern.square[i].pos.x_pix,
+ proc_pixel_get(pattern.square[i].pos.x_pix,
pattern.square[i].pos.y_pix,
&(pattern.square[i].len));
pattern.square[i].len *= 2;
diff --git a/modules/proc/src/proc_resistor.cpp b/modules/proc/src/proc_resistor.cpp
index 18d922c..cdac617 100644
--- a/modules/proc/src/proc_resistor.cpp
+++ b/modules/proc/src/proc_resistor.cpp
@@ -367,14 +367,14 @@ static void resistor_bkgd (void)
proc_cmp(IMG_IFACE_CMP_HUE);
proc_median_vertical();
proc_median_horizontal();
- proc_pixel_value(0, 0, &bkgd_hue);
+ proc_pixel_get(0, 0, &bkgd_hue);
/* saturation */
proc_load_mem(4);
proc_cmp(IMG_IFACE_CMP_SATURATION);
proc_median_vertical();
proc_median_horizontal();
- proc_pixel_value(0, 0, &bkgd_sat);
+ proc_pixel_get(0, 0, &bkgd_sat);
if (bkgd_hue < 50) {
/* Beige */
@@ -605,49 +605,49 @@ static void bands_colors (void)
/* Hue */
proc_load_mem(9);
if (bands_n == 5) {
- proc_pixel_value(bands[0].x, bands[0].y, &(bands[0].h));
+ proc_pixel_get(bands[0].x, bands[0].y, &(bands[0].h));
}
if (bands_n >= 3) {
- proc_pixel_value(bands[1].x, bands[1].y, &(bands[1].h));
+ proc_pixel_get(bands[1].x, bands[1].y, &(bands[1].h));
}
- proc_pixel_value(bands[2].x, bands[2].y, &(bands[2].h));
+ proc_pixel_get(bands[2].x, bands[2].y, &(bands[2].h));
if (bands_n >= 3) {
- proc_pixel_value(bands[3].x, bands[3].y, &(bands[3].h));
+ proc_pixel_get(bands[3].x, bands[3].y, &(bands[3].h));
}
if (bands_n > 3) {
- proc_pixel_value(bands[4].x, bands[4].y, &(bands[4].h));
+ proc_pixel_get(bands[4].x, bands[4].y, &(bands[4].h));
}
/* Saturation */
proc_load_mem(10);
if (bands_n == 5) {
- proc_pixel_value(bands[0].x, bands[0].y, &(bands[0].s));
+ proc_pixel_get(bands[0].x, bands[0].y, &(bands[0].s));
}
if (bands_n >= 3) {
- proc_pixel_value(bands[1].x, bands[1].y, &(bands[1].s));
+ proc_pixel_get(bands[1].x, bands[1].y, &(bands[1].s));
}
- proc_pixel_value(bands[2].x, bands[2].y, &(bands[2].s));
+ proc_pixel_get(bands[2].x, bands[2].y, &(bands[2].s));
if (bands_n >= 3) {
- proc_pixel_value(bands[3].x, bands[3].y, &(bands[3].s));
+ proc_pixel_get(bands[3].x, bands[3].y, &(bands[3].s));
}
if (bands_n > 3) {
- proc_pixel_value(bands[4].x, bands[4].y, &(bands[4].s));
+ proc_pixel_get(bands[4].x, bands[4].y, &(bands[4].s));
}
/* Value */
proc_load_mem(11);
if (bands_n == 5) {
- proc_pixel_value(bands[0].x, bands[0].y, &(bands[0].v));
+ proc_pixel_get(bands[0].x, bands[0].y, &(bands[0].v));
}
if (bands_n >= 3) {
- proc_pixel_value(bands[1].x, bands[1].y, &(bands[1].v));
+ proc_pixel_get(bands[1].x, bands[1].y, &(bands[1].v));
}
- proc_pixel_value(bands[2].x, bands[2].y, &(bands[2].v));
+ proc_pixel_get(bands[2].x, bands[2].y, &(bands[2].v));
if (bands_n >= 3) {
- proc_pixel_value(bands[3].x, bands[3].y, &(bands[3].v));
+ proc_pixel_get(bands[3].x, bands[3].y, &(bands[3].v));
}
if (bands_n > 3) {
- proc_pixel_value(bands[4].x, bands[4].y, &(bands[4].v));
+ proc_pixel_get(bands[4].x, bands[4].y, &(bands[4].v));
}
}
diff --git a/modules/user/inc/user_iface.h b/modules/user/inc/user_iface.h
index d69978e..f4511be 100644
--- a/modules/user/inc/user_iface.h
+++ b/modules/user/inc/user_iface.h
@@ -48,7 +48,8 @@
USER_IFACE_ACT_MEDIAN_VERTICAL,
USER_IFACE_ACT_CV = 0x000100u,
- USER_IFACE_ACT_PIXEL_VALUE,
+ USER_IFACE_ACT_PIXEL_GET,
+ USER_IFACE_ACT_PIXEL_SET,
USER_IFACE_ACT_SET_ROI,
USER_IFACE_ACT_SET_ROI_2RECT,
USER_IFACE_ACT_AND_2REF,
diff --git a/modules/user/inc/user_iface.hpp b/modules/user/inc/user_iface.hpp
index bb805f7..c127d93 100644
--- a/modules/user/inc/user_iface.hpp
+++ b/modules/user/inc/user_iface.hpp
@@ -48,7 +48,8 @@
USER_IFACE_ACT_MEDIAN_VERTICAL,
USER_IFACE_ACT_CV = 0x000100u,
- USER_IFACE_ACT_PIXEL_VALUE,
+ USER_IFACE_ACT_PIXEL_GET,
+ USER_IFACE_ACT_PIXEL_SET,
USER_IFACE_ACT_SET_ROI,
USER_IFACE_ACT_SET_ROI_2RECT,
USER_IFACE_ACT_AND_2REF,
diff --git a/modules/user/src/user_clui.c b/modules/user/src/user_clui.c
index ff49e56..9a4405a 100644
--- a/modules/user/src/user_clui.c
+++ b/modules/user/src/user_clui.c
@@ -263,7 +263,10 @@ static int usr_input (void)
/* Pixel */
switch (ch[4]) {
case '0':
- action = USER_IFACE_ACT_PIXEL_VALUE;
+ action = USER_IFACE_ACT_PIXEL_GET;
+ break;
+ case '1':
+ action = USER_IFACE_ACT_PIXEL_SET;
break;
default:
action = USER_IFACE_ACT_FOO;
@@ -566,7 +569,8 @@ static void show_help (void)
printf(" - Vertical mean: %s\n", "f021");
printf(" - Horizontal median: %s\n", "f022");
printf(" - Vertical median: %s\n", "f023");
- printf(" - Pixel value: %s\n", "f1000");
+ printf(" - Pixel get: %s\n", "f1000");
+ printf(" - Pixel set: %s\n", "f1001");
printf(" - Set ROI: %s\n", "f1010");
printf(" - Set ROI 2rect: %s\n", "f1011");
printf(" - Bitwise AND 2ref: %s\n", "f1020");
diff --git a/modules/user/src/user_tui.c b/modules/user/src/user_tui.c
index 7049255..305e1d2 100644
--- a/modules/user/src/user_tui.c
+++ b/modules/user/src/user_tui.c
@@ -366,7 +366,10 @@ static int usr_input (void)
switch (ch) {
case '0':
- action = USER_IFACE_ACT_PIXEL_VALUE;
+ action = USER_IFACE_ACT_PIXEL_GET;
+ break;
+ case '1':
+ action = USER_IFACE_ACT_PIXEL_SET;
break;
default:
action = USER_IFACE_ACT_FOO;
@@ -712,7 +715,8 @@ static void show_help (void)
mvwprintw(win_help, r++, c, " - Vertical mean: %s", "f021");
mvwprintw(win_help, r++, c, " - Horizontal median: %s", "f022");
mvwprintw(win_help, r++, c, " - Vertical median: %s", "f023");
- mvwprintw(win_help, r++, c, " - Pixel value: %s", "f1000");
+ mvwprintw(win_help, r++, c, " - Pixel get: %s", "f1000");
+ mvwprintw(win_help, r++, c, " - Pixel set: %s", "f1001");
mvwprintw(win_help, r++, c, " - Set ROI: %s", "f1010");
mvwprintw(win_help, r++, c, " - Set ROI 2rect: %s", "f1011");
mvwprintw(win_help, r++, c, " - Bitwise AND 2ref: %s", "f1020");
diff --git a/tmp/Makefile b/tmp/Makefile
index 4755930..553d349 100644
--- a/tmp/Makefile
+++ b/tmp/Makefile
@@ -58,17 +58,16 @@ PHONY := all
all: $(ALL)
main.s: $(MAIN_DEPS)
+ @echo " CXX $@"
$(Q)$(CXX) $(CXXFLAGS) $(MAIN_INC_DIRS) -S $< -o $@
- @echo " CXX $@"
main.o: main.s
+ @echo " AS $@"
$(Q)$(AS) $< -o $@
- @echo " AS $@"
- @echo ""
PHONY += clean
clean:
- @echo " RM *.o *.s"
+ @echo " RM *.o *.s"
$(Q)rm -f *.o *.s
################################################################################