Please explain how to operate this in detail ,thanks a lot

Thanks for everyone.
Thanks for everyone.
Thanks for everyone.


opencv 截图并保存_kalp_yp-CSDN博客_opencv截图 代码功能:选择图像中矩形区,按S键截图并保存,Q键退出。#include<opencv2/opencv.hpp> #include<iostream> using namespace std;using namespace cv;Rect select;bool select_flag = false;Mat img, showImg;voi... https://blog.csdn.net/u013539952/article/details/77171061

You can use this document to do that.
Any question is accessible.
Yours Sincerely.

Please configure according to the instructions in the document. If you can't, you can seek Baidu. There should be methods on the Internet or learn relevant knowledge by yourself

I think you should learn by yourself, I am a newbie in this area too but I can do it on my own.
However, I will give my answer.
1.

you should debug it on x64.
2.

img

#include<opencv2/opencv.hpp>

#include<iostream>

using namespace cv;

int main(int argc, char** argv) {

    Mat image = imread("E:/1.png");
    Mat org1,org2,gray,dst;
    Rect rect1(7, 104, 59, 79); // init rect area
    Rect rect2(79, 208, 59, 79);//if your draw on your own coumputer desktop,you should at least modify the parameter
    Point point(388, 118);
    double x1 = 7 + 59 / 2;
    double y1 = 104 + 79/ 2;
    double x2 = 79 + 59 / 2;
    double y2 = 208 + 79 / 2;
    double distance = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    cv::rectangle(image, rect1, Scalar(255, 0, 0), 1, LINE_8, 0); //BGR scalar color mode
    cv::rectangle(image, rect2, Scalar(0, 255, 0), 1, LINE_8, 0);
    org1 = image(rect1); //load area
    org2 = image(rect2);
    namedWindow("picture1", 0); //use your mouse to drag the window
    namedWindow("picture2", 0);
    cvtColor(org1, gray, COLOR_BGR2GRAY);//First conver to gray mode
    threshold(gray, dst, 0, 255, THRESH_BINARY);//Then binary it;
    putText(image, "Distance:"+std::to_string(distance), point, FONT_HERSHEY_SIMPLEX, 1, CV_RGB(255, 0, 0), 2); //draw text
    imshow("test", image);
    imshow("picture1", dst);
    imshow("picture2", org2);
    waitKey(0);

    return 0;

}