From 78384d89230edad0460e960d624b0ae31abc1388 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Mon, 15 Apr 2019 18:59:51 +0000 Subject: [PATCH] build: avoid highgui dependency --- modules/calib3d/CMakeLists.txt | 6 +++++- modules/calib3d/src/calibinit.cpp | 1 + modules/calib3d/src/circlesgrid.cpp | 2 ++ modules/features2d/CMakeLists.txt | 6 +++++- modules/features2d/src/blobdetector.cpp | 28 +++++++++++-------------- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/modules/calib3d/CMakeLists.txt b/modules/calib3d/CMakeLists.txt index b79944da59..cba3f811b5 100644 --- a/modules/calib3d/CMakeLists.txt +++ b/modules/calib3d/CMakeLists.txt @@ -1,2 +1,6 @@ set(the_description "Camera Calibration and 3D Reconstruction") -ocv_define_module(calib3d opencv_imgproc opencv_features2d WRAP java python) +set(debug_modules "") +if(DEBUG_opencv_calib3d) + list(APPEND debug_modules opencv_highgui) +endif() +ocv_define_module(calib3d opencv_imgproc opencv_features2d ${debug_modules} WRAP java python) diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index ade9c71ebb..863f480b4b 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -76,6 +76,7 @@ //#define ENABLE_TRIM_COL_ROW +// Requires CMake flag: DEBUG_opencv_calib3d=ON //#define DEBUG_CHESSBOARD #define DEBUG_CHESSBOARD_TIMEOUT 0 // 0 - wait for 'q' diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index e19a719c8d..d86d22b205 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -43,6 +43,8 @@ #include "precomp.hpp" #include "circlesgrid.hpp" #include + + // Requires CMake flag: DEBUG_opencv_calib3d=ON //#define DEBUG_CIRCLES #ifdef DEBUG_CIRCLES diff --git a/modules/features2d/CMakeLists.txt b/modules/features2d/CMakeLists.txt index f18f69edb3..e92309db0f 100644 --- a/modules/features2d/CMakeLists.txt +++ b/modules/features2d/CMakeLists.txt @@ -1,2 +1,6 @@ set(the_description "2D Features Framework") -ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python js) +set(debug_modules "") +if(DEBUG_opencv_features2d) + list(APPEND debug_modules opencv_highgui) +endif() +ocv_define_module(features2d opencv_imgproc ${debug_modules} OPTIONAL opencv_flann WRAP java python js) diff --git a/modules/features2d/src/blobdetector.cpp b/modules/features2d/src/blobdetector.cpp index f1e8b63799..403a8974cc 100644 --- a/modules/features2d/src/blobdetector.cpp +++ b/modules/features2d/src/blobdetector.cpp @@ -44,15 +44,11 @@ #include #include +// Requires CMake flag: DEBUG_opencv_features2d=ON //#define DEBUG_BLOB_DETECTOR #ifdef DEBUG_BLOB_DETECTOR -# include "opencv2/opencv_modules.hpp" -# ifdef HAVE_OPENCV_HIGHGUI -# include "opencv2/highgui.hpp" -# else -# undef DEBUG_BLOB_DETECTOR -# endif +#include "opencv2/highgui.hpp" #endif namespace cv @@ -200,13 +196,13 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag findContours(binaryImage, contours, RETR_LIST, CHAIN_APPROX_NONE); #ifdef DEBUG_BLOB_DETECTOR - // Mat keypointsImage; - // cvtColor( binaryImage, keypointsImage, CV_GRAY2RGB ); - // - // Mat contoursImage; - // cvtColor( binaryImage, contoursImage, CV_GRAY2RGB ); - // drawContours( contoursImage, contours, -1, Scalar(0,255,0) ); - // imshow("contours", contoursImage ); + Mat keypointsImage; + cvtColor(binaryImage, keypointsImage, COLOR_GRAY2RGB); + + Mat contoursImage; + cvtColor(binaryImage, contoursImage, COLOR_GRAY2RGB); + drawContours( contoursImage, contours, -1, Scalar(0,255,0) ); + imshow("contours", contoursImage ); #endif for (size_t contourIdx = 0; contourIdx < contours.size(); contourIdx++) @@ -296,12 +292,12 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag #ifdef DEBUG_BLOB_DETECTOR - // circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 ); + circle( keypointsImage, center.location, 1, Scalar(0,0,255), 1 ); #endif } #ifdef DEBUG_BLOB_DETECTOR - // imshow("bk", keypointsImage ); - // waitKey(); + imshow("bk", keypointsImage ); + waitKey(); #endif }