From e0c7d667da065d3f6a3b9cb300318570e5989f23 Mon Sep 17 00:00:00 2001 From: asantamaria <asantamaria@iri.upc.edu> Date: Wed, 30 Aug 2017 12:43:20 +0200 Subject: [PATCH] new naming for OpenCV3 headers in OpenCV examples --- src/examples/test_ROI_ORB.cpp | 12 ++++-- src/examples/test_opencv.cpp | 14 +++++-- src/examples/test_tracker_ORB.cpp | 67 ++++++++++++++++++------------- 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/src/examples/test_ROI_ORB.cpp b/src/examples/test_ROI_ORB.cpp index 8d33f9471..40760fd89 100644 --- a/src/examples/test_ROI_ORB.cpp +++ b/src/examples/test_ROI_ORB.cpp @@ -1,11 +1,17 @@ //std includes #include <iostream> -//opencv includes -#include "opencv2/features2d/features2d.hpp" +// OpenCV includes +#if defined (HAVE_OPENCV3) +#include <opencv2/features2d.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/core.hpp> +#include <opencv2/imgproc.hpp> +#else +#include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui.hpp> -#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/core/core.hpp> +#endif int main(int argc, char** argv) { diff --git a/src/examples/test_opencv.cpp b/src/examples/test_opencv.cpp index 99cfa4046..48af706ec 100644 --- a/src/examples/test_opencv.cpp +++ b/src/examples/test_opencv.cpp @@ -9,12 +9,20 @@ // general includes #include "unistd.h" #include <time.h> -#include "opencv2/calib3d/calib3d.hpp" -#include "opencv2/features2d/features2d.hpp" +// OpenCV includes +#if defined (HAVE_OPENCV3) +#include <opencv2/features2d.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/core.hpp> +#include <opencv2/imgproc.hpp> +#include "opencv2/calib3d.hpp" +#else +#include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> -#include "opencv2/imgproc/imgproc.hpp" +#include "opencv2/calib3d/calib3d.hpp" +#endif // General includes //#include <math.h> diff --git a/src/examples/test_tracker_ORB.cpp b/src/examples/test_tracker_ORB.cpp index e37dda2b6..f798e3907 100644 --- a/src/examples/test_tracker_ORB.cpp +++ b/src/examples/test_tracker_ORB.cpp @@ -1,8 +1,12 @@ //std includes #include <iostream> -//opencv includes -#include "opencv2/features2d/features2d.hpp" +// OpenCV includes +#if defined (HAVE_OPENCV3) +#include <opencv2/features2d.hpp> +#else +#include <opencv2/features2d/features2d.hpp> +#endif #include "processor_image_landmark.h" @@ -12,32 +16,39 @@ int main(int argc, char** argv) std::cout << std::endl << "==================== tracker ORB test ======================" << std::endl; - cv::VideoCapture capture; - const char * filename; - if (argc == 1) - { - std::string video_path = "/src/examples/Test_ORB.mp4"; - filename = (_WOLF_ROOT_DIR + video_path).c_str(); - capture.open(filename); - } - else if (std::string(argv[1]) == "0") - { - //camera - filename = "0"; - capture.open(0); - } - else - { - filename = argv[1]; - capture.open(filename); - } - std::cout << "Input video file: " << filename << std::endl; - if(!capture.isOpened()) std::cout << "failed" << std::endl; else std::cout << "succeded" << std::endl; - //capture.set(CV_CAP_PROP_POS_MSEC, 3000); - - unsigned int img_width = capture.get(CV_CAP_PROP_FRAME_WIDTH); - unsigned int img_height = capture.get(CV_CAP_PROP_FRAME_HEIGHT); - std::cout << "Image size: " << img_width << "x" << img_height << std::endl; + // parsing input params + const char * filename; + cv::VideoCapture capture; + if (argc < 2) + { + std::cout << "Please use\n\t./test_opencv <arg> " + "\nwith " + "\n\targ = <path/videoname.mp4> for video input " + "\n\targ = 0 for camera input." << std::endl; + return 0; + } + else if (std::string(argv[1]) == "0") + { + filename = "0"; // camera + capture.open(0); + std::cout << "Input stream from camera " << std::endl; + } + else + { + filename = argv[1]; // provided through argument + capture.open(filename); + std::cout << "Input video file: " << filename << std::endl; + } + // Open input stream + if (!capture.isOpened()) // check if we succeeded + std::cout << "failed" << std::endl; + else + std::cout << "succeded" << std::endl; + + // set and print image properties + unsigned int img_width = (unsigned int)capture.get(CV_CAP_PROP_FRAME_WIDTH); + unsigned int img_height = (unsigned int)capture.get(CV_CAP_PROP_FRAME_HEIGHT); + std::cout << "Image size: " << img_width << "x" << img_height << std::endl; //===================================================== // Environment variable for configuration files -- GitLab