summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralejandro-colomar <colomar.6.4.3@gmail.com>2019-06-04 01:36:27 +0200
committeralejandro-colomar <colomar.6.4.3@gmail.com>2019-06-04 01:36:27 +0200
commit5fe0571436248c57d25c866a951c5eabc85da2df (patch)
tree3e45aa67c3de29b4f6a781df55c2842f5809318d
parent471c7f0313eaa28872d72801d7139f776c1e1b91 (diff)
parent4af7e65e16b185420fabd52188c265975e3e26e6 (diff)
Use less to display files
-rw-r--r--Makefile7
m---------libalx0
-rw-r--r--src/about/about.c23
-rw-r--r--src/ctrl/start.c17
-rw-r--r--src/image/alx.cpp21
-rw-r--r--src/proc/coins.cpp2
-rw-r--r--src/save/save.cpp43
-rw-r--r--tmp/save/Makefile1
8 files changed, 52 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index dac6bb8..bb867d1 100644
--- a/Makefile
+++ b/Makefile
@@ -229,7 +229,6 @@ all: bin
PHONY += libalx
libalx:
@echo " MAKE $@"
- $(Q)$(MAKE) errno -C $(LIBALX_DIR)
$(Q)$(MAKE) math -C $(LIBALX_DIR)
$(Q)$(MAKE) stdio -C $(LIBALX_DIR)
$(Q)$(MAKE) stdlib -C $(LIBALX_DIR)
@@ -252,11 +251,11 @@ bin: tmp libalx
PHONY += install
install: uninstall
@echo " Install:"
- @echo " MKDIR $(INSTALL_BIN_DIR)/"
+ @echo " MKDIR $(DESTDIR)/$(INSTALL_BIN_DIR)/"
$(Q)mkdir -p $(DESTDIR)/$(INSTALL_BIN_DIR)/
@echo " CP $(BIN_NAME)"
$(Q)cp -v $(BIN_DIR)/$(BIN_NAME) $(DESTDIR)/$(INSTALL_BIN_DIR)/
- @echo " MKDIR $(INSTALL_SHARE_DIR)/vision-artificial/"
+ @echo " MKDIR $(DESTDIR)/$(INSTALL_SHARE_DIR)/vision-artificial/"
$(Q)mkdir -p $(DESTDIR)/$(INSTALL_SHARE_DIR)/vision-artificial/
@echo " CP -r share/vision-artificial/*"
$(Q)cp -r -v ./share/vision-artificial/* $(DESTDIR)/$(INSTALL_SHARE_DIR)/vision-artificial/
@@ -268,7 +267,7 @@ uninstall:
@echo " Clean old installations:"
@echo " RM bin"
$(Q)rm -f $(DESTDIR)/$(INSTALL_BIN_DIR)/$(BIN_NAME)
- @echo " RM -r $(INSTALL_SHARE_DIR)/vision-artificial/"
+ @echo " RM -r $(DESTDIR)/$(INSTALL_SHARE_DIR)/vision-artificial/"
$(Q)rm -f -r $(DESTDIR)/$(INSTALL_SHARE_DIR)/vision-artificial/
@echo " Done"
@echo
diff --git a/libalx b/libalx
-Subproject 60fdf5f81261b8f1b7f8c342aa866a1f85698b7
+Subproject be176601c4928dceeb952c1f4810389c5e5a530
diff --git a/src/about/about.c b/src/about/about.c
index b9a347d..595f65f 100644
--- a/src/about/about.c
+++ b/src/about/about.c
@@ -50,53 +50,48 @@ char share_path [FILENAME_MAX];
void about_init (void)
{
- if (snprintf(share_path, FILENAME_MAX, "%s/vision-artificial/",
- INSTALL_SHARE_DIR) >= SSIZEOF(share_path)) {
+ if (snprintf(share_path, sizeof(share_path), "%s/vision-artificial/",
+ INSTALL_SHARE_DIR) >= SSIZEOF(share_path)) {
goto err;
}
return;
err:
- printf("Path is too large and has been truncated\n");
+ fprintf(stderr, "Path is too large and has been truncated\n");
exit(EXIT_FAILURE);
}
void print_share_file (int file)
{
- char fname[FILENAME_MAX];
+ char fname [FILENAME_MAX];
char cmd[_POSIX_ARG_MAX];
switch (file) {
case SHARE_COPYRIGHT:
- if (snprintf(fname, sizeof(fname), "%s/%s",
- share_path,
+ if (snprintf(fname, sizeof(fname), "%s/%s", share_path,
"COPYRIGHT.txt") >= SSIZEOF(fname)) {
goto err;
}
break;
case SHARE_DISCLAIMER:
- if (snprintf(fname, sizeof(fname), "%s/%s",
- share_path,
+ if (snprintf(fname, sizeof(fname), "%s/%s", share_path,
"DISCLAIMER.txt") >= SSIZEOF(fname)) {
goto err;
}
break;
case SHARE_HELP:
- if (snprintf(fname, sizeof(fname), "%s/%s",
- share_path,
+ if (snprintf(fname, sizeof(fname), "%s/%s", share_path,
"HELP.txt") >= SSIZEOF(fname)) {
goto err;
}
break;
case SHARE_LICENSE:
- if (snprintf(fname, sizeof(fname), "%s/%s",
- share_path,
+ if (snprintf(fname, sizeof(fname), "%s/%s", share_path,
"LICENSE.txt") >= SSIZEOF(fname)) {
goto err;
}
break;
case SHARE_USAGE:
- if (snprintf(fname, sizeof(fname), "%s/%s",
- share_path,
+ if (snprintf(fname, sizeof(fname), "%s/%s", share_path,
"USAGE.txt") >= SSIZEOF(fname)) {
goto err;
}
diff --git a/src/ctrl/start.c b/src/ctrl/start.c
index 5562503..3b34ce3 100644
--- a/src/ctrl/start.c
+++ b/src/ctrl/start.c
@@ -12,6 +12,7 @@
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
+#include <string.h>
#include "vision-artificial/image/iface.h"
#include "vision-artificial/proc/iface.h"
@@ -43,11 +44,9 @@ void start_switch (void)
case START_FOO:
start_foo();
break;
-
case START_SINGLE:
start_single();
break;
-
case START_SERIES:
start_series();
break;
@@ -69,14 +68,16 @@ static void start_single (void)
errno = 0;
img_iface_load(NULL, saved_name);
- if (!errno) {
- user_iface_init();
- user_iface();
- user_iface_cleanup();
- } else {
- printf("errno:%i\n", errno);
+ if (errno) {
+ fprintf(stderr, "%s[%i]: %s(): %s", __FILE__, __LINE__,
+ __func__, strerror(errno));
+ goto err;
}
+ user_iface_init();
+ user_iface();
+ user_iface_cleanup();
+err:
img_iface_cleanup();
}
diff --git a/src/image/alx.cpp b/src/image/alx.cpp
index 966c746..ce3d450 100644
--- a/src/image/alx.cpp
+++ b/src/image/alx.cpp
@@ -106,9 +106,9 @@ static void img_alx_local_max (class cv::Mat *imgptr)
const ptrdiff_t cols = imgptr->cols;
const ptrdiff_t step = imgptr->step;
/* Minimum distance between local maxima */
- const int dist = 4;
+ const int dist = 2;
/* Minimum value of local maxima */
- const uint8_t val_min = 16;
+ const uint8_t val_min = 1;
class cv::Mat imgtmp;
int arr_tmp[rows][cols];
bool wh;
@@ -129,11 +129,10 @@ static void img_alx_local_max (class cv::Mat *imgptr)
img_pix = imgptr->data + i*step + j;
if (*img_pix < val_min)
continue;
-
- for (ptrdiff_t k = (i + dist + 1); k >= (i - dist - 1); k--) {
- for (ptrdiff_t l = (j + dist + 1); l >= (j - dist - 1); l--) {
- if ((k > 0) && (k < rows)) {
- if ((l > 0) && (l < cols)) {
+ for (ptrdiff_t k = (i + dist); k >= (i - dist); k--) {
+ for (ptrdiff_t l = (j + dist); l >= (j - dist); l--) {
+ if ((k >= 0) && (k < rows)) {
+ if ((l >= 0) && (l < cols)) {
near_pix = imgptr->data + k*step + l;
if (*near_pix > *img_pix)
goto not_maxima;
@@ -158,10 +157,10 @@ not_maxima:
img_pix = imgptr->data + i*step + j;
if (arr_tmp[i][j] != MAYBE_LOCAL_MAX)
continue;
- for (ptrdiff_t k = (i+dist+1); k >= (i-dist-1); k--) {
- for (ptrdiff_t l = (j+dist+1); l >= (j-dist-1); l--) {
- if ((k > 0) && (k < rows)) {
- if ((l > 0) && (l < cols)) {
+ for (ptrdiff_t k = (i+dist); k >= (i-dist); k--) {
+ for (ptrdiff_t l = (j+dist); l >= (j-dist); l--) {
+ if ((k >= 0) && (k < rows)) {
+ if ((l >= 0) && (l < cols)) {
near_pix = imgptr->data + k*step + l;
if (*near_pix == *img_pix) {
if (!arr_tmp[k][l])
diff --git a/src/proc/coins.cpp b/src/proc/coins.cpp
index 4451b2d..78849d5 100644
--- a/src/proc/coins.cpp
+++ b/src/proc/coins.cpp
@@ -176,7 +176,7 @@ static void coins_segmentate (void)
proc_threshold(cv::THRESH_BINARY_INV, IMG_IFACE_THR_OTSU);
proc_distance_transform();
proc_local_max();
- proc_dilate(6);
+ proc_dilate(1);
proc_save_mem(1);
}
diff --git a/src/save/save.cpp b/src/save/save.cpp
index aea9d91..bf2cab4 100644
--- a/src/save/save.cpp
+++ b/src/save/save.cpp
@@ -12,13 +12,13 @@
#include <cerrno>
#include <cstdio>
#include <cstdlib>
+#include <cstring>
#include <sys/stat.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
-#include "libalx/base/errno/errno_str.hpp"
#include "libalx/base/stddef/restrict.hpp"
#include "vision-artificial/user/iface.hpp"
@@ -42,21 +42,21 @@
/******************************************************************************
******* variables ************************************************************
******************************************************************************/
- class cv::Mat image;
- char home_path[FILENAME_MAX];
- char user_prog_path[FILENAME_MAX];
- char saved_path[FILENAME_MAX];
- char labels_path[FILENAME_MAX];
- char labels_fail_path[FILENAME_MAX];
- char lighters_path[FILENAME_MAX];
- char lighters_fail_path[FILENAME_MAX];
- char objects_path[FILENAME_MAX];
- char objects_fail_path[FILENAME_MAX];
- char coins_path[FILENAME_MAX];
- char coins_fail_path[FILENAME_MAX];
- char resistors_path[FILENAME_MAX];
- char resistors_fail_path[FILENAME_MAX];
- char saved_name[FILENAME_MAX];
+class cv::Mat image;
+char home_path[FILENAME_MAX];
+char user_prog_path[FILENAME_MAX];
+char saved_path[FILENAME_MAX];
+char labels_path[FILENAME_MAX];
+char labels_fail_path[FILENAME_MAX];
+char lighters_path[FILENAME_MAX];
+char lighters_fail_path[FILENAME_MAX];
+char objects_path[FILENAME_MAX];
+char objects_fail_path[FILENAME_MAX];
+char coins_path[FILENAME_MAX];
+char coins_fail_path[FILENAME_MAX];
+char resistors_path[FILENAME_MAX];
+char resistors_fail_path[FILENAME_MAX];
+char saved_name[FILENAME_MAX];
/******************************************************************************
@@ -137,13 +137,10 @@ void save_init (void)
saved_name[0] = '\0';
if (mkdir(user_prog_path, 0700)) {
- switch (errno) {
- case EEXIST:
- /* OK */
- break;
- default:
- printf("%s: %s\n", errno_str[errno][0],
- errno_str[errno][1]);
+ if (errno != EEXIST) {
+ fprintf(stderr, "%s[%i]: %s(): %s", __FILE__, __LINE__,
+ __func__, strerror(errno));
+ exit(EXIT_FAILURE);
}
}
diff --git a/tmp/save/Makefile b/tmp/save/Makefile
index 50546a5..7326870 100644
--- a/tmp/save/Makefile
+++ b/tmp/save/Makefile
@@ -17,7 +17,6 @@ OBJ = \
SAVE_INC = \
$(INC_DIR)/vision-artificial/save/save.hpp \
- $(LIBALX_INC_DIR)/libalx/base/errno/errno_str.hpp \
$(LIBALX_INC_DIR)/libalx/base/stddef/restrict.hpp \
$(INC_DIR)/vision-artificial/user/iface.hpp
SAVE_SRC = \