【发布时间】:2022-11-28 00:49:14
【问题描述】:
我一直试图用 OpenCV 拍照,但 imshow() 返回的是一张彩色图像。 它不返回任何错误。
import cv2
from time import sleep
camera = cv2.VideoCapture(0)
ret, frame = camera.read()
sleep(1)
cv2.imshow("frame", frame)
cv2.waitKey(0)
cv2.imwrite("image.jpg", frame)
cv2.destroyAllWindows()
Here is the window created while running this code
我的摄像头完全可以与其他程序和 python 程序一起使用,但我无法完成这项工作。 我试过更改摄像头端口、重新运行 pycharm 甚至重新启动我的计算机和摄像头,但效果不佳。 当我尝试使用 imwrite() 保存图像时,它也不起作用。
帮助?
【问题讨论】: