ROI.cpp
上传用户:bjtznx
上传日期:2022-07-26
资源大小:1k
文件大小:1k
- #include <stdio.h>
- #include <cv.h>
- #include <highgui.h>
- #include <math.h>
- int main(void)
- {
- /* load image */
- long current_frame = 0;
- while(true)
- {
- CvCapture *input_video = cvCaptureFromFile("SAM_0826.AVI");
- cvSetCaptureProperty( input_video, CV_CAP_PROP_POS_FRAMES, current_frame );
- IplImage *img1 = cvQueryFrame( input_video );
- //cvNamedWindow( "SRC", 0 );
- //cvShowImage( "SRC", img1 );
- /* sets the Region of Interest
- Note that the rectangle area has to be __INSIDE__ the image */
- cvSetImageROI(img1, cvRect(0, 0, 640, 187));
- /* create destination image
- Note that cvGetSize will return the width and the height of ROI */
- IplImage *img2 = cvCreateImage(cvGetSize(img1),img1->depth,img1->nChannels);
- /* copy subimage */
- cvCopy(img1, img2, NULL);
- IplImage *img3 = cvCreateImage(cvGetSize(img1),img1->depth,img1->nChannels );
- cvConvertImage(img2, img3, CV_CVTIMG_FLIP);
- /* Show the output */
- cvNamedWindow( "ROI", 0 );
- cvShowImage( "ROI", img3 );
- cvWaitKey(10);
- /* always reset the Region of Interest */
- cvResetImageROI(img1);
- current_frame++;
- }
- }