Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am trying to run yolo in opencv using darknet on cpu code works fine but not getting camera displayed.

code is here you guys can see`import cv2 from darkflow.net.build import TFNet import numpy as np import time

option= { 'model':'cfg/yolo.cfg', 'load':'bin/yolov2.weights', 'threshold': 0.13, } tfnet=TFNet(option)

camera_port=0

capture=cv2.VideoCapture(0) colors =[tuple(255*np.random.rand(3)) for i in range(5)] while (capture.isOpened()): stime=time.time() ret,frame=capture.read() result=tfnet.return_predict(frame) if ret: for colors,result in zip (colors,result): tl= (result['topleft']['x'],result['topleft']['y']) br =(result['bottomright']['x'],result['bottomright']['y']) label = result['label'] frame=cv2.rectangle(frame,tl,br,(0,255,0),7) frame =cv2.putText(frame,label,br,cv2.FONT_HERSHEY_COMPLEX, 10,(0,0,0),2) cv2.imshow('frame',frame) print('FPS{:.1f}'.format(1/(time.time() -stime))) if cv2.waitKey(1)& 0xff ==ord('q'): break else: capture.release() cv2.destroyAllWindows() break `error is [ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

click to hide/show revision 2
None

updated 2019-12-13 03:37:11 -0600

berak gravatar image

I am trying to run yolo in opencv using darknet on cpu code works fine but not getting camera displayed.

code is here you guys can see`import see`

import cv2
from darkflow.net.build import TFNet
import numpy as np
import time

time option= { 'model':'cfg/yolo.cfg', 'load':'bin/yolov2.weights', 'threshold': 0.13, } tfnet=TFNet(option)

camera_port=0

tfnet=TFNet(option) #camera_port=0 capture=cv2.VideoCapture(0) colors =[tuple(255*np.random.rand(3)) for i in range(5)] while (capture.isOpened()): stime=time.time() ret,frame=capture.read() result=tfnet.return_predict(frame) if ret: for colors,result in zip (colors,result): tl= (result['topleft']['x'],result['topleft']['y']) br =(result['bottomright']['x'],result['bottomright']['y']) label = result['label'] frame=cv2.rectangle(frame,tl,br,(0,255,0),7) frame =cv2.putText(frame,label,br,cv2.FONT_HERSHEY_COMPLEX, 10,(0,0,0),2) cv2.imshow('frame',frame) print('FPS{:.1f}'.format(1/(time.time() -stime))) if cv2.waitKey(1)& 0xff ==ord('q'): break else: capture.release() cv2.destroyAllWindows() break

`error is is

[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

callback

I am trying to run yolo in opencv using darknet on cpu code works fine but not getting camera displayed.

code is here you guys can see`

import cv2
from darkflow.net.build import TFNet
import numpy as np
import time

option= {
    'model':'cfg/yolo.cfg',
    'load':'bin/yolov2.weights',
    'threshold': 0.13,
    }
tfnet=TFNet(option)
#camera_port=0
capture=cv2.VideoCapture(0)
colors =[tuple(255*np.random.rand(3)) for i in range(5)]
while (capture.isOpened()):
    stime=time.time()
    ret,frame=capture.read()
    result=tfnet.return_predict(frame)
    if ret:
        for colors,result in zip (colors,result):
            tl= (result['topleft']['x'],result['topleft']['y'])
            br =(result['bottomright']['x'],result['bottomright']['y'])
            label = result['label']
            frame=cv2.rectangle(frame,tl,br,(0,255,0),7)
            frame =cv2.putText(frame,label,br,cv2.FONT_HERSHEY_COMPLEX, 10,(0,0,0),2)
        cv2.imshow('frame',frame)
        print('FPS{:.1f}'.format(1/(time.time() -stime)))
        if cv2.waitKey(1)& 0xff ==ord('q'):
            break
        else:
            capture.release()
            cv2.destroyAllWindows()
            break

`error is

[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback

I am trying to run yolo in opencv using darknet on cpu code works fine but not getting camera displayed.displayed.[Solved]

code is here you guys can see`

import cv2
from darkflow.net.build import TFNet
import numpy as np
import time

option= {
    'model':'cfg/yolo.cfg',
    'load':'bin/yolov2.weights',
    'threshold': 0.13,
    }
tfnet=TFNet(option)
#camera_port=0
capture=cv2.VideoCapture(0)
colors =[tuple(255*np.random.rand(3)) for i in range(5)]
while (capture.isOpened()):
    stime=time.time()
    ret,frame=capture.read()
    result=tfnet.return_predict(frame)
    if ret:
        for colors,result in zip (colors,result):
            tl= (result['topleft']['x'],result['topleft']['y'])
            br =(result['bottomright']['x'],result['bottomright']['y'])
            label = result['label']
            frame=cv2.rectangle(frame,tl,br,(0,255,0),7)
            frame =cv2.putText(frame,label,br,cv2.FONT_HERSHEY_COMPLEX, 10,(0,0,0),2)
        cv2.imshow('frame',frame)
        print('FPS{:.1f}'.format(1/(time.time() -stime)))
        if cv2.waitKey(1)& 0xff ==ord('q'):
            break
        else:
            capture.release()
            cv2.destroyAllWindows()
            break

`error is

[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674) SourceReaderCB::~SourceReaderCB terminating async callback