How to use the cv2.imshow() function with DeepStream SDK 5.0
I’ve heard that you can now access image data directly from DeepStream SDK 5.0.
Via pyds.get_nvds_buf_surface() we have confirmed that the image can be handled by OpenCV.
n_frame=pyds.get_nvds_buf_surface(hash(gst_buffer),frame_meta.batch_id)
frame_image=np.array(n_frame,copy=True,order='C')
#covert the array into cv2 default color format
print("ffs")
frame_image=cv2.cvtColor(frame_image,cv2.COLOR_RGBA2BGRA)
frame_image=draw_bounding_boxes(frame_image,obj_meta,obj_meta.confidence)
But I want the result to appear on the screen after processing in OpenCV.
So I want to use cv2.imshow(), but it stops at the cv2.waitKey(1) part.
Is there a way to display the results of processing in OpenCV?
I’m making it with that as a reference.
I’m having trouble because it doesn’t show up when I run cv2.imshow(“Test”,frame_image) after get_nvds_buf_surfac()
Hi @natukage405,
can you save the image with cv2.imwrite()?
With below chnage, I can save the image as png and view it with display.
Would check if it’s your display issue or others.
Thanks!
@@ -123,6 +126,7 @@ def tiler_sink_pad_buffer_probe(pad,info,u_data):
frame_image=np.array(n_frame,copy=True,order='C')
#covert the array into cv2 default color format
frame_image=cv2.cvtColor(frame_image,cv2.COLOR_RGBA2BGRA)
+ cv2.imwrite("test.png", frame_image)
save_image = True
frame_image=draw_bounding_boxes(frame_image,obj_meta,obj_meta.confidence)
I can confirm that the image can be saved with cv2.imwrite() and that I can reference the saved image.
But what I want to do is to display the image using cv2.imshow().
You need to investigate.
I have the same problem as natukage405, I want to display real-time frame by using cv2.imshow() but when I use it in the code (in deepstream_test1_usbcam in python examples), it does not work. I need the cv2.imshow() output for using it in another GUI.
I appreciate it if you could help me with this issue.
Because they might need to make some transformations. I think the point is showing a custom image (~custom overlay, shrink etc.). I was running into this same issue. Do you have any solution yet? Thank you.
My problem is completely the same as the original topic, but you do not have any good solution (cv2.imshow with deepstream), just a workaround (that is sometimes ok, sometimes not).
e.g.: a custom drawing/texts on the screen. The default deepstream drawing is not optimal in many cases (especially if there are overlapped objects. E.g.: if I would add text that shows average of the last few object count etc. Can I use custom drawing on render plugin?
I don’t quite understand how to use this. Can you describe in more detail how the program code using Deepstream and cv2.imshow should look like?
Multithreading, multiprocessing but how exactly?
Cv2.imshow as far as I know should be in the main thread.