-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalibration .py
61 lines (47 loc) · 1.32 KB
/
calibration .py
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
54
55
56
57
58
59
60
61
# importing the module
import cv2
import matplotlib.pyplot as plt
width = 200
height = 100
# function to display the coordinates of
# of the points clicked on the image
def click_event(event, x, y, flags, params):
# checking for left mouse clicks
if event == cv2.EVENT_LBUTTONDOWN:
# displaying the coordinates
# on the Shell
print(x, ' ', y)
# displaying the coordinates
# on the image window
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, str(x) + ',' +
str(y), (x,y), font,
1, (255, 0, 0), 2)
cv2.imshow('image', img)
# checking for right mouse clicks
if event==cv2.EVENT_RBUTTONDOWN:
# displaying the coordinates
# on the Shell
print(x, ' ', y)
# displaying the coordinates
# on the image window
font = cv2.FONT_HERSHEY_SIMPLEX
b = img[y, x, 0]
g = img[y, x, 1]
r = img[y, x, 2]
cv2.putText(img, str(b) + ',' +
str(g) + ',' + str(r),
(x,y), font, 1,
(255, 255, 0), 2)
cv2.imshow('image', img)
# driver function
if __name__=="__main__":
image = cv2.imread('sampl.jpg')
resized_image = cv2.resize(image, (755, 377))
plt.imshow(resized_image)
frame = resized_image
img = frame
cv2.imshow('image',img)
cv2.setMouseCallback('image', click_event)
cv2.waitKey(0)
# wait for a key to be pressed to exit