thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

how to change USB camera? #704

Open jplnasa5 opened 6 years ago

jplnasa5 commented 6 years ago

I change the code : file =0 change to file =1 like this:

def camera(self): file = self.FLAGS.demo SaveVideo = self.FLAGS.saveVideo

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

so how to change another USB camera ?

GoyalAnkit16 commented 4 years ago

You changed file = 0 to file = 1, that's sufficient No need to change anything in the command Don't insert 1 there. It works for me