Opencv_roi Select areas of interest draw rectangles on the original and show ROI and applications

Source: Internet
Author: User

#include <opencv2/highgui/highgui.hpp> #include <stdio.h>int main () {        iplimage *image1;        Iplroi ROI;        Cvrect Rect1,rect2;        Image1=cvloadimage ("sunspot. jpg", 1);        Rect1=cvrect (50,50,14,22);//coordinate value according to manual calibration to determine        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 (+ 14,50 +), 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=cvloadimage ("sunspot. jpg",-1);//read in image      iplimage *dst;      Cvrect roi_rect_src;      Cvrect ROI_RECT_DST;      Cvnamedwindow ("src", cv_window_autosize);      Cvmovewindow ("src", 200,200);      cvshowimage ("src", src);//Output an image of the non-locating ROI      cvwaitkey (0);            roi_rect_src.x=src->width/2;      roi_rect_src.y=src->height/2;      roi_rect_src.width=200;      roi_rect_src.height=200;      Cvsetimageroi (SRC,ROI_RECT_SRC);      cout<< "output image area" <<endl;      cout<< (src->roi->xoffset) << "<< (src->roi->yoffset) <<endl ;      cout<< (Src->roI->width) << "<< (src->roi->height) <<endl; <span style=" White-space:pre "> </span>cvnamedwindow ("Src1", cv_window_autosize);    cvshowimage ("Src1", SRC);//output set image after Roi         Dst=cvcloneimage (SRC);//Copy the image of the ROI region      Roi_rect_dst=cvgetimageroi (DST); /Get ROI area of image      cout<< "ROI of output target image" <<endl;      cout<<roi_rect_dst.x<< "" <<ROI_rect_dst.y<<endl;      cout<<roi_rect_dst.width<< "" <<ROI_rect_dst.height<<endl;      Cvnamedwindow ("DST", cv_window_autosize);      Cvmovewindow ("DST", 400,200);      Cvshowimage ("DST", DST);      Cvwaitkey (0);        Cvresetimageroi (DST);//release ROI      cvshowimage ("DST", DST) for the target image;      Cvwaitkey (0);      Cvreleaseimage (&AMP;SRC);     Cvreleaseimage (&AMP;DST);  }  


Opencv_roi Select areas of interest draw rectangles on the original and show ROI and applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.