setMouseCallback wrong

Hello, I have the following code usiing Opencv, Can somebody tell me how to call
setMouseCallback because I have an error , more precisely at onMouse say that a pointer to a member is nor valid for a managed class. Thank's.

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {

src = mOriginalImagesAf.clone();
namedWindow(winName, WINDOW_NORMAL);
setMouseCallback(winName, onMouse, NULL);
imshow(winName, src);

}



void checkBoundary(){
//check croping rectangle exceed image boundary
if (cropRect.width>img.cols - cropRect.x)
cropRect.width = img.cols - cropRect.x;

if (cropRect.height>img.rows - cropRect.y)
cropRect.height = img.rows - cropRect.y;

if (cropRect.x<0)
cropRect.x = 0;

if (cropRect.y<0)
cropRect.height = 0;
}

void showImage(){
img = src.clone();
checkBoundary();
if (cropRect.width>0 && cropRect.height>0){
ROI = src(cropRect);
imshow("cropped", ROI);
}

rectangle(img, cropRect, Scalar(0, 255, 0), 1, 8, 0);
imshow(winName, img);
}


void onMouse(int event, int x, int y, int f, void*){


switch (event){

case CV_EVENT_LBUTTONDOWN:
clicked = true;

P1.x = x;
P1.y = y;
P2.x = x;
P2.y = y;
break;

case CV_EVENT_LBUTTONUP:
P2.x = x;
P2.y = y;
clicked = false;
break;

case CV_EVENT_MOUSEMOVE:
if (clicked){
P2.x = x;
P2.y = y;
}
break;

default: break;


}


if (clicked){
if (P1.x>P2.x){
cropRect.x = P2.x;
cropRect.width = P1.x - P2.x;
}
else {
cropRect.x = P1.x;
cropRect.width = P2.x - P1.x;
}

if (P1.y>P2.y){
cropRect.y = P2.y;
cropRect.height = P1.y - P2.y;
}
else {
cropRect.y = P1.y;
cropRect.height = P2.y - P1.y;
}

}


showImage();


}
Topic archived. No new replies allowed.