Old: Ver. 1 - 3: PTAM on Linux(Ubuntu) with USB camera

Japanese, Casper Cartridges, kameda-lab.org 2010/11/23d, (2012/10/10)

Latest Version

New Casper Cartridge (newer than Ver.3) is ready now.
Access the page from this link.
[Casper Cartridge Top]


Ver.1-3 overview cartridge list why casper? internal set-up OpenCV samples ARToolKit PTAM OpenCV/svn

Abstract

Let's run PTAM on Ubuntu 10.04.1 LTS.

Unfortunately, you cannot install PTAM(r114, 2010/01/29) by just following the instruction on Ubuntu 10.04 LTS Desktop.
In addition, I prefer to run PTAM with USB camera on poor graphic (non-nVidia) PC that may cause faulty errors on compilation and execution.
I fixed these problems here.

You may take easier way of USB boot of Ubuntu 10.04.1 LTS ( + OpenCV2.1.0 + ARToolKit + PTAM).


Preparation

I included original PTAM(r114) in PTAM-linx-go_YYYYMMDD.tgz. You need to make an agreement with their license.
In addition, Dr. Georg Klein wants you to put your names on his site, so you are asked to visit PTAM Web site and put your names at the end of the page.


Install

Extract PTAM-linux-go_YYYYMMDD.tgz somewhere. The content should be:

$ cd
$ tar xvfz PTAM-linux-go_YYYYMMDD.tgz

PTAM-linux-go/PTAM-r114-2010129.zip
PTAM-linux-go/PTAM-linux-go.bash
PTAM-linux-go/PTAM-linux-compileagain.bash
PTAM-linux-go/hack/libcvd/convolution.cc
PTAM-linux-go/hack/gvars3/serialize.h
PTAM-linux-go/hack/PTAM/PTAM-r114-linux.patch
PTAM-linux-go/hack/PTAM/README_PTAM-r114-linux-patch.txt
PTAM-linux-go/hack/PTAM/modified_files/Build/Linux/Makefile
PTAM-linux-go/hack/PTAM/modified_files/Build/Linux/VideoSource_Linux_OpenCV.cc
PTAM-linux-go/hack/PTAM/modified_files/CHANGELOG_kmd.txt
PTAM-linux-go/hack/PTAM/modified_files/CalibImage.cc
PTAM-linux-go/hack/PTAM/modified_files/CalibImage.h
PTAM-linux-go/hack/PTAM/modified_files/CameraCalibrator.cc
PTAM-linux-go/hack/PTAM/modified_files/EyeGame.cc
PTAM-linux-go/hack/PTAM/modified_files/System.cc
PTAM-linux-go/hack/PTAM/modified_files/Tracker.cc
PTAM-linux-go/hack/PTAM/modified_files/Tracker.h
PTAM-linux-go/hack/PTAM/modified_files/main.cc

You need to know root password to install some packages from now.
Internet connection required.
The install directory is set to your home directory's ./PTAM-work. (If you do not like that, change it by yourself)

Are you ready?
Then, move to PTAM-linux-go directory and run the script.
(Or you can go all the steps manually by youself; see the script.)
$ cd
$ cd PTAM-linux-go
$ bash ./PTAM-linux-go.bash

You may need to say "Yes" for some questions (and root password?) for package installation.

Now the compilation is over.
Plug-in your USB camera.
Are you ready?
First, you need to calibrate the camera.
$ cd
$ cd PTAM-work/PTAM/
$ ./CameraCalibrator [-coloron] {number|file|url}
- If you cannot see images (only black screen), try "-coloron".
- If you have multiple cameras, specify the number (0 for default, 1 for second camera, ...)
- If you set a movie file, it will be treated as input.
- If you set a valid URL of feeding movie (e.g. Motion JPEG), it will be treated as input.

After you save camera.cfg, you finally get to run PTAM!
$ ./PTAM [-coloron] [-lightoff] {number|file|url}
- If you cannot see images (only black screen), try "-coloron".
- If you see black eye balls, try "-lightoff".
- If you cannot see images (only black screen), try "-coloron".
- If you have multiple cameras, specify the number (0 for default, 1 for second camera, ...)
- If you set a movie file, it will be treated as input.
- If you set a valid URL of feeding movie (e.g. Motion JPEG), it will be treated as input.


Some Tips

You still need to choose a "right" camera and "right" graphic card.
It should work with ordinally cameras (including many of Logicool cameras) and popular (perhaps cheap) graphic environment (such as Intel integrated chip).

Even in successful cases, you might need to try a couple of times before you can invoke PTAM window, probably because the program sometimes fails on getting image buffer from USB camera.

PC
[Good]
(So far as I tested, most of Desktop PC should be OK if you can boot it by USB)
o Panasonic CF-Y5
o Dell Dimension 9150
o Dell Inspiron 9400
o Dell Latitude 2100
o Fujitsu FMV ESPRIMO D5370
o Asus EeePC901
o SONY VAIO type-F VPCF128FJ
[Option needed]
o Panasonic CF-Y8 (-lightoff)
o Toshiba Dynabook SS RX2 (-lightoff)
o Dell Latitude E4300 (-lightoff)
[NG]
x Any of Mac Books
x Dell Inspiron 6000

Camera
[Good]
o Logicool V-U0010
o Logicool UBK45
o Logicool V-UAR38
o Logicool V-UBM46
o NetCowboy DC-NCP130
o V-Gear TalkCam 1.1
o Buffalo BWC-130H01
o Elecom UCAM-DLX3000B
[NG]
x V-Gear TalkCam Pro


Comment

PTAM-linux-go/PTAM-linux-go.bash
The bold face means that you need root password.
#!/bin/bash
#
# A quick hack to compile PTAM (r114, 2010/01/29) on Ubuntu10.04LTS
# 
#    Many many thanks to Georg Klein
#                 and to Arnaud GROSJEAN
#
# 2010/10/12 Minor Bug Fixed, Patch of PTAM changed
# 2010/10/07 Released 
# 2010/10/02 start writing by Yoshinari Kameda, kameda[at]iit.tsukuba.ac.jp
#

targettopdir=$HOME/PTAM-work
pwdinfo=`pwd`

# OpenCV?
echo "--------------------------------------------------------------"
echo "Do you have OpenCV 2.1.0 ? If not, stop here and prepare that."
echo "(Pausing 10 seconds here)"
echo "--------------------------------------------------------------"
sleep 10

# You may need more?
# Consult "Ubuntu10.04LTS + OpenCV2.1.0 on USB" project by kameda 
echo "----------------------------------------------------------"
echo "You need liblapack-dev freeglut3-dev, and libdc1394-22-dev"
echo "Are you OK? (Pausing 10 seconds here)"
echo "-----------------------------------------------------------"
sleep 10
sudo apt-get install liblapack-dev freeglut3-dev libdc1394-22-dev

export CVS_RSH=ssh

mkdir -p $targettopdir

# TooN
echo "------------------------------------"
echo "Start compiling Toon in 3 seconds..."
echo "------------------------------------"
sleep 3
pushd $targettopdir
cvs -z3 -d:pserver:[email protected]:/sources/toon co -D "Mon May 11 16:29:26 BST 2009" TooN
cd TooN
./configure
sudo make install
popd

# libcvd
echo "--------------------------------------"
echo "Start compiling libcvd in 3 seconds..."
echo "--------------------------------------"
sleep 3
pushd $targettopdir
cvs -z3 -d:pserver:[email protected]:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" libcvd
cd libcvd
mv cvd_src/convolution.cc cvd_src/convolution.cc-original
cp $pwdinfo/hack/libcvd/convolution.cc cvd_src/convolution.cc
export CXXFLAGS=-D_REENTRANT
./configure --without-ffmpeg
make
sudo make install
popd

# gvars3
echo "---------------------------------------"
echo "Start compiling gvars3 in 3 seconds ..."
echo "---------------------------------------"
sleep 3
pushd $targettopdir
cvs -z3 -d:pserver:[email protected]:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" gvars3
cd gvars3
mv gvars3/serialize.h gvars3/serialize.h-original
cp $pwdinfo/hack/gvars3/serialize.h gvars3/serialize.h
./configure --disable-widgets
make
sudo make install
popd

# before you go further, re-arrange the dynamic libraries
sudo ldconfig

# PTAM main
echo "--------------------------------------"
echo "Start compiling PTAM in 10 seconds ..."
echo "YOU NEED TO AGREE WITH THEIR LICENSE !"
echo "--------------------------------------"
sleep 10
pushd $targettopdir
unzip $pwdinfo/PTAM-r114-2010129.zip
patch -p0 -d . < $pwdinfo/hack/PTAM/PTAM-r114-linux.patch
cd PTAM
cp Build/Linux/* .
make

# Tips at end
echo "----------------"
echo "Is the camera ready?"
echo "Let's go to $HOME/PTAM-work/PTAM "
echo "You need to first run ./CameraCalibrator"
echo "and save a camera config file."
echo "Then, you can enjoy ./PTAM !"
echo "----------------"

exit 0

(KAMEDA, Yoshinari) kameda[at]iit.tsukuba.ac.jp, kameda[at]ieee.org