c++ - OpenCv Cropping issue -


i new opencv. trying crop image code have written not cropping it. please me out. got region of interest when try copy it copies whole image not region of interest

#include<iostream> using namespace std; #include<vector> #include<iostream> #include<opencv2\opencv.hpp>   cvmemstorage * st = 0; cvhaarclassifiercascade * hcc= 0; char * path =  "c:/users/gardezi/documents/visual studio 2012/projects/aimrl/aimrl/haarcascade_frontalface_alt.xml";    bool startdetection(iplimage * img) {    int ; cvcreateimage(cvgetsize(img) , img->depth , img->nchannels ); cvpoint pt1 , pt2; iplimage * f ; if (hcc) {         cvseq * face = cvhaardetectobjects(img , hcc , st , 1.1  , 2 , cv_haar_do_canny_pruning , cvsize(40  , 40 ) );       //face data base       (i = 0 ;i <  (face? face->total : 0 ) ; i++)     {         cvrect * r = (cvrect*)cvgetseqelem(face , );         pt1.x = r->x;          pt1.y = r->y;         pt2.x = r->x + r->width;         pt2.y = r->y + r->height;      cvrectangle(img , pt1 , pt2 , cv_rgb(255, 0 , 0) , 3 , 8 , 0);           cvsetimageroi(img , cvrect(pt1.x , pt1.y , pt2.x , pt2.y));           f =  cvcreateimage( cvgetsize( img) , img->depth , img->nchannels );          cvcopy(img , f , null );      }   }  cvshowimage("result" , f ); cvwaitkey(0); return true; }    void main() { iplimage * img; hcc = (cvhaarclassifiercascade *)cvload(path , 0 , 0 , 0 ); img = cvloadimage("download.jpg" , 0); st = cvcreatememstorage(0); startdetection(img); } 

if new opencv, not use iplimage, cv::mat. cropping trivial using operator parenthesis, , if need copy region of interest in new image call clone().

cv::rect roi; cv::mat image; [...] //initialization of roi , image cv::mat roiofimage = image(roi); cv::mat deepcopyofroiimage = image(roi).clone(); 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -