Skip to content

Commit

Permalink
Fix for uselib and OpenCV 2.x, 3.x, 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAB committed Apr 8, 2019
1 parent 42a4081 commit 1cad888
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/yolo_console_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ std::vector<bbox_t> get_3d_coordinates(std::vector<bbox_t> bbox_vect, cv::Mat xy

#include <opencv2/opencv.hpp> // C++
#include <opencv2/core/version.hpp>
#ifndef CV_VERSION_EPOCH
#ifndef CV_VERSION_EPOCH // OpenCV 3.x and 4.x
#include <opencv2/videoio/videoio.hpp>
#define OPENCV_VERSION CVAUX_STR(CV_VERSION_MAJOR)"" CVAUX_STR(CV_VERSION_MINOR)"" CVAUX_STR(CV_VERSION_REVISION)
#ifndef USE_CMAKE_LIBS
Expand All @@ -162,12 +162,13 @@ std::vector<bbox_t> get_3d_coordinates(std::vector<bbox_t> bbox_vect, cv::Mat xy
#pragma comment(lib, "opencv_highgui" OPENCV_VERSION ".lib")
#endif // TRACK_OPTFLOW
#endif // USE_CMAKE_LIBS
#else
#else // OpenCV 2.x
#define OPENCV_VERSION CVAUX_STR(CV_VERSION_EPOCH)"" CVAUX_STR(CV_VERSION_MAJOR)"" CVAUX_STR(CV_VERSION_MINOR)
#ifndef USE_CMAKE_LIBS
#pragma comment(lib, "opencv_core" OPENCV_VERSION ".lib")
#pragma comment(lib, "opencv_imgproc" OPENCV_VERSION ".lib")
#pragma comment(lib, "opencv_highgui" OPENCV_VERSION ".lib")
#pragma comment(lib, "opencv_video" OPENCV_VERSION ".lib")
#endif // USE_CMAKE_LIBS
#endif // CV_VERSION_EPOCH

Expand Down Expand Up @@ -353,20 +354,27 @@ int main(int argc, char *argv[])
cv::VideoCapture cap;
if (filename == "web_camera") {
cap.open(0);
video_fps = cap.get(CV_CAP_PROP_FPS);
cap >> cur_frame;
} else if (!use_zed_camera) {
cap.open(filename);
video_fps = cap.get(CV_CAP_PROP_FPS);
cap >> cur_frame;
}
#ifdef CV_VERSION_EPOCH // OpenCV 2.x
video_fps = cap.get(CV_CAP_PROP_FPS);
#else
video_fps = cap.get(cv::CAP_PROP_FPS);
#endif
cv::Size const frame_size = cur_frame.size();
//cv::Size const frame_size(cap.get(CV_CAP_PROP_FRAME_WIDTH), cap.get(CV_CAP_PROP_FRAME_HEIGHT));
std::cout << "\n Video size: " << frame_size << std::endl;

cv::VideoWriter output_video;
if (save_output_videofile)
#ifdef CV_VERSION_EPOCH // OpenCV 2.x
output_video.open(out_videofile, CV_FOURCC('D', 'I', 'V', 'X'), std::max(35, video_fps), frame_size, true);
#else
output_video.open(out_videofile, cv::VideoWriter::fourcc('D', 'I', 'V', 'X'), std::max(35, video_fps), frame_size, true);
#endif

struct detection_data_t {
cv::Mat cap_frame;
Expand Down

0 comments on commit 1cad888

Please sign in to comment.