i am using openCV for my ios application to detect moving object in live video camera, but i am not familiar with use of openCV please help me. any other way to do this also welcome .
- (void)viewDidLoad {
[super viewDidLoad];
self.videoCamera.delegate = self;
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:self.view];
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionBack;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
self.videoCamera.grayscaleMode = NO;
[self.videoCamera start];
// cv::BackgroundSubtractorMOG2 bg;
}
- (void)processImage:(cv::Mat&)image
{
//process here
cv::cvtColor(image, img, cv::COLOR_BGRA2RGB);
int fixedWidth = 270;
cv::resize(img, img, cv::Size(fixedWidth,(int)((fixedWidth*1.0f)* (image.rows/(image.cols*1.0f)))),cv::INTER_NEAREST);
//update the model
bg_model->operator()(img, fgmask, update_bg_model ? -1 : 0);
GaussianBlur(fgmask, fgmask, cv::Size(7, 7), 2.5, 2.5);
threshold(fgmask, fgmask, 10, 255, cv::THRESH_BINARY);
image = cv::Scalar::all(0);
img.copyTo(image, fgmask);
}
i am new at openCV so, i don't know what to do.
Add this code to
processImage
delegate :You'll need to declare following as global variable
Please refer this URL for further information.