如何让 OpenCV 窗口始终处于最前?
在使用 cv2.imshow('MediaPipe Pose Detection press q exit', frame) 显示图像时,想要让窗口始终处于最前,可以使用以下代码:
cv2.namedWindow('MediaPipe Pose Detection press q exit', cv2.WINDOW_NORMAL)
cv2.resizeWindow('MediaPipe Pose Detection press q exit', 800, 600) # 可以根据需要调整窗口大小
cv2.moveWindow('MediaPipe Pose Detection press q exit', 0, 0) # 将窗口移动到屏幕左上角
cv2.imshow('MediaPipe Pose Detection press q exit', frame)
cv2.waitKey(0)
cv2.destroyAllWindows()
这段代码中,cv2.namedWindow 函数用于创建一个名为 'MediaPipe Pose Detection press q exit' 的窗口,并将其设置为可调整大小的。cv2.resizeWindow 函数用于调整窗口大小,cv2.moveWindow 函数用于将窗口移动到屏幕左上角。最后,cv2.imshow 函数用于显示图像,cv2.waitKey(0) 函数用于等待用户按下任意键,cv2.destroyAllWindows() 函数用于关闭所有窗口。
通过以上代码,OpenCV 窗口将始终处于最前并位于屏幕左上角。
原文地址: https://www.cveoy.top/t/topic/gQWP 著作权归作者所有。请勿转载和采集!