Sign inSign up

al42and/debian-opencv2

By al42and

•Updated over 8 years ago

Debian stable + OpenCV 2.4 + Python 2.7 + several ways to use graphics

Image
1

920

al42and/debian-opencv2 repository overview

⁠Debian-OpenCV2

This docker image provides latest stable Debian, with OpenCV 2.4 and Python 2.7 installed, plus some of the popular Python packages, plus several ways to use graphics.

⁠Installing Docker

⁠Ubuntu

sudo apt install docker.io
sudo usermod -aG docker $(whoami)

Until you re-login, you will have to prefix all docker commands with sudo.

⁠Windows

Download "Docker Toolbox" from https://www.docker.com/products/docker-toolbox⁠, install it, run "Docker Quick-start Terminal", and let it do its magic.

You can also try "Docker for Windows", which sounds like a better option, but is unsupported on my Windows machine.

⁠Working with this image

First, do docker pull al42and/debian-opencv2:latest to get an image (it's about 1GiB).

If you want to bind host directory within container, use docker run -v $(pwd):/app option or the like. This might cause some problems on Linux due to different user IDs.

⁠Using PyCharm Professional

Open PyCharm, go to Preferences (or File -> Settings) -> Project:yours -> Project Interpreter, and add new Remote Interpreter.

⁠Using Jupyter

docker run -p 9999:9999 -dt al42and/debian-opencv2 run_jupyter

And then open http://localhost:9999/⁠ in your browser

⁠Jupyter and X in Linux (probably MacOS too)

With some minor effort (and a bunch of X11 magic)⁠ we can do the following to pass X socket inside container:

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run -p 9999:9999 -dt -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH -e XAUTHORITY=$XAUTH -e DISPLAY=$DISPLAY al42and/debian-opencv2 run_jupyter

And now we can watch OpenCV videos or use Matplotlib animations⁠ from Jupyter notebook!

⁠Using SSH X-forwarding

docker run -p 2222:22 -dt al42and/debian-opencv2 run_ssh

This way, you have this container running in background. Now, if you're on Linux or Mac, just do ssh -X root@localhost -p2222, with password being 1234.

If you're on Windows, things get more complicated. First, run docker-machine ip default in Docker console to get an IP of a virtual machine Docker uses. Then install Xming⁠ and use its XLaunch tool to connect to this IP, port 2222, username root and password 1234.

⁠Jupyter and X in Windows

Surprisingly, this paragraph is pretty short. First, install Xming and run container as:

docker run -p 2222:22 -dt al42and/debian-opencv2 run_ssh

Then download file tools/run_jupyter.xlaunch from this repository, right-click it and choose edit. XLaunch should open. Accept all default choices, but change host IP to the one returned by docker-machine ip default.

After several seconds it should launch X-server on your machine, and Jupyter in container, with SSH connecting them. Now, open http://localhost:9999/⁠ and rejoice!

⁠Jupyter and X in Linux/MacOS

On Linux it's more efficient to use Unix sockets to connect to X server, but you can go ssh-way if you want:

docker run -p 2222:22 -dt al42and/debian-opencv2 run_ssh
ssh root@localhost -p2222 -L9999:localhost:9999 -Xf run_jupyter &>/dev/null

It start background ssh connection to container, with port 9999 and X forwarding.

⁠Using VNC

docker run -p 5900:5900 -dt al42and/debian-opencv2 run_vnc

Then connect to localhost:5900 using your favorite VNC client. The password is 1234.

⁠Building

docker build -t al42and/debian-opencv2 --no-cache .

⁠Known issues:

  1. Mac OS - Certificate path doesn't exist:
  1. When doing import cv2 you get libdc1394 error: Failed to initialize libdc1394:
  • Ignore it, there's nothing to worry about

Tag summary

Content type

Image

Digest

Size

567.2 MB

Last updated

over 8 years ago

docker pull al42and/debian-opencv2