i have problems with handling mouse event in opencv
i want to write a program with this feature:
1:when a user click left button of mouse on windows a circle is constructed with for ex radius (15)
at first i make a black image 500*500
and i use setMouseCallback for my_mouse_callback and in function my_mouse_callback i write my
circle code ,when run the program there arent any errors but only there is a black image 500*500 that when i click left button of mouse nothing happens, i know my program has trouble but where? please help me my program is like this:
void my_mouse_callback(int event, int x, int y, int flags, void* param);
int main() { int i,j,k;
Mat image;
image.create(500,500,CV_8UC3);
namedWindow("amin");
for(i=0;i<500;i++){
for(j=0;j<500;j++){
for(k=0;k<3;k++){
Vec3b &intensity = image.at<vec3b>(j, i);
intensity.val[k]=0;
}
}
}
setMouseCallback( "amin", my_mouse_callback, &image );
imshow("amin",image);
waitKey(0);
return(0);
}
void my_mouse_callback( int event, int x, int y, int flags, void* param ) {
if(event==CV_EVENT_LBUTTONDOWN){
circle( image, Point(x,y), 20, Scalar(0xff,0xff,0xff) );
}
}