Hi expert
I have a program that is using opencv VideoCapture interface. But it cannot get the latest frame from capture usbcam (Logitech, Inc. Webcam C270). The result of the inference is always delayed by 6 seconds. In order to solve the issue, I want to migrate to jetcam.
import cv2
import tensorflow as tf
import tensornets as nets
<b>inputs = tf.placeholder(tf.float32, [None, 416, 416, 3]</b>)
model = nets.YOLOv3COCO(inputs, nets.Darknet19)
cap = cv2.VideoCapture("/dev/video0")
....
frame = cap.read()[1]
img=cv2.resize(frame,(416,416))
<b> imge=np.array(img).reshape(-1,416,416,3)</b>
preds = sess.run(model.preds, {inputs: model.preprocess(imge)})
but some error when migrate to jetcam
from jetcam.usb_camera import USBCamera
camera = USBCamera(width=416, height=416, format='brg8', capture_width=640, capture_height=480, capture_device=0)
import tensorflow as tf
import tensornets as nets
<b>inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])</b>
model = nets.YOLOv3COCO(inputs, nets.Darknet19)
.....
camera.running = True
frame = camera.read()
start_time = time.time()
preds = sess.run(model.preds, {inputs: model.preprocess(frame)})
error
evice (/job:localhost/replica:0/task:0/device:GPU:0 with 1500 MB memory) -> physical GPU (device: 0, name: NVIDIA Tegra X1, pci bus id: 0000:00:00.0, compute capability: 5.3)
Traceback (most recent call last):
File "jetcam-show_last_frame.py", line 22, in <module>
preds = sess.run(model.preds, {inputs: model.preprocess(frame)})
File "/home/hgnan/.local/lib/python3.6/site-packages/tensornets/preprocess.py", line 39, in _direct
return __preprocess_dict__[model_name](inputs, target_size)
File "/home/hgnan/.local/lib/python3.6/site-packages/tensornets/preprocess.py", line 112, in darknet_preprocess
y = np.zeros((len(x), h, w, x.shape[3]))
Any idea for me.
Thanks.