Iam trying to draw circles on points where the user clicks on the image..below is my code..it doesn't draws the circle when clicked on the image.But when i add
cvCircle(shape,cvPoint(100,100),10,CV_RGB(0,255,0),-1);
inside main function it just draws the circle...(here i have given the x,y coordinates manually)
IplImage* shape;
void mouseHandler(int event, int x, int y, int flags, void* param)
{
switch(event){
case CV_EVENT_LBUTTONDOWN:
printf("Left button clicked %i\ %i \n",x,y);
cvCircle(shape,cvPoint(x,y),10,CV_RGB(0,255,0),-1);
break;
case CV_EVENT_RBUTTONDOWN:
printf("Right BUTTON Clicked\n");
break;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cvNamedWindow("Shapes",CV_WINDOW_AUTOSIZE);
shape=cvLoadImage("bb.jpg");
cvSetMouseCallback("Shapes",mouseHandler,0);
cvShowImage("Shapes",shape);
cvWaitKey(0);
cvReleaseImage(&shape);
cvDestroyAllWindows();
return 0;
}
Does anyone know the reason?
Thankyou