Programming

opencv 마우스 클릭 이벤트

 2015. 7. 23. 20:21
반응형

http://opencv-srf.blogspot.kr/2011/11/mouse-events.html


와 이건 대박

뭔가 자바랑 비슷한 삘


// 마우스 클릭 시 좌표 알아오기

void callBackFunc(int event, int x, int y, int flags, void* userdata){

if (event == EVENT_LBUTTONDOWN){

cout << "Left button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

}

else if (event == EVENT_RBUTTONDOWN){

cout << "Right button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

}

else if (event == EVENT_MBUTTONDOWN){

cout << "Middle button of the mouse is clicked - position (" << x << ", " << y << ")" << endl;

}

else if (event == EVENT_MOUSEMOVE){

cout << "Mouse move over the window - position (" << x << ", " << y << ")" << endl;

}

}


이렇게 해놓고


main에서

namedWindow(win_name, 1);

setMouseCallback(win_name, callBackFunc, NULL); // 마우스 클릭 이벤트 설정


이렇게만 설정해주면 된다!




반응형