【问题标题】:How can i access camera module from iotedge module using azure IOTEDGE如何使用 azure IOTEDGE 从 iotedge 模块访问相机模块
【发布时间】:2021-10-14 15:13:39
【问题描述】:

我在我的 docker 文件中使用以下代码进行视频流传输

import numpy as np
import cv2
cap = cv2.VideoCapture(0)
# Define the codec and create VideoWriter object
#fourcc = cv.VideoWriter_fourcc(*'XVID')
total_frame=0
while cap.isOpened():
    ret, frame = cap.read()
    print(ret)
    if not ret:
        print("Can't receive frame (stream end?). Exiting ...")
        break
    #frame = cv.flip(frame, 0)

    #video_writer = cv2.VideoWriter(time_string, fourcc, 30.0, (1280, 720))
    # write the flipped frame


# Release everything if job is finished
cap.release()
#cv2.destroyAllWindows()

`

我在上面的代码中使用这个 dockerfile

FROM ubuntu

# Install dependencies
RUN apt-get update && \
  apt-get install -yq \ 
    python3 \
    python3-pip \   
  && apt-get clean && rm -rf /var/lib/apt/lists/*


RUN pip3 install --upgrade pip 
RUN pip3 install imutils
RUN pip3 install azure-iot-device
RUN pip3 install opencv-contrib-python

WORKDIR /main/

COPY main .

CMD ["python3", "/main/main.py"]

我可以使用 docker run --device /dev/video0 image 访问主机上的视频源 但是当我将它部署为 IOTEDGE 模块时我无法访问相机?请告诉我如何从主机系统上的 iotedge 模块访问视频源。cv2.VideoCapture(0) 的位置是 cv2.VideoCapture('/dev/video0' )

【问题讨论】:

    标签: python azure docker azure-devops azure-iot-edge


    【解决方案1】:

    对于任何容器,包括 IoT Edge 模块,您都需要向容器公开 /dev/videoX。对于 IoT Edge 模块,这是通过容器创建选项完成的。

    在此处搜索 /dev/video0:https://kevinsaye.wordpress.com/2018/04/16/creating-an-opencv-module-for-iot-edge/ 以了解它是如何完成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多