我正在使用OpenCV在Python中编写一些代码,该代码将获取一系列图像并对其进行处理。我为接收到的每个图像显示图像和处理后的图像。我显示图像的代码是这样的:
# Get an image and processes it
cv2.imshow('Raw Image', img)
cv2.imshow('Partially Processed Image', partially_processed_image)
cv2.imshow('Processed Image', processed_image)
cv2.waitkey(0)
# Save result and repeat back through for another image
这会将图像全部放在屏幕上的同一位置,彼此重叠。 OpenCV中是否可以将图像显示到不同的屏幕位置(因此它们不会自动显示在彼此的顶部)?我查看了文档,没有发现任何明显的东西,但是我想知道是否有解决方法。
谢谢!
最佳答案
根据Mark Setchell的上述评论,以下是在OpenCV中以特定屏幕坐标显示图像的方法(有关所使用的版本,请查看OpenCV文档中的namedWindow()
和moveWindow()
):
# Make your windows
cv2.namedWindow('Raw Image', cv2.WINDOW_NORMAL)
cv2.namedWindow('Partially Processed Image', cv2.WINDOW_NORMAL)
cv2.namedWindow('Processed Image', cv2.WINDOW_NORMAL)
# Get your image and process it
# Then display
cv2.imshow('Raw Image', img)
cv2.imshow('Partially Processed Image', partially_processed_image)
cv2.imshow('Processed Image', processed_image)
# Then move your windows to where you want them
cv2.moveWindow('Raw Image', some_x, some_y)
cv2.moveWindow('Partially Processed Image', some_other_x, some_other_y)
cv2.moveWindow('Processed Image', yet_another_x, yet_another_y)
cv2.waitkey(0)
# Save result and repeat back through for another image
关于python - 您可以使用opencv在特定的屏幕坐标处显示图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62450255/