I tried to run the code in Jetson GPU but I can't?
I just obtained 5 fps, this means that use CPU not GPU
this is my full code
from imutils.video import VideoStream
from imutils.video import FPS
import numpy as np
import argparse
import imutils
import time
import cv2
CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
"bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
"dog", "horse", "motorbike", "person", "pottedplant", "sheep",
"sofa", "train", "tvmonitor"]
COLORS = np.random.uniform(0, 255, size=(len(CLASSES), 3))
print("[INFO] loading model...")
net = cv2.dnn.readNetFromCaffe('prototxt.txt', 'caffemodel') # deep neural network ( dnn )
print("[INFO] starting video stream...")
vs = cv2.VideoCapture(0)
vs.release()
vs = cv2.VideoCapture(0)
time.sleep(2.0)
fps = FPS().start()
while True:
ret, frame = vs.read() # add ret,
frame = imutils.resize(frame, width=400)
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)),
0.007843, (300, 300), 127.5)
net.setInput(blob)
detections = net.forward()
big_area = 0
big_center = 320
detected = 0
# loop over the detections
for i in np.arange(0, detections.shape[2]):
confidence = detections[0, 0, i, 2]
object_type = int(detections[0, 0, i, 1])
if object_type == 15 and confidence > 0.2: # it was if confidence > args["confidence"]:
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
(startX, startY, endX, endY) = box.astype("int")
label = "{}: {:.2f}%".format('person', confidence * 100)
cv2.rectangle(frame, (startX, startY), (endX, endY), [0, 0, 255], 2)
y = startY - 15 if startY - 15 > 15 else startY + 15
cv2.putText(frame, label, (startX, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, [0, 0, 255], 2)
rect_area = (endX - startX) * (endY - startY)
detected = 1
if rect_area > big_area: # big_area and big_center are used so that the TurtleBot always tracks the closest person
big_area = rect_area
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
fps.update()
# stop the timer and display FPS information
fps.stop()
vs.release()
cv2.destroyAllWindows()
any ideas or suggestions?
thank you in advance
↧