atulyakumar97/fire-and-gun-detection

How to improve the detect speed?

TuringLongfei opened this issue · 0 comments

Hi:
I noticed in your sample videos, there is no jitters or lags at all. But when i run your default code, it has a lot of jitters/lags. A 5 seconds video may need 15 seconds to finish. Looks like the net.forward part is taking too long. How to modify the code in order to get the same effect as you showed in your video? Many thanks!

def detect_objects(img, net, outputLayers):			
	blob = cv2.dnn.blobFromImage(img, scalefactor=0.00392, size=(320, 320), mean=(0, 0, 0), swapRB=True, crop=False)
	net.setInput(blob)
	outputs = net.forward(outputLayers) #this part is taking so long
	return blob, outputs