Skip to content
Snippets Groups Projects
Commit 48c9dc2b authored by Rich Lewis's avatar Rich Lewis
Browse files

update the macos demo to work with OpenCV 3.x

parent 209a2ff5
Branches
No related tags found
No related merge requests found
#include <iostream> #include <iostream>
#include <cv.h> #include <opencv2/opencv.hpp>
#include <highgui.h>
#include "../../package_bgs/FrameDifference.h" #include "../../package_bgs/FrameDifference.h"
using namespace bgslibrary::algorithms; using namespace bgslibrary::algorithms;
//using namespace cv;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
CvCapture *capture = 0; cv::VideoCapture capture(0);
capture = cvCaptureFromCAM(0);
if(!capture){ if (!capture.isOpened())
{
std::cerr << "Cannot initialize video!" << std::endl; std::cerr << "Cannot initialize video!" << std::endl;
return -1; return -1;
} }
...@@ -19,13 +19,13 @@ int main(int argc, char **argv) ...@@ -19,13 +19,13 @@ int main(int argc, char **argv)
IBGS *bgs; IBGS *bgs;
bgs = new FrameDifference; bgs = new FrameDifference;
IplImage *frame; int key = 0;
while(1) cv::Mat img_input;
while (key != 'q')
{ {
frame = cvQueryFrame(capture); capture >> img_input;
if(!frame) break; if(img_input.empty()) break;
cv::Mat img_input(frame);
cv::imshow("Input", img_input); cv::imshow("Input", img_input);
cv::Mat img_mask; cv::Mat img_mask;
...@@ -34,18 +34,16 @@ int main(int argc, char **argv) ...@@ -34,18 +34,16 @@ int main(int argc, char **argv)
// by default, it shows automatically the foreground mask image // by default, it shows automatically the foreground mask image
bgs->process(img_input, img_mask, img_bkgmodel); bgs->process(img_input, img_mask, img_bkgmodel);
//if(!img_mask.empty()) key = cvWaitKey(33);
// cv::imshow("Foreground", img_mask);
// do something
if(cvWaitKey(33) >= 0) if(key >= 0)
break; break;
} }
delete bgs; delete bgs;
capture.release();
cvDestroyAllWindows(); cvDestroyAllWindows();
cvReleaseCapture(&capture);
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment