Connecting to camera(s) in Docker
이 페이지에서는 Docker에서 사용자 정의 IP 주소를 사용하여 하나 이상의 카메라에 연결하는 방법을 설명합니다.
참고
계속하기 전에 호스트 컴퓨터에서 Network Configuration 구성했는지 확인하세요.
참고
These instructions are independent of the compute backend. See Install Zivid in Docker for the OpenCL and CUDA backend options and which one to use for your host.
Docker uses the bridge network driver by default, which does not allow multicast traffic.
This means multicast DNS (mDNS) network discovery is unavailable, and only cameras with default IP 172.28.60.5 can be discovered without further configuration.
There are three ways to work around this.
If you know the IP address or hostname of the camera, you can connect to it directly without relying on mDNS discovery.
Pass a CameraAddress to connectCamera, as described in Capture Tutorial.
This is the simplest option when you are connecting to a specific camera at a known address.
간단한 해결책은 호스트 네트워크를 Docker 컨테이너에 노출하는 것입니다. Docker 컨테이너를 실행할 때 다음과 같이 --network=host 을 활성화하면 됩니다.
sudo docker run --interactive --tty --device=/dev/dri --network=host <image>
여기서 <image> 는 컨테이너를 시작하는 Docker 이미지입니다. 이렇게 하면 모든 호스트 네트워크 인터페이스가 컨테이너에 노출됩니다.
참고
This works on native Linux, where the host network reaches the camera directly.
On Windows, Docker Desktop runs containers in the WSL virtual machine.
There, --network=host exposes that virtual machine’s network, not the Windows host network, so mDNS discovery does not find the camera.
The camera is still reachable by IP address, so on Windows connect by IP address or hostname instead.
Zivid SDK는 Cameras.yml 파일을 사용하여 mDNS 대신 특정 IP 주소를 검색할 수 있습니다. 작동 방식에 대한 자세한 내용은 Cameras.yml and how to restrict discoverable cameras 참조하세요. 기본 IP가 아닌 카메라를 검색하려면 Dockerfile에 다음을 추가하세요.
ENV ZIVID_CONFIG=/root/.config/Zivid/API/Cameras.yml
RUN mkdir --p $(dirname $ZIVID_CONFIG)
RUN echo "__version__: 1" >> $ZIVID_CONFIG
RUN echo "Cameras:" >> $ZIVID_CONFIG
RUN echo " NetworkCameras:" >> $ZIVID_CONFIG
RUN echo " - NetworkCamera:" >> $ZIVID_CONFIG
RUN echo " Host: 172.28.60.5" >> $ZIVID_CONFIG
RUN echo " - NetworkCamera:" >> $ZIVID_CONFIG
RUN echo " Host: 172.28.60.6" >> $ZIVID_CONFIG
RUN echo " - NetworkCamera:" >> $ZIVID_CONFIG
RUN echo " Host: 172.28.60.7" >> $ZIVID_CONFIG
Host 필드를 변경하여 특정 IP 주소로 카메라를 검색하거나, 다른 NetworkCamera 를 추가하세요. 변경 사항을 적용하려면 Docker 이미지를 다시 빌드하세요.
다음을 실행하여 Docker 컨테이너에서 연결된 모든 카메라를 검색할 수 있는지 확인합니다.
ZividListCameras