Hi,
I am developing a application using Darknet in TX2.
print out the camera using the Qlabel on the pyQt5. But only red color doesn’t print.
If I use a gst-launch, the camera works normally.
Is there a problem with the source code?
cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, \
height=(int)720, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, \
format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink", cv2.CAP_GSTREAMER)
#cap.set(3, 1280)
#cap.set(4, 720)
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
self.label.resize(width, height)
# Create an image we reuse for each detect
darknet_image = dn.make_image(dn.network_width(netMain),
dn.network_height(netMain),3)
while running:
prev_time = time.time()
ret, frame_read = cap.read()
frame_rgb = cv2.cvtColor(frame_read, cv2.COLOR_BGR2RGB)
frame_resized = cv2.resize(frame_rgb,
(dn.network_width(netMain),
dn.network_height(netMain)),
interpolation=cv2.INTER_LINEAR)
dn.copy_image_from_bytes(darknet_image,frame_resized.tobytes())
detections = dn.detect_image(netMain, metaMain, darknet_image, thresh=0.50)
image = self.cvDrawBoxes(detections, frame_resized)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
print(1/(time.time()-prev_time))
h,w,c = image.shape
qImg = QtGui.QImage(image.data, w, h, w*c, QtGui.QImage.Format_RGB888)
pixmap = QtGui.QPixmap.fromImage(qImg)
self.label.setPixmap(pixmap)