Permalink
Browse files
Merge pull request #60 from RichLewis007/update-macos-demo-to-opencv3
update the macos demo to work with OpenCV 3.x
- Loading branch information...
Showing
with
13 additions
and
15 deletions.
-
+13
−15
demos/macosx/FrameDifferenceTest.cpp
|
|
@@ -1,31 +1,31 @@ |
|
|
#include <iostream>
|
|
|
-#include <cv.h>
|
|
|
-#include <highgui.h>
|
|
|
+#include <opencv2/opencv.hpp>
|
|
|
|
|
|
#include "../../package_bgs/FrameDifference.h"
|
|
|
|
|
|
using namespace bgslibrary::algorithms;
|
|
|
+//using namespace cv;
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
{
|
|
|
- CvCapture *capture = 0;
|
|
|
- capture = cvCaptureFromCAM(0);
|
|
|
+ cv::VideoCapture capture(0);
|
|
|
|
|
|
- if(!capture){
|
|
|
+ if (!capture.isOpened())
|
|
|
+ {
|
|
|
std::cerr << "Cannot initialize video!" << std::endl;
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
IBGS *bgs;
|
|
|
bgs = new FrameDifference;
|
|
|
|
|
|
- IplImage *frame;
|
|
|
- while(1)
|
|
|
+ int key = 0;
|
|
|
+ cv::Mat img_input;
|
|
|
+ while (key != 'q')
|
|
|
{
|
|
|
- frame = cvQueryFrame(capture);
|
|
|
- if(!frame) break;
|
|
|
+ capture >> img_input;
|
|
|
+ if(img_input.empty()) break;
|
|
|
|
|
|
- cv::Mat img_input(frame);
|
|
|
cv::imshow("Input", img_input);
|
|
|
|
|
|
cv::Mat img_mask;
|
|
|
@@ -34,18 +34,16 @@ int main(int argc, char **argv) |
|
|
// by default, it shows automatically the foreground mask image
|
|
|
bgs->process(img_input, img_mask, img_bkgmodel);
|
|
|
|
|
|
- //if(!img_mask.empty())
|
|
|
- // cv::imshow("Foreground", img_mask);
|
|
|
- // do something
|
|
|
+ key = cvWaitKey(33);
|
|
|
|
|
|
- if(cvWaitKey(33) >= 0)
|
|
|
+ if(key >= 0)
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
delete bgs;
|
|
|
|
|
|
+ capture.release();
|
|
|
cvDestroyAllWindows();
|
|
|
- cvReleaseCapture(&capture);
|
|
|
|
|
|
return 0;
|
|
|
}
|
0 comments on commit
c5c700d