-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouse.cpp
More file actions
53 lines (36 loc) · 1.08 KB
/
Copy pathmouse.cpp
File metadata and controls
53 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
void CallBackFunc(int event, int x, int y, int flags, void* userdata)
{
if (event == EVENT_LBUTTONDOWN)
{
cout << "왼쪽 마우스 버튼 클릭.. 좌표 = (" << x << ", " << y << ")" << endl;
}
}
int main(int argc, char** argv)
{
Mat img_original, img_gray;
//이미지파일을 로드하여 image에 저장
img_original = imread("bandicam 2017-12-12 15-46-32-142.jpg", IMREAD_COLOR);
if (img_original.empty())
{
cout << "Could not open or find the image" << std::endl;
return -1;
}
//그레이스케일 이미지로 변환
cvtColor(img_original, img_gray, COLOR_BGR2GRAY);
//윈도우 생성
//namedWindow("original image", WINDOW_AUTOSIZE);
namedWindow("gray image", WINDOW_AUTOSIZE);
//윈도우에 출력
//imshow("original image", img_original);
imshow("gray image", img_gray);
//윈도우에 콜백함수를 등록
setMouseCallback("gray image", CallBackFunc, NULL);
//키보드 입력이 될때까지 대기
waitKey(0);
return 0;
}