From
http://royontechnology.blogspot.hk/2012/06/installing-emacs-241.html
Though we can directly install from the Ubuntu Software Center, but it is more flexible to build it.
Installing Emacs 24.1
I was excited to see the announcement that Emacs 24.1 has been released. I wanted to install and try. There were a few glitches that I faced during the installation. I thought it might be useful for someone who might be hitting the same blocks.
Once I downloaded the source code and verified the signature, I unzipped the Emacs 24.1 source code. The first "configure" run gave the following error:
configure: error: You seem to be running X, but no X development libraries
were found. You should install the relevant development files for X
and for the toolkit you want, such as Gtk+, Lesstif or Motif. Also make
sure you have development files for image handling, i.e.
tiff, gif, jpeg, png and xpm.
If you are sure you want Emacs compiled without X window support, pass
--without-x
to configure.
To address this error I had to do the following:
sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev
Then when I attempted to run configure again, I got the following error:
configure: error: The required function `tputs' was not found in any library.
These libraries were tried: libncurses, libterminfo, libtermcap, libcurses.
Please try installing whichever of these libraries is most appropriate
for your system, together with its header files.
For example, a libncurses-dev(el) or similar package.
To resolve this error I had to do the following:
sudo apt-get install libncurses-dev
Thats it. The installation was smooth. Here is the summary of commands you need to run:
sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev libncurses-dev
#Note, libjpeg-dev, libpng12-dev's version may be different.
# You can skip this step if you don't want to verify the signature.
gpg --verify emacs-24.1.tar.bz2.sig emacs-24.1.tar.bz2
tar xvfj emacs-24.1.tar.bz2
cd emacs-24.1
./configure
make
sudo make install
Posted by Roy at 4:25:00 PM
Labels: Emacs
Saturday, December 15, 2012
Install scipy for Ubuntu 12.04
Download from git
https://github.com/scipy/scipy
1. Install fortran compiler. e.g. gfortran.
2. Install blas, lapack (search libblas, liblapack on the Ubuntu Software Center)
3. $ python setup.py install --prefix=$MYDIR ($MYDIR can be /usr/local)
Wednesday, November 7, 2012
using algorithm in latex
[Latex] 如何在Latex上寫algorithm
[转]
作者: Wei Chung Cheng 發佈於 上午1:57 2011年1月21日星期五
做個紀錄吧,我下關鍵字都找不到清晰的教學XD
希望以後有人要用到的時候比較好查!
首先你需要灌一些package,灌package的方式,我以MiKTeX為例子。
簡單的來說,開始 -> MiKTeX -> Maintenance (Admin) -> Package Manager (Admin)
點進去之後,他會搜尋所有的Package。
然後你點選你需要的Package 再按那個"+"的按鈕就會更新package了!
通常Algorithm 會用到哪些package呢?
你可以灌以下這些Package:
algorithms, algorithm2e, program, alg, algorithmicx, pseudocode
安裝完成之後,回到你的tex檔。
在\begin{document}之前,加入以下這兩行:
\usepackage{algorithmic} - 對應algorithmicx
前兩行renewcommand 是:
將require以Input: 形式表示及ensure以Output:形式表示。
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
希望以後有人要用到的時候比較好查!
首先你需要灌一些package,灌package的方式,我以MiKTeX為例子。
簡單的來說,開始 -> MiKTeX -> Maintenance (Admin) -> Package Manager (Admin)
點進去之後,他會搜尋所有的Package。
然後你點選你需要的Package 再按那個"+"的按鈕就會更新package了!
通常Algorithm 會用到哪些package呢?
你可以灌以下這些Package:
algorithms, algorithm2e, program, alg, algorithmicx, pseudocode
安裝完成之後,回到你的tex檔。
在\begin{document}之前,加入以下這兩行:
\usepackage{algorithmic} - 對應algorithmicx
\usepackage{algorithm} - 對應algorithms
因為我目前只用到這兩個,相對應其他package的usepackage 稍微搜尋一下就會有了!
有時候加完之後complie 會出現algorithm.sty找不到的訊息。
這時候就手動將algorithm.sty放入你目前的資料夾中就可以了!
至於去哪找到algorithm.sty呢?
資料夾 "MiKTeX 2.8\tex\latex\algorithms" 底下就找得到。
另外附上簡單的Sample
\algsetup{indent=2em}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\newcommand{\factorial}{\ensuremath{\mbox{\sc Factorial}}}
\begin{algorithm}[h!]
\caption{$\factorial(n)$}\label{alg:factorial}
\begin{algorithmic}[1]
\REQUIRE An integer $n \geq 0$.
\ENSURE The value of $n!$.
\medskip
\IF {$n = 0$}
\RETURN $1$
\ELSE
\RETURN $n \cdot \factorial(n-1)$
\ENDIF
\end{algorithmic}
\end{algorithm
前兩行renewcommand 是:
將require以Input: 形式表示及ensure以Output:形式表示。
網路上範例一:
\begin{algorithm}[htb]
\caption{ Framework of ensemble learning for our system.}
\label{alg:Framwork}
\begin{algorithmic}[1]
\Require
The set of positive samples for current batch, $P_n$;
The set of unlabelled samples for current batch, $U_n$;
Ensemble of classifiers on former batches, $E_{n-1}$;
\Ensure
Ensemble of classifiers on the current batch, $E_n$;
\State Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$;
\label{code:fram:extract}
\State Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches;
\label{code:fram:trainbase}
\State $E_n=E_{n-1}cup E$;
\label{code:fram:add}
\State Classifying samples in $U_n-T_n$ by $E_n$;
\label{code:fram:classify}
\State Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$;
\label{code:fram:select} \\
\Return $E_n$;
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[htb]
\caption{ Framework of ensemble learning for our system.}
\label{alg:Framwork}
\begin{algorithmic}[1]
\Require
The set of positive samples for current batch, $P_n$;
The set of unlabelled samples for current batch, $U_n$;
Ensemble of classifiers on former batches, $E_{n-1}$;
\Ensure
Ensemble of classifiers on the current batch, $E_n$;
\State Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$;
\label{code:fram:extract}
\State Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches;
\label{code:fram:trainbase}
\State $E_n=E_{n-1}cup E$;
\label{code:fram:add}
\State Classifying samples in $U_n-T_n$ by $E_n$;
\label{code:fram:classify}
\State Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$;
\label{code:fram:select} \\
\Return $E_n$;
\end{algorithmic}
\end{algorithm}
排版效果圖:
網路上範例二:
\begin{algorithm}[h]
\caption{An example for format For \& While Loop in Algorithm}
\begin{algorithmic}[1]
\For{each $i\in [1,9]$}
\State initialize a tree $T_{i}$ with only a leaf (the root);
\State $T=T\cup T_{i};$
\EndFor
\ForAll {$c$ such that $c\in RecentMBatch(E_{n-1})$}
\label{code:TrainBase:getc}
\State $T=T\cup PosSample(c)$;
\label{code:TrainBase:pos}
\EndFor;
\For{$i=1$; $i<n$; $i++$ }
\State $//$ Your source here;
\EndFor
\For{$i=1$ to $n$}
\State $//$ Your source here;
\EndFor
\State $//$ Reusing recent base classifiers.
\label{code:recentStart}
\While {$(|E_n| \leq L_1 )and( D \neq \phi)$}
\State Selecting the most recent classifier $c_i$ from $D$;
\State $D=D-c_i$;
\State $E_n=E_n+c_i$;
\EndWhile
\label{code:recentEnd}
\end{algorithmic}
\end{algorithm}
\caption{An example for format For \& While Loop in Algorithm}
\begin{algorithmic}[1]
\For{each $i\in [1,9]$}
\State initialize a tree $T_{i}$ with only a leaf (the root);
\State $T=T\cup T_{i};$
\EndFor
\ForAll {$c$ such that $c\in RecentMBatch(E_{n-1})$}
\label{code:TrainBase:getc}
\State $T=T\cup PosSample(c)$;
\label{code:TrainBase:pos}
\EndFor;
\For{$i=1$; $i<n$; $i++$ }
\State $//$ Your source here;
\EndFor
\For{$i=1$ to $n$}
\State $//$ Your source here;
\EndFor
\State $//$ Reusing recent base classifiers.
\label{code:recentStart}
\While {$(|E_n| \leq L_1 )and( D \neq \phi)$}
\State Selecting the most recent classifier $c_i$ from $D$;
\State $D=D-c_i$;
\State $E_n=E_n+c_i$;
\EndWhile
\label{code:recentEnd}
\end{algorithmic}
\end{algorithm}
排版效果圖:
個人範例:
\begin{algorithm}[h]
\caption{Conjugate Gradient Algorithm with Dynamic Step-Size Control}
\label{alg::conjugateGradient}
\begin{algorithmic}[1]
\Require
$f(x)$: objective funtion;
$x_0$: initial solution;
$s$: step size;
\Ensure
optimal $x^{*}$
\State initial $g_0=0$ and $d_0=0$;
\Repeat
\State compute gradient directions $g_k=\bigtriangledown f(x_k)$;
\State compute Polak-Ribiere parameter $\beta_k=\frac{g_k^{T}(g_k-g_{k-1})}{\parallel g_{k-1} \parallel^{2}}$;
\State compute the conjugate directions $d_k=-g_k+\beta_k d_{k-1}$;
\State compute the step size $\alpha_k=s/\parallel d_k \parallel_{2}$;
\Until{($f(x_k)>f(x_{k-1})$)}
\end{algorithmic}
\end{algorithm}
\caption{Conjugate Gradient Algorithm with Dynamic Step-Size Control}
\label{alg::conjugateGradient}
\begin{algorithmic}[1]
\Require
$f(x)$: objective funtion;
$x_0$: initial solution;
$s$: step size;
\Ensure
optimal $x^{*}$
\State initial $g_0=0$ and $d_0=0$;
\Repeat
\State compute gradient directions $g_k=\bigtriangledown f(x_k)$;
\State compute Polak-Ribiere parameter $\beta_k=\frac{g_k^{T}(g_k-g_{k-1})}{\parallel g_{k-1} \parallel^{2}}$;
\State compute the conjugate directions $d_k=-g_k+\beta_k d_{k-1}$;
\State compute the step size $\alpha_k=s/\parallel d_k \parallel_{2}$;
\Until{($f(x_k)>f(x_{k-1})$)}
\end{algorithmic}
\end{algorithm}
排版效果圖:
先前所使用的套件為algorithm或algorithmic
接下來介紹另一個寫algorithm的套件alogrithm2e
首先使用\usepackage指令
\usepackage[linesnumbered,boxed]{algorithm2e}
接下來是網路範例:
\begin{algorithm}
\caption{identifyRowContext}
\KwIn{$r_i$, $Backgrd(T_i)$=${T_1,T_2,\ldots ,T_n}$ and similarity threshold $\theta_r$}
\KwOut{$con(r_i)$}
$con(r_i)= \Phi$\;
\For{$j=1;j \le n;j \ne i$}
{
float $maxSim=0$\;
$r^{maxSim}=null$\;
\While{not end of $T_j$}
{
compute Jaro($r_i,r_m$)($r_m\in T_j$)\;
\If{$(Jaro(r_i,r_m) \ge \theta_r)\wedge (Jaro(r_i,r_m)\ge r^{maxSim})$}
{
replace $r^{maxSim}$ with $r_m$\;
}
}
$con(r_i)=con(r_i)\cup {r^{maxSim}}$\;
}
return $con(r_i)$\;
\end{algorithm}
排版效果圖:
\usepackage[linesnumbered,boxed]{algorithm2e}
接下來是網路範例:
\begin{algorithm}
\caption{identifyRowContext}
\KwIn{$r_i$, $Backgrd(T_i)$=${T_1,T_2,\ldots ,T_n}$ and similarity threshold $\theta_r$}
\KwOut{$con(r_i)$}
$con(r_i)= \Phi$\;
\For{$j=1;j \le n;j \ne i$}
{
float $maxSim=0$\;
$r^{maxSim}=null$\;
\While{not end of $T_j$}
{
compute Jaro($r_i,r_m$)($r_m\in T_j$)\;
\If{$(Jaro(r_i,r_m) \ge \theta_r)\wedge (Jaro(r_i,r_m)\ge r^{maxSim})$}
{
replace $r^{maxSim}$ with $r_m$\;
}
}
$con(r_i)=con(r_i)\cup {r^{maxSim}}$\;
}
return $con(r_i)$\;
\end{algorithm}
排版效果圖:
延伸幾個問題:
一、如何修改Algorithm的標題為中文的"演算法”?
在\begin{document}之前加入\renewcommand{\algorithmcfname}{算法} 即可(註:需先安裝中文字形)
二、如何去掉演算法中的豎線?
加入 \SetAlgoNoLine 指令在\begin{algorithm}之後
排版效果圖:
三、還可以使用其他標題樣式?
也可以使用\usepackage[ruled,vlined]{algorithm2e}
排版效果圖:
排版效果圖:
關於algorithm2e還有以下一些information
The algorithm2e LaTeX package conflicts with several others over the use of the algorithm identifier.
The algorithm2e LaTeX package conflicts with several others over the use of the algorithm identifier.
A common indicator is something like this message: Too many }'s.l.1616 }
To resolve the issues, simply put the following just before the inclusion of the algorithm2e package:
\makeatletter
\newif\if@restonecol
\makeatother
\let\algorithm\relax
\let\endalgorithm\relax
Wednesday, October 10, 2012
Configure sMobileNet of HKUST on Linux | Linux and Virtualization
Configure sMobileNet of HKUST on Linux | Linux and Virtualization
The wireless network connection configuration for sMobileNet in NetworkManager
The SSID is “sMobileNet”
Wireless security is “WPA & WPA2 Enterprise”
Authentication is “Protected EAP (PEAP)”
Anonymous identity is “” (empty)
CA certificate is “(None)” (there will be a warning appear, we can ignore it)
PEAP version is “Automatic”
Inner authentication is “MSCHAPv2″
Username is “username@ust.hk”
Password is your password.
A sample security configuration
Tuesday, September 25, 2012
MIT indoor dataset
http://web.mit.edu/torralba/www/indoor.html
some recognition results
http://www.cs.unc.edu/~megha/DPM/IndoorScene/index.html
Thursday, September 6, 2012
Tuesday, September 4, 2012
Install Opencv2.4 in Ubuntu 12.04 with python
UPDATE:
Now you can use my new guide to install OpenCV 2.4.1 in Ubuntu 12.04 LTS:
First, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal
1 | sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev |
Now we need to get and compile the ffmpeg source code so that video files work properly with OpenCV. This section is partially based on the method discussed here.
1 | cd ~ |
3 | tar -xvzf ffmpeg-0.7-rc1.tar.gz |
4 | cd ffmpeg-0.7-rc1 |
5 | ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libxvid --enable-x11grab --enable-swscale --enable-shared |
6 | make |
7 | sudo make install |
The next step is to get the OpenCV 2.2 code:
1 | cd ~ |
3 | tar -xvf OpenCV-2.2.0. tar .bz2 |
4 | cd OpenCV-2.2.0/ |
Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python and TBB with OpenCV, here is where we set that. Just execute the following line at the console to create the appropriate Makefile. Note that there is a dot at the end of the line, it is an argument for the cmake program and it means current directory.
1 | cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON . |
Check that the above command produces no error and that in particular it reports FFMPEG as 1. If this is not the case you will not be able to read or write videos. Also, check that Python reports ON and Python numpy reports YES. Also, check that under Use TBB it says YES. If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:
Now, you are ready to compile and install OpenCV 2.2:
1 | make |
2 | sudo make install |
Now you have to configure OpenCV. First, open the opencv.conf file with the following code:
1 | sudo gedit /etc/ld.so.conf.d/opencv.conf |
Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:
1 | /usr/ local /lib |
Run the following code to configure the library:
1 | sudo ldconfig |
Now you have to open another file:
1 | sudo gedit /etc/ bash .bashrc |
Add these two lines at the end of the file and save it:
1 | PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/ local /lib/pkgconfig |
2 | export PKG_CONFIG_PATH |
Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.
There is a final step to configure Python with OpenCV. You need to copy the file cv.so into the correct place. You can do that by just executing the following command:
1 | sudo cp /usr/local/lib/python2.7/site-packages/cv.so /usr/local/lib/python2.7/dist-packages/cv.so |
Now you have OpenCV 2.2 installed in your computer with Python and TBB support.
Subscribe to:
Posts (Atom)