summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralejandro-colomar <colomar.6.4.3@gmail.com>2019-08-16 15:23:49 +0200
committeralejandro-colomar <colomar.6.4.3@gmail.com>2019-08-16 15:23:49 +0200
commitc813aea5d823869bf15ba3aad841de1ed478022e (patch)
treeb52abcdfb30595e02607bd6b98335d6c17abd013
parent1f7a75ee5e06ff91e270d8ccce48d8aa69a5ae70 (diff)
Use libalx cv features2d
-rw-r--r--bin/Makefile1
-rw-r--r--inc/vision-artificial/image/orb.hpp71
-rw-r--r--src/image/iface.cpp4
-rw-r--r--src/image/orb.cpp139
-rw-r--r--tmp/image/Makefile11
5 files changed, 3 insertions, 223 deletions
diff --git a/bin/Makefile b/bin/Makefile
index eccf924..9b09e7f 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -8,7 +8,6 @@ OBJS = \
$(TMP_DIR)/image/calib3d.o \
$(TMP_DIR)/image/cv.o \
$(TMP_DIR)/image/iface.o \
- $(TMP_DIR)/image/orb.o \
$(TMP_DIR)/menu/iface.o \
$(TMP_DIR)/menu/parse.o \
$(TMP_DIR)/menu/tui.o \
diff --git a/inc/vision-artificial/image/orb.hpp b/inc/vision-artificial/image/orb.hpp
deleted file mode 100644
index 932c1ab..0000000
--- a/inc/vision-artificial/image/orb.hpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2018 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#ifndef VA_IMAGE_ORB_HPP
-#define VA_IMAGE_ORB_HPP
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-#include <opencv2/core/core.hpp>
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
-enum Img_ORB_Action {
- IMG_ORB_ACT_FOO = 0x000000u,
-
- IMG_ORB_ACT_ORB = 0x000200u,
- IMG_ORB_ACT_ALIGN
-};
-
-
-/******************************************************************************
- ******* structs / unions *****************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* extern functions *****************************************************
- ******************************************************************************/
-void img_orb_act (const class cv::Mat *img_ref,
- class cv::Mat *imgptr, int action);
-
-
-/******************************************************************************
- ******* static inline functions (prototypes) *********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* static inline functions (definitions) ********************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-#endif /* vision-artificial/image/orb.hpp */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/src/image/iface.cpp b/src/image/iface.cpp
index 1ddbb35..10cae4d 100644
--- a/src/image/iface.cpp
+++ b/src/image/iface.cpp
@@ -25,6 +25,7 @@
#include "libalx/base/stdio/printf/sbprintf.hpp"
#include "libalx/extra/cv/alx.hpp"
#include "libalx/extra/cv/core.hpp"
+#include "libalx/extra/cv/features2d.hpp"
#include "libalx/extra/cv/imgproc.hpp"
#include "libalx/extra/cv/ximgproc.hpp"
#include "libalx/extra/ocr/ocr.hpp"
@@ -32,7 +33,6 @@
#include "vision-artificial/image/calib3d.hpp"
#include "vision-artificial/image/cv.hpp"
-#include "vision-artificial/image/orb.hpp"
#include "vision-artificial/save/save.hpp"
#include "vision-artificial/user/iface.hpp"
@@ -1086,7 +1086,7 @@ static void img_iface_align (void)
if (image_ref.empty())
goto err;
- img_orb_act(&image_ref, &image_copy_tmp, IMG_ORB_ACT_ALIGN);
+ alx::CV::orb_align(&image_ref, &image_copy_tmp, NULL);
user_iface_log_write(1, "Align to reference");
return;
diff --git a/src/image/orb.cpp b/src/image/orb.cpp
deleted file mode 100644
index 905cd62..0000000
--- a/src/image/orb.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2018 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-#include "vision-artificial/image/orb.hpp"
-
-#include <cstddef>
-#include <cstdio>
-
-#include <vector>
-
-#include <opencv2/calib3d/calib3d.hpp>
-#include <opencv2/core/core.hpp>
-#include <opencv2/features2d/features2d.hpp>
-#include <opencv2/highgui/highgui.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
-#define MAX_FEATURES (50000)
-#define GOOD_MATCH_P (0.25)
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* structs / unions *****************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* static functions (prototypes) ****************************************
- ******************************************************************************/
-static void img_orb_align (const class cv::Mat *img_0,
- class cv::Mat *img_1);
-
-
-/******************************************************************************
- ******* global functions *****************************************************
- ******************************************************************************/
-void img_orb_act (const class cv::Mat *img_ref,
- class cv::Mat *imgptr, int action)
-{
- switch (action) {
- case IMG_ORB_ACT_ALIGN:
- img_orb_align(img_ref, imgptr);
- break;
- }
-}
-
-
-/******************************************************************************
- ******* static functions (definitions) ***************************************
- ******************************************************************************/
-static void img_orb_align (const class cv::Mat *img_0,
- class cv::Mat *img_1)
-{
- class std::vector <class cv::KeyPoint> keypoints_0;
- class std::vector <class cv::KeyPoint> keypoints_1;
- class cv::Mat descriptors_0;
- class cv::Mat descriptors_1;
-#if (CV_VERSION_EPOCH == 2)
- class cv::ORB orb;
-#elif (CV_VERSION_EPOCH == 3)
- class cv::Ptr <class cv::Feature2D> orb;
-#endif
- class std::vector <struct cv::DMatch> matches;
- class cv::Ptr <class cv::DescriptorMatcher> matcher;
- ptrdiff_t good_matches;
- class cv::Mat img_matches;
- class std::vector <class cv::Point_ <float>> points_0;
- class std::vector <class cv::Point_ <float>> points_1;
- ptrdiff_t size;
- class cv::Mat img_hg;
- class cv::Mat img_align;
-
- /* Detect ORB features & compute descriptors */
-#if (CV_VERSION_EPOCH == 2)
- orb(*img_0, cv::Mat(), keypoints_0, descriptors_0);
- orb(*img_1, cv::Mat(), keypoints_1, descriptors_1);
-#elif (CV_VERSION_EPOCH == 3)
- orb = cv::ORB::create(MAX_FEATURES);
- orb->detectAndCompute(*img_0, cv::Mat(), keypoints_0, descriptors_0);
- orb->detectAndCompute(*img_1, cv::Mat(), keypoints_1, descriptors_1);
-#endif
-
- /* Match structures */
- matcher = cv::DescriptorMatcher::create("BruteForce-Hamming");
- matcher->match(descriptors_1, descriptors_0, matches, cv::Mat());
-
- /* Sort matches by score */
- std::sort(matches.begin(), matches.end());
-
- /* Remove not so good matches */
- good_matches = GOOD_MATCH_P * matches.size();
- matches.erase(matches.begin() + good_matches, matches.end());
-
- /* Draw top matches */
- cv::drawMatches(*img_1, keypoints_1, *img_0, keypoints_0, matches,
- img_matches);
- cv::imwrite("matches.jpg", img_matches);
-
- /* Extract location of good matches */
- size = matches.size();
- for (ptrdiff_t i = 0; i < size; i++) {
- points_1.push_back(keypoints_1[matches[i].queryIdx].pt);
- points_0.push_back(keypoints_0[matches[i].trainIdx].pt);
- }
-
- /* Find homography */
- img_hg = cv::findHomography(points_1, points_0, CV_RANSAC);
-
- /* Use homography to warp image */
- cv::warpPerspective(*img_1, img_align, img_hg, img_0->size());
-
- /* Write img_align into img_1 */
- *img_1 = img_align;
- img_align.release();
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/tmp/image/Makefile b/tmp/image/Makefile
index 364d95c..00cf3cb 100644
--- a/tmp/image/Makefile
+++ b/tmp/image/Makefile
@@ -15,8 +15,7 @@
OBJ = \
calib3d.o \
cv.o \
- iface.o \
- orb.o
+ iface.o
CALIB3D_INC = \
$(INC_DIR)/vision-artificial/image/calib3d.hpp \
@@ -34,7 +33,6 @@ IFACE_INC = \
$(INC_DIR)/vision-artificial/image/iface.hpp \
$(INC_DIR)/vision-artificial/image/calib3d.hpp \
$(INC_DIR)/vision-artificial/image/cv.hpp \
- $(INC_DIR)/vision-artificial/image/orb.hpp \
$(INC_DIR)/vision-artificial/save/save.hpp \
$(INC_DIR)/vision-artificial/user/iface.hpp
IFACE_SRC = \
@@ -74,13 +72,6 @@ iface.o: iface.s
@echo " AS vision-artificial/image/$@"
$(Q)$(AS) $< -o $@
-orb.s: $(ORB_SRC) $(ORB_INC)
- @echo " CXX vision-artificial/image/$@"
- $(Q)$(CXX) $(CXXFLAGS) -I $(INC_DIR) -S $< -o $@
-orb.o: orb.s
- @echo " AS vision-artificial/image/$@"
- $(Q)$(AS) $< -o $@
-
PHONY += clean
clean: