树莓派debian系统(cm4)中,docker运行onvif2报错,100%修复
·
树莓派debian系统(cm4)中,docker运行onvif2报错:…/ver10/device/wsdl/devicemgmt.wsdl
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
1.完全不依赖网络下载 wget
2.不依赖 GitHub /fastgit
3.WSDL 直接跟着项目打包
4.你的内网环境也能正常构建
第一步:进入一个临时目录(随便哪里)就在刚创的wsdl文件夹
第二步:下载完整 ONVIF WSDL 集合(包含所有 xsd、wsdl),放到代码中,static、log等目录同层级
wget https://github.com/onvif/specs/archive/refs/heads/master.zip
Dockerfile.pi64 内容
from 101.36.128.150:1443/pi64/pi_cm4_base:1.0.0
RUN apt-get update && apt-get install -y \
gcc \
python3-dev \
libxml2-dev \
libxslt-dev \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ Django==3.2.12
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ django-cors-headers
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ djangorestframework
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ django-db-connection-pool==1.2.1
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pycryptodome==3.20
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pycryptodomex==3.20
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ shutilwhich==1.1.0
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ itsdangerous==2.2.0
#### RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ pandas==1.3.5
##### 安装 onvif2(源码安装,绕过镜像源无包问题)
RUN pip3 install -i https://mirrors.aliyun.com/pypi/simple/ \
zeep \
onvif2-zeep
##### 从 code/wsdl 复制到镜像内(你已经放好了)
COPY code/wsdl /usr/local/onvif/wsdl
##### 3. 创建 onvif2 强制需要的路径(硬编码路径修复)
RUN mkdir -p /usr/local/lib/python3.10/site-packages/ && \
ln -s /usr/local/onvif/wsdl /usr/local/lib/python3.10/site-packages/wsdl
RUN apt-get update
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=
ENV TZ=Asia/Shanghai
RUN apt-get install -y tzdata
RUN rm -rf /root/code
COPY code /root/code
CMD [ "/bin/sh","/root/code/start.sh"]
代码 CameraONVIF 类中
def camera_start(self):
"""启动模块 """
wsdl_path = '/usr/local/lib/python3.10/site-packages/wsdl' # 写死这个路径(根据Dockerfile固定)
self.mycam = ONVIFCamera(
self.cam_ip,
self.cam_port,
self.cam_user,
self.cam_password,
wsdl_dir=wsdl_path,
no_cache=True
)
更多推荐
所有评论(0)