diff --git a/src/examples/test_ROI_ORB.cpp b/src/examples/test_ROI_ORB.cpp index 8d33f947197ea07a8487d178353bccccb4ad050a..40760fd892e582753a776ca24c0e5650f625d7e6 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 99cfa4046c0ab0e57f05620f55805410506afc93..48af706ec6123a32c05dfc9f19e16ca39dce0ffd 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 e37dda2b630b6c20f03de73e0e2913ab4896bf17..f798e3907be437a4c6e6b7085c0c2d8fbe350da9 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