Commit 25e39c69 authored by Alfonso Sanchez-Beato's avatar Alfonso Sanchez-Beato

fix compilation problems seen in #11

parent d71d1722
...@@ -4,6 +4,7 @@ find_package(OpenCV REQUIRED) ...@@ -4,6 +4,7 @@ find_package(OpenCV REQUIRED)
set(SOURCES map_test.cpp) set(SOURCES map_test.cpp)
add_definitions(-DCOMPARE_FEATURES)
include_directories(${OpenCV_INCLUDE_DIRS}) include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(map_test ${SOURCES} ${HEADERS}) add_executable(map_test ${SOURCES} ${HEADERS})
target_link_libraries(map_test ${OpenCV_LIBS}) target_link_libraries(map_test ${OpenCV_LIBS})
...@@ -38,14 +38,17 @@ ...@@ -38,14 +38,17 @@
#include <iostream> #include <iostream>
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
#include <cmath> #include <cmath>
#include <opencv/cv.h> #include <opencv2/highgui.hpp> // OpenCV window I/O
#include <opencv/highgui.h> #include <opencv2/imgproc.hpp> // OpenCV image transformations
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O #include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp> // OpenCV image transformations #include <opencv2/imgproc/types_c.h>
#include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui_c.h>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/calib3d/calib3d.hpp> #ifdef COMPARE_FEATURES
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/nonfree.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/calib3d/calib3d_c.h>
#endif
#include "opencv2/reg/mapaffine.hpp" #include "opencv2/reg/mapaffine.hpp"
#include "opencv2/reg/mapshift.hpp" #include "opencv2/reg/mapshift.hpp"
...@@ -64,8 +67,7 @@ using namespace cv; ...@@ -64,8 +67,7 @@ using namespace cv;
using namespace cv::reg; using namespace cv::reg;
using namespace std; using namespace std;
static void showDifference(const Mat& image1, const Mat& image2, const char* title)
void showDifference(const Mat& image1, const Mat& image2, const char* title)
{ {
Mat img1, img2; Mat img1, img2;
image1.convertTo(img1, CV_32FC3); image1.convertTo(img1, CV_32FC3);
...@@ -86,7 +88,7 @@ void showDifference(const Mat& image1, const Mat& image2, const char* title) ...@@ -86,7 +88,7 @@ void showDifference(const Mat& image1, const Mat& image2, const char* title)
imshow(title, imgSh); imshow(title, imgSh);
} }
void testShift(const Mat& img1) static void testShift(const Mat& img1)
{ {
Mat img2; Mat img2;
...@@ -118,7 +120,7 @@ void testShift(const Mat& img1) ...@@ -118,7 +120,7 @@ void testShift(const Mat& img1)
cvDestroyWindow(DIFF_REGPIX_IM); cvDestroyWindow(DIFF_REGPIX_IM);
} }
void testEuclidean(const Mat& img1) static void testEuclidean(const Mat& img1)
{ {
Mat img2; Mat img2;
...@@ -156,7 +158,7 @@ void testEuclidean(const Mat& img1) ...@@ -156,7 +158,7 @@ void testEuclidean(const Mat& img1)
cvDestroyWindow(DIFF_REGPIX_IM); cvDestroyWindow(DIFF_REGPIX_IM);
} }
void testSimilarity(const Mat& img1) static void testSimilarity(const Mat& img1)
{ {
Mat img2; Mat img2;
...@@ -195,7 +197,7 @@ void testSimilarity(const Mat& img1) ...@@ -195,7 +197,7 @@ void testSimilarity(const Mat& img1)
cvDestroyWindow(DIFF_REGPIX_IM); cvDestroyWindow(DIFF_REGPIX_IM);
} }
void testAffine(const Mat& img1) static void testAffine(const Mat& img1)
{ {
Mat img2; Mat img2;
...@@ -230,7 +232,7 @@ void testAffine(const Mat& img1) ...@@ -230,7 +232,7 @@ void testAffine(const Mat& img1)
cvDestroyWindow(DIFF_REGPIX_IM); cvDestroyWindow(DIFF_REGPIX_IM);
} }
void testProjective(const Mat& img1) static void testProjective(const Mat& img1)
{ {
Mat img2; Mat img2;
...@@ -263,11 +265,12 @@ void testProjective(const Mat& img1) ...@@ -263,11 +265,12 @@ void testProjective(const Mat& img1)
cvDestroyWindow(DIFF_REGPIX_IM); cvDestroyWindow(DIFF_REGPIX_IM);
} }
#ifdef COMPARE_FEATURES
// //
// Following an example from // Following an example from
// http:// ramsrigoutham.com/2012/11/22/panorama-image-stitching-in-opencv/ // http:// ramsrigoutham.com/2012/11/22/panorama-image-stitching-in-opencv/
// //
void calcHomographyFeature(const Mat& image1, const Mat& image2) static void calcHomographyFeature(const Mat& image1, const Mat& image2)
{ {
static const char* difffeat = "Difference feature registered"; static const char* difffeat = "Difference feature registered";
...@@ -349,7 +352,7 @@ void calcHomographyFeature(const Mat& image1, const Mat& image2) ...@@ -349,7 +352,7 @@ void calcHomographyFeature(const Mat& image1, const Mat& image2)
showDifference(imf1, resf, difffeat); showDifference(imf1, resf, difffeat);
} }
void calcHomographyPixel(const Mat& img1, const Mat& img2) static void calcHomographyPixel(const Mat& img1, const Mat& img2)
{ {
static const char* diffpixel = "Difference pixel registered"; static const char* diffpixel = "Difference pixel registered";
...@@ -370,7 +373,7 @@ void calcHomographyPixel(const Mat& img1, const Mat& img2) ...@@ -370,7 +373,7 @@ void calcHomographyPixel(const Mat& img1, const Mat& img2)
showDifference(img1, dest, diffpixel); showDifference(img1, dest, diffpixel);
} }
void comparePixelVsFeature(const Mat& img1_8b, const Mat& img2_8b) static void comparePixelVsFeature(const Mat& img1_8b, const Mat& img2_8b)
{ {
static const char* difforig = "Difference non-registered"; static const char* difforig = "Difference non-registered";
...@@ -389,7 +392,7 @@ void comparePixelVsFeature(const Mat& img1_8b, const Mat& img2_8b) ...@@ -389,7 +392,7 @@ void comparePixelVsFeature(const Mat& img1_8b, const Mat& img2_8b)
waitKey(0); waitKey(0);
} }
#endif
int main(void) int main(void)
{ {
...@@ -408,6 +411,7 @@ int main(void) ...@@ -408,6 +411,7 @@ int main(void)
testAffine(img1); testAffine(img1);
testProjective(img1); testProjective(img1);
#ifdef COMPARE_FEATURES
Mat imgcmp1 = imread("LR_05.png", CV_LOAD_IMAGE_UNCHANGED); Mat imgcmp1 = imread("LR_05.png", CV_LOAD_IMAGE_UNCHANGED);
if(!imgcmp1.data) { if(!imgcmp1.data) {
cout << "Could not open or find file" << endl; cout << "Could not open or find file" << endl;
...@@ -420,6 +424,7 @@ int main(void) ...@@ -420,6 +424,7 @@ int main(void)
return -1; return -1;
} }
comparePixelVsFeature(imgcmp1, imgcmp2); comparePixelVsFeature(imgcmp1, imgcmp2);
#endif
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment