Build PTAM on Ubuntu

Install TooN

git clone https://github.com/edrosten/TooN.git toon
cd toon
./configure --prefix=$HOME
make install

Install libCVD

Install the dependency first:

sudo apt-get install libdc1394-22-dev libv4l-dev
(cd /usr/include/linux && sudo ln -s ../libv4l1-videodev.h videodev.h)
git clone https://github.com/edrosten/libcvd.git libcvd
cd libcvd
CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME
# or CXXFLAGS=-D_REENTRANT ./configure --without-ffmpeg --prefix=$HOME --disable-fast7
vi cvd_src/image_io/jpeg.cxx
# at lines 160 and 189: replace `true' with `(boolean)1'
# at line 253: replace `true' with `(boolean)1'
# at line 339: replace `1' with `(boolean)1'
make -j8
make install

Install GVars

Install the dependency:

sudo apt-get install libreadline6-dev
git clone https://github.com/edrosten/gvars.git gvars
cd gvars
./configure --disable-widgets --prefix=$HOME
make -j8
make install

Build PTAM

Build it:

git clone https://github.com/Oxford-PTAM/PTAM-GPL.git ptam
cd ptam
git checkout Linuxmint15
cd Src
vi Makefile
# modify the include and lib paths in the Makefile
# make depend
make -j12

Run it:

./CameraCalibrator
# calibrate the camera
cp camera.cfg settings.cfg
./PTAM
# track!

PTAMM

Build PTAM on Ubuntu

Image sequence to a video clip on Linux

using ffmpeg in an essential form:

ffmpeg -start_number n -i test_%d.jpg -vcodec mpeg4 test.avi

with more control:

ffmpeg -f image2 -framerate 25 -pattern_type sequence -start_number 1234 -r 3 -i img_%04d.jpg -s 720x480 test.avi

using mkmpeg4 script, which requires mplayer on Linux:

mkmpeg4 -o output.avi -f 30 `ls *.png`

references:
http://www.shawnlankton.com/2007/04/videos-in-matlab-and-linux/
http://geodynamics.org/svn/cig/seismo/3D/SPECFEM3D/trunk/utils/Visualization/GMT/grenoble_basin_GMT_movies/mkmpeg4.py
http://superuser.com/questions/624567/ffmpeg-create-a-video-from-images

Image sequence to a video clip on Linux

tar: cannot mkdir permission denied

tar, by default, should handle the restoration of directory permissions correctly so that the files can be extracted within subdirectories as well as the original permissions of those subdirectories are restored as in the archive, but sometimes it fails. It might be when extracting from an incrementally created archive.

tar xf ../r2013b.tar
...
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/tablelayout_common_1372719204.xml: Cannot open: No such file or directory
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/._tex-archive_common_1360092817.enc: Cannot open: No such file or directory
tar: r2013b/archives/common: Cannot mkdir: Permission denied
tar: r2013b/archives/common/3p/tex-archive_common_1360092817.enc: Cannot open: No such file or directory
...

Then it’s required to have tar to delay the permission restoration after extracting all files by giving --delay-directory-restore option:

tar -x --delay-directory-restore -f ../r2013b.tar

See this for the default behaviour of tar.

tar: cannot mkdir permission denied

Multiple NVidia graphics cards in Ubuntu

Two NVidia GTX/GT graphics cards + two monitors + Intel motherboard + Ubuntu 12.04 + 64 bit Nvidia driver + CUDA installation

Disconnect the secondary one of the two monitors.

Select the primary video adaptor in BIOS setup. If the BIOS persists not to change the order, try to change it to automatic or something else, then to change it to manual with your favoured order in the next reboot.

This ensures that you have POST messages and tty1–6 consoles displayed in your primary graphics card correctly.

Update xorg.conf. nvidia-settings can do it for you. Ensure that:
you have a “Device” section which identifies correctly the graphics card you want to use for X11.
This will have your X11 server use the graphics card you want.

Install the graphics card driver in the following order.

Download the suitable graphics card driver and the CUDA toolkit in the following pages, both the .run installers.

EDIT: Check which version of gcc was used to build the kernel:

cat /proc/version

Set compiler version the same as that used to compile kernel:

sudo update-alternatives --config gcc

or

export CC=/usr/bin/gcc-x.x

If you’re in GUI environment, press ctrl-alt-F1 to change to a tty console.

Stop X server:

sudo service lightdm stop

Remove the old NVidia driver:

sudo apt-get remove nvidia-*

Remove the nouveau driver which causes problems with maya and potentially with other software:

sudo apt-get remove xserver-xorg-video-nouveau

If you installed the driver without using apt-get you may need:

sudo /usr/bin/nvidia-uninstall

Remove the NVidia kernel module:

sudo dkms remove -m nvidia -v <version> --all

To identify the kernel module that’s running:

lsmod | grep nvidia
find /lib/modules | grep nvidia

To get more info about the kernel module:

modinfo <module name>

nvidia apt-get uninstaller removes kernel modules, so better reboot before checking it.

Install the driver—run the downloaded graphics card driver (the .run file):

sudo sh ./NVIDIA-Linux-x86_64-<version>.run

After installing the driver, remove xorg.conf file:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Set your gcc version back if you had to change it for the driver compilation:

sudo update-alternatives --config gcc

Reboot:

sudo reboot

Install CUDA—run the downloaded CUDA toolkit .run installer:

sudo sh ./cuda_<version>_linux_64.run

During the installation, do not install the driver, but only the CUDA toolkit and sample code.

After the installation add path and library path.

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Connect the second monitor.

Failed to run `/usr/sbin/dkms add -m nvidia -v 331.20 -k 3.2.0-57-generic`: Error! DKMS tree already contains: nvidia-331.20 You cannot add the same module/version combo more than once.

References:
http://ubuntuforums.org/archive/index.php/t-2020648.html
http://ubuntuforums.org/showthread.php?t=1036788
http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-linux/index.html#runfile-installation

Multiple NVidia graphics cards in Ubuntu