if file == 'camera':
file = 1####################0
else:
assert os.path.isfile(file), \
'file {} does not exist'.format(file)
camera = cv2.VideoCapture(file)########file
👍
if file == 1:#############0
self.say('Press [ESC] to quit demo')
assert camera.isOpened(), \
'Cannot capture source'
if file == 1:#camera window###############0
#cv2.namedWindow('camera',0)###################0
_, frame = camera.read()#################none
cv2.imshow('frame',frame)###############none
height, width, _ = frame.shape
cv2.resizeWindow('', width, height)
Then commend:
python flow --model cfg/yolo-voc-6c.cfg --load -1 --demo camera
but error information is
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp, line 331
Traceback (most recent call last):
File "flow", line 6, in
cliHandler(sys.argv)
File "/Users/sisyphus/darkflow/darkflow/cli.py", line 29, in cliHandler
tfnet.camera()
File "/Users/sisyphus/darkflow/darkflow/net/help.py", line 89, in camera
cv2.imshow('frame',frame)###############none
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:331: error: (-215) size.width>0 && size.height>0 in function imshow
I change the code : file =0 change to file =1 like this:
def camera(self): file = self.FLAGS.demo SaveVideo = self.FLAGS.saveVideo
Then commend: python flow --model cfg/yolo-voc-6c.cfg --load -1 --demo camera
but error information is OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp, line 331 Traceback (most recent call last): File "flow", line 6, in
cliHandler(sys.argv)
File "/Users/sisyphus/darkflow/darkflow/cli.py", line 29, in cliHandler
tfnet.camera()
File "/Users/sisyphus/darkflow/darkflow/net/help.py", line 89, in camera
cv2.imshow('frame',frame)###############none
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:331: error: (-215) size.width>0 && size.height>0 in function imshow
so how to change another USB camera ?