-
Notifications
You must be signed in to change notification settings - Fork 1
/
VideoCapture.py
50 lines (43 loc) · 1.22 KB
/
VideoCapture.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
import numpy as np
import cv2
import grasp_image_func as gi
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# img = cv2.copyMakeBorder(frame, 0, 0, 0, 0, cv2.BORDER_REPLICATE)
# cv2.imshow('img', img)
# cv2.waitKey()
# Our operations on the frame come here
# gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# draw grasps
if frame is None:
continue
else:
H, W, Ang = gi.predictGraspOnImage(frame)
print(H) # y-coord of pixel position
print(W) # x-coord of pixel position
print(Ang) # angle of grasp
# Display the resulting frame
# cv2.imshow('frame', frame)
usrInput = raw_input('Press enter to continue or "q" to quit')
if usrInput == 'q':
print('exiting...')
break
else:
print('return to loop')
print('----------->')
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
# try:
# while True:
# ret, frame = cap.read()
# if frame is None:
# continue
# else:
# gi.predictGraspOnImage(frame)
# except KeyboardInterrupt:
# pass
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()