#include <iostream>
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <highgui.h>
using namespace cv;
using namespace std;
Mat image;
char window_name[20]="Get coordinates";
static void onMouse( int event, int x, int y, int f, void* ){
cout << x << " " << y << endl;
//putText(image, "point", Point(x,y), CV_FONT_HERSHEY_PLAIN, 1.0, CV_RGB(255,0,0));
}
int main() {
namedWindow( window_name, CV_WINDOW_AUTOSIZE );
image = imread("image.png");
imshow( window_name, image );
setMouseCallback( window_name, onMouse, 0 );
waitKey(0);
return 0;
}
这是在控制台上将鼠标悬停在图像上时打印鼠标指针坐标值的代码。如果我想在图像上类似地打印坐标,我应该怎么做?