4/20/2016

Add Singleton Pattern to AndroidStudio Live Templates

AndroidStudio provides Live Templates to increase productivity for Android developers.

You can complete and insert code snippets into your code by typing their abbreviation and pressing tab. You can see and change those settings in the Editor section of the Preferences.


You can add your own templates. E.g. I add Singleton pattern, thus I can implement and add Singleton Pattern in a class quickly by type my defined abbreviation('singleton').


abbreviation : singleton 
description : Generate Singleton template for the current class
template text:
private $class$() {
    
}

private static class $class$LazyHolder {
   private static final $class$ INSTANCE = new $class$();
}

public static $class$ getInstance() {
   return $class$LazyHolder.INSTANCE;
}

Remember to let it be applicable in Java

Finally, in your java editor




3/19/2016

The list of vision-based SLAM / Visual Odometry open source and papers

RGB(Monocular)

LSD-SLAM
Source : https://github.com/tum-vision/lsd_slam
Publications :
LSD-SLAM: Large-Scale Direct Monocular SLAM, J. Engel, T. Schöps, D. Cremers, ECCV '14 
Semi-Dense Visual Odometry for a Monocular Camera, J. Engel, J. Sturm, D. Cremers, ICCV '13
Available on ROS : Yes

ORB-SLAM
Source : https://github.com/raulmur/ORB_SLAM
Website: http://webdiis.unizar.es/~raulmur/orbslam/
Publications : ORB-SLAM: A Versatile and Accurate Monocular SLAM System
Available on ROS : Yes


Nister's Five Point Algorithm for Essential Matrix estimation, and FAST features, with a KLT tracker
Source : https://github.com/avisingh599/mono-vo
Website: http://avisingh599.github.io/vision/monocular-vo/
Publications: http://avisingh599.github.io/assets/ugp2-report.pdf
Available on ROS : No

RGB-D

OpenCV RGBD-Odometry (Visual Odometry based RGB-D images)

Dense Visual SLAM for RGB-D Cameras
Available on ROS : Yes

RTAB MAP - Real-Time Appearance-Based Mapping

Useful third parties

Basic library
OpenCV
Eigen
Sophus
ROS
PointCloud

Loop detection
dorian3d

Graph Optimization
ceres-solver
g2o
gtasm
Vertigo

Map library
Grip Map 
OmniMapper 
OctoMap

Other useful references

Openslam : Introduce some other SLAM systems and open sources
Kintinuous : Real-time large scale dense visual SLAM system
InfiniTAM : A Framework for the Volumetric Integration of Depth Images
ElasticFusion : Real-time dense visual SLAM system

RGB-D dataset download

TUM Universtiy 

KTTI Vision benchmark


RGB-D tools

https://vision.in.tum.de/data/datasets/rgbd-dataset/tools

2/25/2016

Ubuntu 解決標楷體問題

安裝ubuntu14.04時, 如果選擇英語語系, 會幫你安裝中文套件, 預設字體是標楷體

解決方法;
   $ sudo vim /etc/fonts/conf.d/69-language-selector-zh-tw.conf

然後分別加入

<string>WenQuanYi Zen Hei</string>
<string>WenQuanYi Micro Hei</string>
<string>WenQuanYi Micro Hei Mono</string>


2/23/2016

Dense Visual SLAM for RGB-D Cameras ( dvo_slam setups )

What is DVO SLAM

Requierements

Software: Ubuntu 12.04 using ROS Fuerte or Ubuntu 14.04 using ROS Indigo
Hardware: RGB-D cameras like RealSense r200, Asus Xtion, Kinect, etc.

(Optional)
If you use ubuntu 12.04 with ROS Fuerte and camera is Kinect or Xtion, you have to setup your camera first.

$ lsusb–v
$ sudo apt-get install ros-fuerte-openni-kinect

if it is 0601 not 0600(old verison)

$ sudo apt-get install --reinstall libopenni-sensor-primesense0
$ sudo gedit /etc/openni/GlobalDefaults.ini

Set `UsbInterface=2`

$ sudo reboot

After reboot, launch openni script, it will open your camera
$ roscore

$ roslaunch openni_launch openni.launch
Use image_view tool to see your RGB and depth images
$ rosrun image_view image_view image:=/camera/rgb/image_color

$ rosrun image_view image_view image:=/camera/depth/image

Clone the source

$ git clone https://github.com/jefftee/dvo_slam.git
$ rosmake dvo_core dvo_ros dvo_slam dvo_benchmark


Ubuntu 12.04 using ROS Fuerte:
$ git clone -b fuerte https://github.com/tum-vision/dvo_slam.git
or clone it from my repository (I add some launch files)
$ git clone -b fuerte git@bitbucket.org:TzuTaLin/dvo_slam.git
Build it

$ export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/dvo_slam

$ sudo apt-get install ros-fuerte-libg2o liblapack-dev libblas-dev freeglut3-dev libqglviewer-qt4-dev libsuitesparse-dev libx11-dev

$ rosmake dvo_core dvo_ros dvo_slam dvo_benchmark
Clean
$ roscd your_package_name && make clean
Run keyframe tracker
$ rosrun dvo_slam camera_keyframe_tracker

Run tracker without keyframe
$ rosrun dvo_ros camera_tracker

Run and show configure, and Visualize
$ roslaunch dvo_slam qucikstart.lauch

Run benchmark
Download the dataset:
http://vision.in.tum.de/rgbd/dataset/freiburg1/rgbd_dataset_freiburg1_xyz.tgz

Extract it and go the folder
$ associate.py rgb.txt depth.txt > assoc.txt

You can download the tool from https://vision.in.tum.de/data/datasets/rgbd-dataset/tools

Than in the dataset folder,  run: 
$ roslaunch dvo_benchmark benchmark.launch keep_alive 
or
$ roslaunch dvo_benchmark benchmark.launch

Debug (Optional)
$ rosrun rqt rq

Change the name for registerd topics (Optional)

Dataset download

http://vision.in.tum.de/data/datasets/rgbd-dataset/download
http://alexteichman.com/octo/clams/

References:

http://www.alexteichman.com/octo/clams/
https://github.com/tum-vision/dvo_slam/issues/5
https://github.com/tum-vision/dvo_slam/issues/6
https://github.com/tum-vision/dvo_slam/issues/31
http://wiki.ros.org/rviz/Tutorials/Interactive%20Markers%3A%20Getting%20Started
http://blog.csdn.net/jasmine_shine/article/details/46444603

SLAM Tools:

http://vision.in.tum.de/data/datasets/rgbd-dataset/tools#evaluation
https://vision.in.tum.de/data/datasets/rgbd-dataset/tools


1/22/2016

Build and install OpenCV and contrib lib on Ubuntu / Android


I am going to show you how to clone the opencv source from Git repository. After cloing the source, I will build and install it.

Build for ubuntu

Download the source of opencv and opencv_contrib from github and checkout to the tag, 3.1.0:
cd ~/<my_working _directory>
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
cd ~/<my_working _directory>/opencv
git checkout -b 3.1.0 3.1.0
cd ~/<my_working _directory>/opencv_contrib
git checkout -b 3.1.0 3.1.0

Use cmake: 
cd opencv
mkdir release
cd release
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

If your environment contains CUDA, by default, it will build it with CUDA. If you don't want to build it with CUDA,  add -DWITH_CUDA=OFF to your cmake command line.

Start to build and install to /usr/local/include and /usr/local/lib. You can change the installed dir by change CMAKE_INSTALL_PREFIX
make -j8 # -j8 runs 8 jobs in parallel.
         # Change 8 to number of hardware threads available.
sudo make install

You can check your current opencv version:
$ pkg-config --modversion opencv

It will be 3.1.0 !

You can also look at the headers or libs installed. Using pkg-config can tell you where they are: 
$ pkg-config --cflags opencv
$ pkg-config --libs opencv

Actually, you can use the latest stable OpenCV version available in sourceforge without building the source.

How to speed up building process?
You can use Ninja to speed up instead of using Makefile
cd opencv
mkdir release
cd release
cmake -G Ninja -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
ninja -j8
ninja install

Build for Android version:

export ANDROID_NDK=[YourNDKPath]
cd ~/<my_working _directory>git clone https://gist.github.com/tzutalin/f07f5633fd599001101006561689062b
sh build-android-opencv.sh

You can change your target API in build_android_opencv.sh. For example, you can build the target for arm by changing the variable, ANDROID_ABI, in build_android_opencv.sh which you clone from the above commands.






The final output will be installed and located in ~/<my_working _directory>/android_opencv/

Alternatively, you can refer to https://github.com/tzutalin/build-opencv-for-android

References:
http://code.opencv.org/projects/opencv/wiki/Building_OpenCV4Android_from_trunk
http://docs.opencv.org/3.1-beta/doc/tutorials/introduction/linux_install/linux_install.html
https://github.com/Itseez/opencv/wiki/Building_OpenCV4Android_from_trunk
https://github.com/alexkarargyris/Caffe_OpenCV_Android_App


12/21/2015

Use Xtion on ROS indigo

Environment: ROS indigo and Ubuntu 14.04

Note:
If using usb 3.0 or above, should turn it down in BIOS(Advance->USB->xhci) disable xhci

 Install dependencies:
$ sudo apt-get install ros-indigo-rgbd-launch ros-indigo-openni2-camera ros-indigo-openni2-launch

Install package rqt and useful plugins: sudo apt-get install ros-indigo-rqt ros-indigo-rqt-common-plugins ros-indigo-rqt-robot-plugins

 Open Terminal 1
$ roscore

 Open Terminal 2: launch openni2.launch
$ roslaunch openni2_launch openni2.launch

 Open Terminal 3: Open RVIZ to visualize
$ rosrun rviz rviz
Show the depth image by adding its topic


Finally, show IR, Depth, RGB image, and point cloud by adding all of their topics in Rviz:



You can also try my Gist:
https://gist.github.com/tzutalin/175776fe02a9496a7778

11/11/2015

Object detection and recognition on mobile device (Android)



Object detection and recognition on mobile device


   Few months ago, I had implemented Object detection algorithm (FastRCNN and FasterRCNN) on Android arm 

and x86 platform. However, there are some performance issue needed to resolve. For example, it takes a long to 

recognize all bounding boxes and use too much memory on  mobile platforms. I have tried openCL on my 

Android phone, but it won't be better. So I am going to remove some layers of Convolution Neural Network to 

improve speed and memory, but I am not sure of how much accuracy will drop down. I am also 

going to try pruning methods and other BLAS like MKL to speed up forwarding on mobile device.  



Image recognition:



Object detection on HTC Desire Eye 













Source:
https://github.com/tzutalin/Android-Object-Detection

10/22/2015

C++ Boost lib to scan directory

library(-l) : boost_system boost_filesystem 
Include(-I) : /usr/include/boost
#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

std::string dirPath = "/home/darrenl/Pictures/person";
fs::path someDir(dirPath);
fs::directory_iterator end_iter;

typedef std::multimap<std::time_t, fs::path> result_set_t;
result_set_t result_set;

if (fs::exists(someDir) && fs::is_directory(someDir)) {
    for (fs::directory_iterator dir_iter(someDir); dir_iter != end_iter;
            ++dir_iter) {
        if (fs::is_regular_file(dir_iter->status())) {
            result_set.insert(
                    result_set_t::value_type(
                            fs::last_write_time(dir_iter->path()),
                            *dir_iter));
            LOG(INFO)<< dir_iter->path().string();

        }
    }
}

10/15/2015

Ubuntu Quick install Apache, PHP, and create public_html


Install Apache and MySQL

sudo apt-get install apache2 mysql-client mysql-server php5-mysql

Visiting your server in your web browser
















Create a public_html folder by User

sudo a2enmod userdir
sudo service apache2 reload
Of course, you'll also need to make sure that the permissions on your public_html folder allow the www-data user to see the files in there -- 755 usually works well. To do this:
mkdir ~/public_html
chmod -R 755 ~/public_html
So that, Apache can access files in Home directory

Install PHP 

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Test PHP

<?php
phpinfo();
?>
The address you want to visit will be:
http://localhost/info.php















Enable PHP in UserDir
sudo vim /etc/apache2/mods-enabled/php5.conf






sudo /etc/init.d/apache2 restart

9/18/2015

Develop a GUI tool to label and annotate image

labelImg Introduction

  In the past few month, I started to do a project about objection detection. There is a great website, called Image-Net, that I can download images from it to do objection recognition. However, Image-Net provide the users with a few images with bounding box(annotation file). Therefore, I tried to spend a few days to develop a GUI tools that can annotate the image in PascalVOC and Image-Net annotation format. The bellow screenshot is my GUI tool developed by pyQT and forking from labelMe.


A tutorial demonstrates how to use it. There are some hotkeys that can annotate and save the image faster.
Hotkeys:
' Ctrl+ N ' :  Create a bounding box
' n ' : Change to the next image
'Ctrl + S' : Save the annotated file

Other ImageNet Utils
  I also created some tools that can easily download the image, crop the image with bounding box, and convert the image's path and label to text file, etc. Please feel tree to knock yourself out. 

For example, one of the tools 

It will create train.txt containing 3,000 paths and label 1 for training and test.txt contain 1,000 paths and label 1 for testing, and label 1 is chair.
./labelcreator.py --size_of_train 3000 --size_of_test 1000 --label 1 --dir ./chair

The result format is as bellow:

Conclusion


  Hope these tools can help the people who are doing vision algorithms or research.

If the tool helps you, please give me a star in Github.

Source code: