我正试图通过docker将opencv连接到macos主机中的外部显示器。我用的是x石英和socat:
open -a XQuartz
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"所以它正确地听着:
ip-192-168-1-168:workoutdj loretoparisi$ lsof -i TCP:6000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
socat 40381 loretoparisi 5u IPv4 0x9d69a8efeca8e83f 0t0 TCP *:6000 (LISTEN)然后(在不同的窗口中运行),我尝试了不同的方法将显示连接到码头:
docker run -e DISPLAY=host.docker.internal:0 --rm -it -v $(pwd):/app facemaskdetect bash
$ python facemaskdetect/detector.py -i examples/example_01.png -o cam
[INFO] computing face detections...
No protocol specified
: cannot connect to X server host.docker.internal:0或者:
docker run -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --rm -it -v $(pwd):/app facemaskdetect bash
$ python facemaskdetect/detector.py -i examples/example_01.png -o cam
[INFO] computing face detections...
: cannot connect to X server /private/tmp/com.apple.launchd.qIcIi1ayqO/org.macosforge.xquartz:0我也尝试过通过这个通过xhost跟踪
export IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost +$IP
xhost +local:docker
docker run --rm -it -e DISPLAY=$IP:0 -e XAUTHORITY=/.Xauthority --net host -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.Xauthority:/.Xauthority -v $(pwd):/app facemaskdetect bash
$ python facemaskdetect/detector.py -i examples/example_01.png -o cam
[INFO] computing face detections...
: cannot connect to X server :0发布于 2020-06-29 05:20:32
因为方法二使用$IP,所以可以将它绑定到socat以访问X11显示。socat TCP-LISTEN:6000,bind=$IP,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
https://stackoverflow.com/questions/62540669
复制相似问题