1 | initial version |
// i wrote this code to train myself about this question. maybe it will be useful for newcomers like me
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( )
{
Mat image(400,300,CV_8UC1,Scalar(200,200,200));
Rect newroi;
newroi.width=image.cols*0.9;
newroi.height=image.rows*0.9;
newroi.x=image.cols*0.05;
newroi.y=image.rows*0.05;
rectangle(image,newroi,Scalar(0,0,0),1);
Mat newimage=image(newroi);
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image );
namedWindow( "Display window2", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window2", newimage );
waitKey(0); // Wait for a keystroke in the window
return 0;
}
enter code here
2 | No.2 Revision |
//
#include <opencv2/highgui/highgui.hpp>