forked from gihanjayatilaka/Image-Marker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageMarker.py
More file actions
51 lines (35 loc) · 800 Bytes
/
ImageMarker.py
File metadata and controls
51 lines (35 loc) · 800 Bytes
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
'''
USAGE
python ImageMarker.py FolderWithImages OutputFileName
LOADING
numpy.load(OutputFileName.npy)
'''
import argparse
import sys
import os
import cv2
import numpy as np
def mouse_callback(event, x, y, flags, params):
if event==1:
clicks.append([x,y])
print(clicks)
if __name__ == "__main__":
FOLDER=sys.argv[1]
fileList=os.listdir(FOLDER)
print(fileList)
ans={}
for f in fileList:
ff=FOLDER+'/'+f
print(ff)
img=cv2.imread(ff)
cv2.imshow("image",img)
clicks=[]
cv2.setMouseCallback('image', mouse_callback)
while True:
if len(clicks)==2:
break
cv2.waitKey(1)
ans[ff]=clicks
clicks=[]
print(ans)
np.save(sys.argv[2], ans)