Docker container files update for RGBDemo

ScanMarks-ItWorks

I was able to determine it was the Sensor driver package which was causing my point cloud vs RGB image offset so using the latest v5.1.6.6 is another binary package installed via the resources directory of the Docker project. My doit-rgbdemo script handles getting these packages off the internet and extracting them so they are ready to be installed once the Dockerfile starts getting used to build the image.  I create a new user in the image with the userID of ‘docker’ and passwd of ‘docker’. The password would come in handy if you want to use ‘sudo’ to install anything later.  I’ve also added access to /dev/dri so you can get OpenGL optimized rendering for 3D.
So here are the two files, doit-rgbdemo and Dockerfile, put them in a director of their own, make doit-rgbdemo executable( chmod +x doit-rgbdemo ) and run it. After a bit you will have a new Docker image created called “rgbdemo/openni” and you should see an xterm pop up on your desktop waiting for you to run something. Change into the /home/docker/rgbdermo/build/bin directory and try running ./rgbd-viewer after plugging in your ASUS Xtion Pro Live camera.
doit-rgbdemo:
#!/bin/bash

# Creates a Docker image for running RGBDemo( /home/docker/rgbdemo/build/bin ) programs for 3D vision and capture using the
# ASUS Xtion Pro Live camera( might work with kinect ). It builds the image based on commands in the Dockerfile file and
# then starts an xterm controlled by the default user( userID=docker passwd=docker ).
# You'll find the rgbdemo package installed in the /home/docker director and the executable applications are in build/bin.
# OpenNI and PCL are installed so there are samples for those installed to. Look for NiViewer and Sample-Ni...... progs to run.
# 
# Installing various required packages into the Docker resources for installation into the container without including
# the compressed file or even the expanded installation directory using files in the resources' directory in the hosts Docker 
# directory. There are three packages needed, the OpenNI, NiTE and Sensor packages. After those packages are setup in the
# resources director, the Docker image is created or started
#
HERE=`pwd`
mkdir -p resources
if [ ! -e resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.bz2 ]
then
  echo "doesn't Exist bz2"
  if [ ! -e resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.zip ]
  then
    echo "doesnt Exist zip"
    cd resources
    wget http://www.openni.ru/wp-content/uploads/2013/11/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.zip
    cd $HERE
  fi
  echo "unzip and remove zip"
  unzip resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.zip -d resources
  rm -rf resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.zip
  # Final check to make sure we have the NiTE installation file
  if [ ! -e resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.bz2 ]
  then
    echo "ERROR: OpenNI install file doesn't exist.... EXIT!"
    exit
  fi
fi
if [ ! -e resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.bz2 ] 
then
  echo "doesn't Exist bz2"
  if [ ! -e resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip ] 
  then
    echo "doesnt Exist zip"
    cd resources
    wget http://www.openni.ru/wp-content/uploads/2013/10/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip
    cd $HERE
  fi
  echo "unzip and remove zip"
  unzip resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip -d resources
  rm -rf unzip resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip
  # Final check to make sure we have the NiTE installation file
  if [ ! -e resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.bz2 ] 
  then
    echo "ERROR: NiTE install file doesn't exist.... EXIT!"
    exit
  fi
fi
if [ ! -e resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.bz2 ]
then
  echo "doesn't Exist bz2"
  if [ ! -e resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.zip ]
  then
    echo "doesnt Exist zip"
    cd resources
    wget http://www.openni.ru/wp-content/uploads/2013/11/Sensor-Bin-Linux-x64-v5.1.6.6.tar.zip
    cd $HERE
  fi
  echo "unzip and remove zip"
  unzip resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.zip -d resources
  rm -rf resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.zip
  # Final check to make sure we have the NiTE installation file
  if [ ! -e resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.bz2 ]
  then
    echo "ERROR: Sensor Driver install file doesn't exist.... EXIT!"
    exit
  fi
fi

CONTAINER="rgbdemo/openni"

# check if the image exists and build it if it doesn't, otherwise setup and run it
#RUNNING=$(sudo docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
RUNNING=$(docker inspect --format="{{ .State.Running }}" $CONTAINER 2> /dev/null)
if [ $? -eq 1 ]; then
  echo "$CONTAINER does not exist."
  echo "creating $CONTAINER."

  #create the container using the Docker File debDockerFile-xterm
  #it's based on the default debian container
  #
  #sudo docker build -t rgbdemo/openni . 
  docker build -t $CONTAINER . 
fi

# create the var to pass to docker linking host file X0 to container file X0
# USB bus for USB devices
# Direct Rendering Interface to GPU DRI for 3D acceleration
XSOCK=/tmp/.X11-unix/X0
VBUS=/dev/bus/usb
VDRI=/dev/dri

# run the xterm xapp container
# -i keeps stdin open
# -t creates a psuedo tty
#docker run -u docker --privileged -it -v $XSOCK:$XSOCK -v $VBUS:$VBUS -v $VDRI:$VDRI $CONTAINER
docker run --privileged -it -v $XSOCK:$XSOCK -v $VBUS:$VBUS -v $VDRI:$VDRI $CONTAINER
Here is the Dockerfile:
FROM ubuntu

# quiets down mesg to console about TERM not being set
ENV TERM linux
USER root

RUN apt-get update \
	&& apt-get install -qqy \
	openssh-client \
	wget \
	git \
	gawk \
	libusb-1.0-0-dev \
	freeglut3-dev \
	openjdk-7-jdk \
	doxygen \
	graphviz \
	software-properties-common \
	cmake build-essential \
	xterm

# install OpenNI 
ADD resources/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10.tar.bz2 /tmp
RUN cd /tmp/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10 \
	&& ./install.sh
RUN rm -rf /tmp/OpenNI-Bin-Dev-Linux-x64-v1.5.7.10

# getting ROS packages because they contain all the openni,opencv/pcl goodness needed
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
RUN wget http://packages.ros.org/ros.key -O - | apt-key add -
RUN apt-get update \
	&& apt-get install -qqy \
	ros-indigo-perception-pcl \
	ros-indigo-vision-opencv

RUN add-apt-repository --yes ppa:xqms/opencv-nonfree
RUN apt-get update \
	&& apt-get install -qqy \
	libopencv-nonfree-dev

# if UsbInterface is commented out, remove the comment char and flag(DJL) as changed
RUN sed -i '/;UsbInterface=2/c\UsbInterface=2;DJL' /etc/openni/GlobalDefaults.ini

# install NiTE middleware
ADD resources/NITE-Bin-Linux-x64-v1.5.2.23.tar.bz2 /tmp
RUN cd /tmp/NITE-Bin-Dev-Linux-x64-v1.5.2.23 \
	&& ./install.sh
RUN rm -rf /tmp/NITE-Bin-Dev-Linux-x64-v1.5.2.23

# install Sensor Driver 
ADD resources/Sensor-Bin-Linux-x64-v5.1.6.6.tar.bz2 /tmp
RUN cd /tmp/Sensor-Bin-Linux-x64-v5.1.6.6 \
	&& ./install.sh
RUN rm -rf /tmp/Sensor-Bin-Linux-x64-v5.1.6.6 

# add a user and add the user to the sudoers list
RUN useradd -ms /bin/bash docker
RUN sed -i '/root\tALL/i\docker\tALL=(ALL:ALL) ALL' /etc/sudoers \
	&& echo 'docker:docker' | chpasswd
USER docker

# get rgbdemo
RUN cd /home/docker \
	&& git clone --recursive https://github.com/rgbdemo/rgbdemo.git
RUN cd /home/docker/rgbdemo \
# fix linux_configure.sh to use OpenNI not OpenNI2
	&& sed -i '/\$\*/i\    -DNESTK_USE_OPENNI2=0 \\' linux_configure.sh \
#edit scan_markers/ModelAcquisitionWindow.cpp, comment out line 57,58,59,60,61
	&& cd scan-markers \
	&& gawk '/if \(!m_controller/, c==4 {$0 = "//" $0; c++} { print }' ModelAcquisitionWindow.cpp > /tmp/tmpfile \
	&& cp /tmp/tmpfile ModelAcquisitionWindow.cpp
RUN  cd /home/docker/rgbdemo \
	&& ./linux_configure.sh \
	&& cd build \
	&& make


# get rules.d file
#/etc/udev/rules.d/55-primesense-usb.rules


ENV DISPLAY :0
#because some gui widgets were not loading
ENV QT_X11_NO_MITSHM 1

USER docker
CMD xterm
#CMD NiViewer

5 thoughts on “Docker container files update for RGBDemo

  1. Hello!
    Thank you for your sharing!
    But I met some problem! Look forward to your help!
    I want to know the version of ubuntu system, because I can’t some software!

    Step 13/32 : RUN add-apt-repository ppa:xqms/opencv-nonfree
    —> Using cache
    —> 53ad82037df1
    Step 14/32 : RUN apt-get update
    —> Using cache
    —> cbf924837874
    Step 15/32 : RUN apt-get install -f libopencv-nonfree-dev
    —> Running in 341839044fff
    Reading package lists…
    Building dependency tree…
    Reading state information…
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    libopencv-nonfree-dev : Depends: libopencv-features2d-dev (= 2.4.8+dfsg1-2ubuntu1xqms1~trusty1) but 2.4.8+dfsg1-2ubuntu1.2 is to be installed
    Depends: libopencv-nonfree2.4 (= 2.4.8+dfsg1-2ubuntu1xqms1~trusty1) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    Like

    1. the article was posted in 2015 so it is likely it was ubuntu 14.02 as I tend towards using the LTS version but since the Dockerfile only states “from ubuntu” it could have pulled down the 15.xx version. But I would start with ubuntu 14.02.

      Like

    2. wait, looking further at the Dockerfile it states modifying apt’s sources.list file and says Trusty so therefore is Trusty Tahr which I just verified is 14.04.

      Like

    3. in the Dockerfile change:
      FROM ubuntu
      to:
      FROM ubuntu:14.04

      You will also have to find any files which are no longer at the remote URLs listed. For example, I found out that the NITE-Bin-Linux-x64-v1.5.2.23.tar.zip was not at the RU site but found it on another site. So I changed the wget line in doit-openni script as follows:

      #old wget http://www.openni.ru/wp-content/uploads/2013/10/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip
      wget http://cvrlcode.ics.forth.gr/web_share/OpenNI/NITE_SDK/NITE_1.x/NITE-Bin-Linux-x64-v1.5.2.23.tar.zip

      Like

    4. I’ve hit the same opencv nonfree error after fixing the version to 14.4 and fixing the NITE url.

      Not sure what the solution is. Even this git repo about using the same opencv nonfree mentioned dependency issues:

      I got:

        apt: command [sudo -H apt-get install -y libopencv-nonfree2.4] failed
      

      When using rosdep

      rosdep install --from-paths src --ignore-src --rosdistro=indigo -y
      

      To solve it:

      sudo add-apt-repository --yes ppa:xqms/opencv-nonfree
      sudo apt-get update
      sudo apt-get install libopencv-nonfree-dev
      

      The rosdep key was opencv2-nonfree.

      let me know if you find a solution.

      Like

Leave a comment