首页 > 代码库 > opencv_ROI选择感兴趣的区域在原图上画出矩形并显示ROI及应用程序

opencv_ROI选择感兴趣的区域在原图上画出矩形并显示ROI及应用程序

#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>

int main()
{
        IplImage *Image1;
        IplROI ROI;
        CvRect Rect1,Rect2;
        Image1=cvLoadImage("黑子.jpg",1);
        Rect1=cvRect(50,50,14,22);//坐标值根据手动标定来确定
        ROI=cvRectToROI(Rect1,0);
        Image1->roi=&ROI;

        Rect2=cvROIToRect(*Image1->roi);

        cvNamedWindow("Coast(Region Of Interesting)",1);
        cvShowImage("Coast(Region Of Interesting)",Image1);

        Image1->roi=NULL;
        cvRectangle(Image1,cvPoint(50,50),cvPoint(50 + 14,50 + 22),CV_RGB(255,0,0),1,8,0);
        cvNamedWindow("Coast",1);
        cvShowImage("Coast",Image1);

        cvWaitKey(0);
}
#include"opencv2/highgui/highgui.hpp"#include"iostream"using namespace std;using namespace cv;   void main()  {      IplImage *src=http://www.mamicode.com/cvLoadImage("黑子.jpg",-1);//读入图像  >


opencv_ROI选择感兴趣的区域在原图上画出矩形并显示ROI及应用程序