【发布时间】:2021-07-14 09:22:34
【问题描述】:
我正在编写一个简单的 Opencv 代码,它可以捕获图像并向我们展示。但是每当我运行它时,它都会告诉无法使用此索引访问相机。
我尝试使用此命令运行我的 docker 文件 docker run -ti --device /dev/video0:/dev/video0 pradyumn10/ubuntu-python3 /bin/bash 这会打开相机一秒钟,然后将其关闭并给出错误“无法显示”
【问题讨论】:
-
请分享您是如何启动此容器(哪些参数)以及可能是 Dockerfile 本身。
-
@Yaron 我没有制作 docker 文件,我只是提取了一个 ubuntu 的图像并运行它,然后我使用“apt install python3-opencv”在其中安装了 opencv 我的代码:import cv2 cam=cv2。 VideoCapture(0) while True: _, frame= cam.read() if frame is not None: cv2.imshow("frame",frame) cam.release()