OpenCV simple showimage command takes 70ms on RPI4
Dear OpenCV-Fellows, I am using openCV on a RPI4 - 4GB and I'm doing realtime person detection with it so frame rate is quite crucial. My whole alogrithm takes 70ms and then, on top, the showimage takes again 70ms, which basically halfs the framerate.
Can you think of a way to speed up the imageshow? Currently, I am using a 1920x1080png with a size of around 1MB. I update only a few numbers on the image during each cycle.
def showimage(img):
to_show = img.copy()
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.putText(to_show, str(allowed), (180, 660), cv2.FONT_HERSHEY_SIMPLEX, 10, (255, 255, 255), 15)
cv2.putText(to_show, str(people_inside), (180, 1020), cv2.FONT_HERSHEY_SIMPLEX, 10, (255, 255, 255), 15)
cv2.imshow("window", to_show)
cv2.waitKey(1)
I see two possibilities:
Thank you Eduardo, do you have some tutorial in mind that explains your suggestion: using low-level API calls, e.g. GTK, X11, OpenGL,
I have no idea where to start and there aren't helpful google entries for that keywords.
You should try first to render in another thread.
Also, you should try to display the bare minimum, that is
imshow
+waitKey
and without any processing to see the computation time and if the other calls would not be the source of the slowdown.Since you are using Python, you can try PyQt. I think there should be also tutorials for using OpenGL in Python.