Monday, 29 February 2016

Using OpenMVG

OpenMVG is a great library on multiple view geometry. It could be used as a stand alone library like OpenCV. These are the steps to follow

Install OpenMVG following the instruction here.
After installation is finished, follow the "Using OpenMVG as a third party library dependency in cmake" session in the installation guide.

Like what is done in the examples, eg here, include the header files and namespace in your source code. Note that the namespace must be used, eg for Image<RGBColor> image;, use using namespace openMVG::image;

For another instance, to use PointFeature defined in "openMVG/features/features.hpp", not only you should include the header file, but also have to add the name space of features, using namespace openMVG::features;

You also have to enable the support for c++11 by adding the code in cmakeList

IF(CMAKE_COMPILER_IS_GNUCC)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE()
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF()

There seems to be a bug in the non free module, according to here.

Wednesday, 24 February 2016

ubantu teamviewer

前几天还好好的teamviewer用着用着突然挂了,显示not ready, no connection,可是网页可以上,说明电脑有internet connection。无论是关掉ubantu防火墙还是重装teamviewer都不行。后来想起来windows远程访问ubantu还可以用remote desktop,只要输入ip地址就行。不过连接进去之后发现ubantu的桌面变得非常不一样,但是不影响程序,比如matlab的使用。

Friday, 19 February 2016

使用两个显示器

现在我有两个显示器,一个Benq的,一个Dell自己原装的。dell的是白色比较宽的插口,benq的是蓝色的比较窄的插口。一开始把蓝色的插到主机上无法detect到benq的显示器,然后切换了一下主显示器之后居然连dell的显示器也无法识别了...

后来尝试用一个黑色转换插头把蓝色插头转换到了很扁平的一种插头,貌似是HDMI,接在主机上,然后重启电脑,两个屏幕才都可以在win7下被识别。不过后来在ubuntu中dell的主显示器不如原来流畅,必须在setting里面把display中dell设置为on,benq的设置为off,然后拔掉benq的黑色转换插头,才能在重新启动的时候用dell作为主显。

Thursday, 18 February 2016

Recurrent neural network简介

最近看到一篇文章简单的介绍了RNN的概念。一般的CNN由input,hidden,output layer组成,每个layer之中的neuron没有联系,后一层的layer只跟前一层有关。这种方法的缺点是无法得到context信息,比如在一个视频中frame之间是有关联的,好比每个单词都要放在一个句子里面才容易理解。而RNN为了利用这种context,增加了每个layer之间的feedback,就是说hidden layer的neuron不仅跟前一层的有关,还跟上一次它自己的值有关,这样就仿佛给了它记忆的功能。RNN的应用包括语言翻译,图片注释等。

Wednesday, 17 February 2016

WD hard disk

Sometimes Win7 does not recognize the WD hard disk, and according to here, this can be solved based on the following steps

win+R to open Run, then enter devmgmt.msc to open device manager

in Universal Serial Bus Controllers, uninstall the unrecognized mass storage usb device, then right click the Universal Serial Bus Controllers and scan for hardware changes

Sunday, 14 February 2016

Python and pyplot

Importance of virtual environment

I am trying to compile the code from cs231n, but it says numpy.core.multiarray failed to import. It is suggested on the web to update the python numpy by pip install -U numpy. However, I did not update it in the virtual environment, instead, I updated in the global space. Then when I tried to compile my ros catkin code, it seems the header file generated from msg using python no longer works.

To resolve this, I have to re-init a catkin workspace, and copy the original src folder to replace the new src folder. Also note to source ./devel/setup.bash. In conclusion, any update and change should be made in the virtual environment only.

Anyway, later I found that matplotlib.pyplot could not be used in the cs231n virtual environment, though matplotlib can be imported. Outside the virtual environment, however, matplotlib.pyplot can be used with no problem. Just note that when using import matplotlib.pyplot as plt, plt.show() need to be called at the end to visualize the result as stated here.  

Saturday, 13 February 2016

Caffe and matlab

I recently installed Caffe and want to use it with matlab. However, it seems the structure of the folder named ''matlab'' has changed after some update. The caffe folder becomes +caffe folder. The mex file is contained in the private folder, and its name is changed to caffe_.mex instead of caffe.mex

Monday, 1 February 2016

Python and image classification

Installation

I am interested in learning python and want to use it in this module. However, when I try to install it with pip, it gives an exception. I have to use sudo apt-get install iphython, and then sudo apt-get install iphython-notebook to install it.

Also, if you are using Ubantu and Windows together, this command virtualenv .env can only be executed in the Ubantu directory, otherwise it says python could not run, permission denied.

To use the ./get_datasets.sh to download the dataset, you have to first give permission to that .sh file, by using chmod u+x program_name.

Another issue is when pip install -r requirements.txt, it says /usr/bin/ld: cannot find -lncurses, and based on this you have to enter sudo apt-get install libncurses5-dev. To build scipy and numpy, you need to install blas and lapack, which could be done in synaptics by installing libblas-dev and liblapack-dev.

Then I run into the error: library dfftpack has Fortran sources but no Fortran compiler found. You have to install gfortran in synaptics.

After all the hard work, run ipython notebook in the same directory and then you will see the notebooks available for the cs231n.

Load the dataset

To load the image dataset, use the following

from cs231n.data_utils import load_CIFAR10
cifar10_dir = 'cs231n/datasets/cifar-10-batches-py'
Xte, Ytr, Xte, Yte = load_CIFAR10(cifar10_dir)

You have to implement the nearest neighbor classifier yourself based on the code provided

To use the k nearest neighbor classifier, use

from cs231n.classifiers import KNearestNeighbor
nn = KNearestNeighbor()

Also note that in python 3, the print statement is replaced with the print function as discussed here.