ios - how to detect moving object in live video camera using openCV -


i using opencv ios application detect moving object in live video camera, not familiar use of opencv please me. other way 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 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 new @ opencv so, don't know do.

add code processimage delegate :

- (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 model     bg_model->apply(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); } 

you'll need declare following global variable

cv::mat img, fgmask; cv::ptr<cv::backgroundsubtractor> bg_model; bool update_bg_model; where, img <- smaller image fgmask <- mask denotes motion happening update_bg_model <- if want fixed background; 

please refer url further information.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -