Laex / Delphi-OpenCV

Project Delphi-OpenCV. Translation of OpenCV library header files in Delphi
500 stars 226 forks source link

cvGetSubRect - need some help #131

Closed boomsya closed 4 years ago

boomsya commented 4 years ago

hi, I try to learn work with OpenCV and need some help with demo cv_GetSubRect demo have source code:

cut_image := cvCreateImage(CvSize(0, 0), image^.depth, image^.nChannels);
cut_image := pIplImage(cvGetSubRect(image, cut_image, R));

but if I call after that (function findSquares4 from demo Squares) line: ..... timg := cvCloneImage(cut_image); I have exception :(

boomsya commented 4 years ago

omg, I have found solution:

cut_image := cvCreateImage(CvSize(subRect.width, subRect.height), img0^.depth, img0^.nChannels);
cvGetSubRect(img0, cut_image, subRect);
image2 := cvCreateImage(cvGetSize(cut_image), img0^.depth, img0^.nChannels);
cvCopy(cut_image, image2);
Squares := findSquares4(cut_image, storage);
...
cvReleaseImage(cut_image);
cvReleaseImage(image2);
Laex commented 4 years ago

Close?