Fixed uses of WebCam for OpenCV 3.x

This commit is contained in:
AlexeyAB
2018-03-20 22:10:46 +03:00
parent 3e5abe0680
commit fe4f01b1d8
6 changed files with 33 additions and 47 deletions

View File

@ -195,4 +195,20 @@ void send_mjpeg(IplImage* ipl, int port, int timeout, int quality) {
std::cout << " MJPEG-stream sent. \n";
}
CvCapture* get_capture_webcam(int index) {
CvCapture* cap = (CvCapture*)new cv::VideoCapture(index);
return cap;
}
IplImage* get_webcam_frame(CvCapture *cap) {
cv::VideoCapture &cpp_cap = *(cv::VideoCapture *)cap;
cv::Mat frame;
cpp_cap >> frame;
IplImage* src = cvCreateImage(cvSize(frame.cols, frame.rows), 8, frame.channels());
*src = frame;
return src;
}
#endif // OPENCV