需求:在鼠标左键按下时,显示该位置的像素值和坐标。
在vs2010下新建了Win32控制台项目,在此只处理灰度图像,显示的像素值为灰度值
#include "iostream"
#include "cv.h"
#include "highgui.h"
#include "math.h"
using namespace std;
void mouseHandler(int event, int x, int y, int flags, void* param)
{
IplImage *img0, *img1;
img0 = (IplImage*)param;
img1 = cvCreateImage(cvSize(img0->width, img0->height), img0->depth, img0->nChannels);
cvCopy(img0, img1, NULL);
CvFont font;
uchar* ptr;
char label[20];
char label2[20];
cvInitFont(&font, CV_FONT_HERSHEY_PLAIN, 1, 1