Merge pull request #5514 from asmorkalov:as/nonfree-independent-samples

This commit is contained in:
Alexander Smorkalov 2015-10-15 10:56:23 +00:00
commit bf41e791ff
18 changed files with 305 additions and 114 deletions

View File

@ -68,8 +68,14 @@ endif()
add_subdirectory(c) add_subdirectory(c)
add_subdirectory(cpp) add_subdirectory(cpp)
ocv_check_dependencies(opencv_ocl)
if (OCV_DEPENDENCIES_FOUND)
add_subdirectory(ocl) add_subdirectory(ocl)
endif()
ocv_check_dependencies(opencv_gpu)
if (OCV_DEPENDENCIES_FOUND)
add_subdirectory(gpu) add_subdirectory(gpu)
endif()
# #
# END OF BUILD CASE 2: Build samples with library binaries # END OF BUILD CASE 2: Build samples with library binaries

View File

@ -4,7 +4,7 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib) opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS}) ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
@ -16,7 +16,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif() endif()
ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS}) ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS} opencv_nonfree)
# --------------------------------------------- # ---------------------------------------------
# Define executable targets # Define executable targets

View File

@ -4,6 +4,20 @@
* Author: Liu Liu * Author: Liu Liu
* liuliu.1987+opencv@gmail.com * liuliu.1987+opencv@gmail.com
*/ */
#include "opencv2/opencv_modules.hpp"
#include <stdio.h>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/objdetect/objdetect.hpp" # include "opencv2/objdetect/objdetect.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -13,9 +27,7 @@
# include "opencv2/legacy/legacy.hpp" # include "opencv2/legacy/legacy.hpp"
# include "opencv2/legacy/compat.hpp" # include "opencv2/legacy/compat.hpp"
#include <iostream>
# include <vector> # include <vector>
#include <stdio.h>
using namespace std; using namespace std;
static void help() static void help()
@ -320,3 +332,5 @@ int main(int argc, char** argv)
return 0; return 0;
} }
#endif

View File

@ -1,3 +1,16 @@
#include "opencv2/opencv_modules.hpp"
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/imgproc/imgproc.hpp" # include "opencv2/imgproc/imgproc.hpp"
@ -164,3 +177,5 @@ int main( int argc, char **argv )
return 0; return 0;
} }
#endif

View File

@ -7,6 +7,19 @@
* *
*/ */
#include "opencv2/opencv_modules.hpp"
#include <stdio.h>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/imgproc/imgproc.hpp" # include "opencv2/imgproc/imgproc.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -16,7 +29,6 @@
# include "opencv2/legacy/compat.hpp" # include "opencv2/legacy/compat.hpp"
#include <string> #include <string>
#include <stdio.h>
static void help() static void help()
{ {
@ -116,3 +128,5 @@ Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, cons
return img_corr; return img_corr;
} }
#endif

View File

@ -4,8 +4,9 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_videostab) opencv_features2d opencv_calib3d opencv_legacy opencv_contrib
opencv_stitching opencv_videostab)
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
@ -14,7 +15,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project(cpp_samples) project(cpp_samples)
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) ocv_include_modules(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS} opencv_nonfree)
if(HAVE_opencv_gpu) if(HAVE_opencv_gpu)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")

View File

@ -1,4 +1,16 @@
#include "opencv2/opencv_modules.hpp" #include "opencv2/opencv_modules.hpp"
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
# include "opencv2/imgproc/imgproc.hpp" # include "opencv2/imgproc/imgproc.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
@ -10,10 +22,10 @@
# endif # endif
# include <fstream> # include <fstream>
#include <iostream>
# include <memory> # include <memory>
# include <functional> # include <functional>
# if defined WIN32 || defined _WIN32 # if defined WIN32 || defined _WIN32
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# include <windows.h> # include <windows.h>
@ -2623,3 +2635,5 @@ int main(int argc, char** argv)
} }
return 0; return 0;
} }
#endif

View File

@ -1,8 +1,11 @@
#include "opencv2/opencv_modules.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp" #include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp" #include "opencv2/features2d/features2d.hpp"
#ifdef HAVE_OPENCV_NONFREE
# include "opencv2/nonfree/nonfree.hpp" # include "opencv2/nonfree/nonfree.hpp"
#endif
#include <iostream> #include <iostream>
@ -17,14 +20,14 @@ static void help(char** argv)
<< "Case1: second image is obtained from the first (given) image using random generated homography matrix\n" << "Case1: second image is obtained from the first (given) image using random generated homography matrix\n"
<< argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image] [evaluate(0 or 1)]\n" << argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image] [evaluate(0 or 1)]\n"
<< "Example of case1:\n" << "Example of case1:\n"
<< "./descriptor_extractor_matcher SURF SURF FlannBased NoneFilter cola.jpg 0\n" << "./descriptor_extractor_matcher ORB ORB FlannBased NoneFilter cola.jpg 0\n"
<< "\n" << "\n"
<< "Case2: both images are given. If ransacReprojThreshold>=0 then homography matrix are calculated\n" << "Case2: both images are given. If ransacReprojThreshold>=0 then homography matrix are calculated\n"
<< argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image1] [image2] [ransacReprojThreshold]\n" << argv[0] << " [detectorType] [descriptorType] [matcherType] [matcherFilterType] [image1] [image2] [ransacReprojThreshold]\n"
<< "\n" << "\n"
<< "Matches are filtered using homography matrix in case1 and case2 (if ransacReprojThreshold>=0)\n" << "Matches are filtered using homography matrix in case1 and case2 (if ransacReprojThreshold>=0)\n"
<< "Example of case2:\n" << "Example of case2:\n"
<< "./descriptor_extractor_matcher SURF SURF BruteForce CrossCheckFilter cola1.jpg cola2.jpg 3\n" << "./descriptor_extractor_matcher ORB ORB BruteForce CrossCheckFilter cola1.jpg cola2.jpg 3\n"
<< "\n" << "\n"
<< "Possible detectorType values: see in documentation on createFeatureDetector().\n" << "Possible detectorType values: see in documentation on createFeatureDetector().\n"
<< "Possible descriptorType values: see in documentation on createDescriptorExtractor().\n" << "Possible descriptorType values: see in documentation on createDescriptorExtractor().\n"
@ -239,7 +242,11 @@ int main(int argc, char** argv)
return -1; return -1;
} }
#ifdef HAVE_OPENCV_NONFREE
cv::initModule_nonfree(); cv::initModule_nonfree();
#else
cout << "Warning: OpenCV is built without nonfree support SIFT, SURF and some other algorithms are not available." << endl;
#endif
bool isWarpPerspective = argc == 7; bool isWarpPerspective = argc == 7;
double ransacReprojThreshold = -1; double ransacReprojThreshold = -1;

View File

@ -49,6 +49,18 @@
// //
//M*/ //M*/
#include "opencv2/opencv_modules.hpp"
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include "opencv2/opencv.hpp" # include "opencv2/opencv.hpp"
# include "opencv2/nonfree/nonfree.hpp" # include "opencv2/nonfree/nonfree.hpp"
@ -212,3 +224,5 @@ int main(int argc, char * argv[]) {
return 0; return 0;
} }
#endif

View File

@ -34,7 +34,19 @@
// or tort (including negligence or otherwise) arising in any way out of // or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
#include "opencv2/opencv_modules.hpp"
#include <iostream> #include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include <string> # include <string>
# include <vector> # include <vector>
@ -126,3 +138,5 @@ int main( int argc, char** argv ) {
imshow("matches", imgMatch); imshow("matches", imgMatch);
waitKey(0); waitKey(0);
} }
#endif

View File

@ -1,11 +1,23 @@
#include "opencv2/opencv_modules.hpp"
#include <cstdio>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/opencv_modules.hpp"
# include "opencv2/calib3d/calib3d.hpp" # include "opencv2/calib3d/calib3d.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
# include "opencv2/imgproc/imgproc.hpp" # include "opencv2/imgproc/imgproc.hpp"
# include "opencv2/nonfree/nonfree.hpp" # include "opencv2/nonfree/nonfree.hpp"
#include <cstdio>
using namespace cv; using namespace cv;
static void help() static void help()
@ -91,3 +103,5 @@ Mat DrawCorrespondences(const Mat& img1, const vector<KeyPoint>& features1, cons
return img_corr; return img_corr;
} }
#endif

View File

@ -1,4 +1,16 @@
#include "opencv2/opencv_modules.hpp"
#include <stdio.h> #include <stdio.h>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -56,3 +68,5 @@ int main(int argc, char** argv)
return 0; return 0;
} }
#endif

View File

@ -4,8 +4,19 @@
* @author A. Huaman * @author A. Huaman
*/ */
#include "opencv2/opencv_modules.hpp"
#include <stdio.h> #include <stdio.h>
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -28,7 +39,7 @@ int main( int argc, char** argv )
Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE ); Mat img_2 = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
if( !img_1.data || !img_2.data ) if( !img_1.data || !img_2.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; } { printf(" --(!) Error reading images \n"); return -1; }
//-- Step 1: Detect the keypoints using SURF Detector //-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400; int minHessian = 400;
@ -97,4 +108,6 @@ int main( int argc, char** argv )
* @function readme * @function readme
*/ */
void readme() void readme()
{ std::cout << " Usage: ./SURF_FlannMatcher <img1> <img2>" << std::endl; } { printf(" Usage: ./SURF_FlannMatcher <img1> <img2>\n"); }
#endif

View File

@ -4,8 +4,19 @@
* @author A. Huaman * @author A. Huaman
*/ */
#include "opencv2/opencv_modules.hpp"
#include <stdio.h> #include <stdio.h>
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -29,7 +40,7 @@ int main( int argc, char** argv )
Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE ); Mat img_scene = imread( argv[2], CV_LOAD_IMAGE_GRAYSCALE );
if( !img_object.data || !img_scene.data ) if( !img_object.data || !img_scene.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; } { printf(" --(!) Error reading images \n"); return -1; }
//-- Step 1: Detect the keypoints using SURF Detector //-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400; int minHessian = 400;
@ -121,4 +132,6 @@ int main( int argc, char** argv )
* @function readme * @function readme
*/ */
void readme() void readme()
{ std::cout << " Usage: ./SURF_Homography <img1> <img2>" << std::endl; } { printf(" Usage: ./SURF_Homography <img1> <img2>\n"); }
#endif

View File

@ -4,8 +4,19 @@
* @author A. Huaman * @author A. Huaman
*/ */
#include "opencv2/opencv_modules.hpp"
#include <stdio.h> #include <stdio.h>
#include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -69,4 +80,6 @@ int main( int argc, char** argv )
* @function readme * @function readme
*/ */
void readme() void readme()
{ std::cout << " Usage: ./SURF_descriptor <img1> <img2>" << std::endl; } { printf(" Usage: ./SURF_descriptor <img1> <img2>\n"); }
#endif

View File

@ -4,8 +4,19 @@
* @author A. Huaman * @author A. Huaman
*/ */
#include <stdio.h> #include "opencv2/opencv_modules.hpp"
#include <iostream> #include <iostream>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/features2d/features2d.hpp" # include "opencv2/features2d/features2d.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
@ -60,3 +71,5 @@ int main( int argc, char** argv )
*/ */
void readme() void readme()
{ std::cout << " Usage: ./SURF_detector <img1> <img2>" << std::endl; } { std::cout << " Usage: ./SURF_detector <img1> <img2>" << std::endl; }
#endif

View File

@ -1,7 +1,6 @@
SET(OPENCV_OCL_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui SET(OPENCV_OCL_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_ocl opencv_calib3d opencv_legacy opencv_contrib opencv_ocl)
opencv_nonfree)
ocv_check_dependencies(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS}) ocv_check_dependencies(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS})
@ -11,7 +10,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
project("${project}_samples") project("${project}_samples")
ocv_include_modules(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS}) ocv_include_modules(${OPENCV_OCL_SAMPLES_REQUIRED_DEPS} opencv_nonfree)
if(HAVE_OPENCL) if(HAVE_OPENCL)
ocv_include_directories(${OPENCL_INCLUDE_DIR}) ocv_include_directories(${OPENCL_INCLUDE_DIR})
@ -52,7 +51,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
endif() endif()
if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32)
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd *.txt) file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* *.txt)
install(FILES ${install_list} install(FILES ${install_list}
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl" DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples)

View File

@ -1,5 +1,16 @@
#include "opencv2/opencv_modules.hpp"
#include <iostream> #include <iostream>
#include <stdio.h>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
std::cout << "The sample requires nonfree module that is not available in your OpenCV distribution." << std::endl;
return -1;
}
#else
# include "opencv2/core/core.hpp" # include "opencv2/core/core.hpp"
# include "opencv2/highgui/highgui.hpp" # include "opencv2/highgui/highgui.hpp"
# include "opencv2/ocl/ocl.hpp" # include "opencv2/ocl/ocl.hpp"
@ -326,3 +337,5 @@ int main(int argc, char* argv[])
waitKey(0); waitKey(0);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#endif