forked from santosha86/Invoice_Processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseOver.py
More file actions
40 lines (36 loc) · 1.13 KB
/
MouseOver.py
File metadata and controls
40 lines (36 loc) · 1.13 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
import cv2
import random
scale = 1
circles =[]
counter = 0
counter2 = 0
points1 =[]
points2= []
myPoints =[]
myColor =[]
def mousePoints(event,x,y,flags,params):
global counter,point1,point2,counter2, circles,myColor
if event == cv2.EVENT_LBUTTONDOWN:
if counter == 0:
point1 = int(x//scale), int(y//scale);
counter +=1
myColor =(random.randint(0,2)*200, random.randint(0,2)*200, random.randint(0,2)*200)
elif counter ==1:
point2 = int(x//scale), int(y//scale)
type = input('Enter Type')
name = input ('Enter Name')
myPoints.append([point1,point2,type,name])
counter =0
circles.append([x,y,myColor])
counter2 +=1
img = cv2.imread('F1_invoices_1.JPG')
img = cv2.resize(img,(0,0),None,scale,scale,interpolation= cv2.INTER_LINEAR)
while True:
#To Display Points
for x,y,color in circles:
cv2.circle(img,(x,y),3,color,cv2.FILLED)
cv2.imshow("Orginal Image", img)
cv2.setMouseCallback("Orginal Image",mousePoints)
if cv2.waitKey(1) & 0xFF == ord('s'):
print(myPoints)
break