Thứ Năm, 2 tháng 1, 2014

MATLAB options file in Linux 64

Happy new year 2014,
I am writing this blog to notice you a trick to change option files in Matlab in Linux, which is very useful. When you want to use MEX to compile a C/Fortran source in MEX interface, you need to modify option files mexopts.sh in Linux because the default file contains errors in Linux. Why is it important so? The answer is that options files control which compiler to use, the compiler and link command options, and the runtime libraries to link against.
Then, where the file locate in Linux? The default file mexopts.sh locates in /home/tranlaman/.matlab/R2012a. But there is another default root file lie in /home/tranlaman/MATLAB/R2012a/bin which overrides the file in /home/tranlaman/.matlab/R2012a. So, modifying the mexopts.sh in /home/tranlaman/MATLAB/R2012a/bin would change everything.
Finally, how do we modify this file? The answer is to change some compiling and linking flag such as CC, CFLAGS, CLIBS, LD, LDFLAGS. Please refer to [1] as a complete flag for custom building MEX files.
Wish everyone has a good year.

Thứ Sáu, 20 tháng 12, 2013

HOW-TO: Making an icon licking in Ubuntu

Hi all,
After a while of using Ubuntu, I feel that everything is fine and cool. It is still something missing in Windows. They are icons. This tutorial guides you how to make an icon licking in Ubuntu. I prefer to style of learning by doing, so let start with an example.
Let save the following code in a file named matlab.desktop, and move it to /usr/share/applications. It is a system folders, and you should know that we need to use sudo.
#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Icon=/usr/share/icons/matlab_logo.gif
Name=MATLAB R2012a
Comment=Start MATLAB - The Language of Technical Computing
Exec=matlab -desktop
Categories=Development;

All you need to do is to replace a command to start your application, in this case, it is MATLAB R2012a. It should be noticed that excutable command here is that matlab. We need to create alias for matlab.
 cd /usr/local/bin/ 
 sudo ln -s /usr/local/MATLAB/R2012a/bin/matlab matlab
This trick will allow you to start Matlab from any folder, as you were trying to do. Further, you should replace icon with your logo. That's all. Then, you find an icon of Matlab in /usr/share/applications. Now you can search Matlab in Launcher Utility and send this icon to Desktop to have a licking icon such that in Windows.

I know that I need to create some icons for some applications I like since a long  time ago. But I rely on the reason that I am busy so I did not care about it. Now I change. Let work with a style, live with a style and more,  research also with a style. I am gonna figure out what style I am.
Thanks,

Chủ Nhật, 24 tháng 11, 2013

Wordle - a new toy

Hi,
After a long time, I did not write anything on my blog. I am quite busy with the modules in uni and other stuff in Computer Vision and Machine Learning. When surfing around for some papers and dissertation, I found a new toy for undergrads, grads student or some geeks. When you finished writing something such as reports, papers and theses, you want to visualize your work just in some words according to their prominence in the writing. Wordle is your toy. Wordle will visualize most frequent  words, "cloud words", that appear in the provided text.
http://www.wordle.net/
The following is the wordle of one of my final review paper.

Chủ Nhật, 14 tháng 7, 2013

LINUX: Awesome error

Today, I met an awesome error when running a shell script file in Ubuntu.
tranlaman@tranlaman-VirtualBox:~/Desktop/workspace/partapp-r2$ ./run_partapp.sh bash: ./run_partapp.sh: /bin/sh^M: bad interpreter: No such file or directory
 The following link can fix the problem excellently:
http://www.gizmola.com/blog/archives/87-linux-shell-scripting-bad-interpreter-no-such-file-or-directory.html

Reason: Because the code was developed in Mac or somewhere, then I run it in Ubuntu. The file format is different.

Thứ Năm, 11 tháng 7, 2013

LD_LIBRARY_PATH all you need to know.

Hi all,
I have spent countless hour when trying to compile the C/C++ code in Linux (Ubuntu 12.04) using GCC or G++ compiler. I met a bunch of errors and then I figured out in Ubuntu the options -I -L and LD_LIBRARY_PATH are quite important. I read README and do exactly the same but still met the errors. Consequently, it is going to save your time if you understand a little bit about -I option, -L options and LD_LIBRARY_PATH.
-I (Include) specifies the directories of included headers file needed to compile your code, for example, the #include <xxx.h>
- L (Library) specifies the directories of shared libraries or static libraries for linking. It is used with -l (not number but an alphabet) options to specify the lib name. For example, a library is libxxx.so or libxxx.a would have -l option as -lxxx.
LD_LIBRARY_PATH (LinkDynamic Library Path -- I guess :-D) specifies the directories of shared libraries for linker during the run-time [2]. Also, it is used at the link-time, when linker looks for libraries and resolve external symbols in these directories. The problems are raised because of LD_LIBRARY_PATH since the directories at the link-time and run-time are different [3]. Some issues relate to incompatible versions of required libraries.
Refer to the links bellow for hands-on errors and solutions:
* The difference between -I and -L options:
[1] http://adf.ly/Rsfwr/what-is-the-difference-between-i-and-l-in-makefile
* The difference between LD_LIBRARY_PATH and -L at the run-time:
[2] http://adf.ly/RsgVz/what-is-the-difference-between-ld-library-path-and-l-at-link-time
* Why the LD_LIBRARY_PATH is bad?
[3] http://adf.ly/RskIY/UnixResource_dir/_/ldpath.html

Thứ Bảy, 15 tháng 6, 2013

Question: Where does my program reside if I install a program in Ubuntu?

Answer:
Normally, it would go to /usr/local. In /usr/local, you would have subdirectories such as /bin, /etc, /lib, /share, /src. These sub-folders contain appropriate files depending on the type of program that you want to install.

Thứ Sáu, 14 tháng 6, 2013

HOW-TO: Install OpenCV-2.4.5 and ffmpeg-1.2.1 in Ubuntu 64bits

Bug       
      After spending several days to install the latest ffmpeg with the latest OpenCV, I discovered that I made a stupid mistakes. The follow is a big-bug that I had met during installing ffmpeg-1.2.1 which create shared library in order for OpenCV to recognize it.
'libavutil/intfloat_readwrite.o: relocation R_X86_64_PC32 against undefined symbol `ldexp@@GLIBC_2.2.5'. 
This error because of bad symbolic link in ubuntu. The reason is that I placed my install folder in shared folder between my computer and Virtualbox VMs [4]. Anyway, if you meet this error, please moving your folder to a safer place, not a shared folder. On the other hand, installing ffmpeg and opencv require you to to have --enable-shared option which create shared-library. So, you need to do the same to all other dependencies, --enable-shared option as in [3]. Other possible remedy, you might want to run ldconfig command to update run-time linker default [5]. The exact structure for this command is
ldconfig [your ffmpeg installer folder].
Installation         
      I am writing this post to summerize steps to install ffmpeg a common media cross-platform for OpenCV-2.4.5 to localize it. I recommend you to follow the instructions in  [3]. You can also follow [1] and
[2]. Refering to [2], you can test if you install OpenCV correctly (testing section). I copy and paste here for easy to refer.
Testing
An easy way to test that the compilation went well is to use the OpenCV test utilities. For example, to test the core module go to OpenCV-2.4.5/build/bin and run:
./opencv_test_core
 You should see something like this:

Note that some failures when testing other modules may come from missing image files. To correctly run these tests or samples you should move the corresponding image files from OpenCV-2.4.5/samples to OpenCV-2.4.5/build/bin.

For testing that you can compile your own programs and link against the installed OpenCV libraries I have packaged the face detection sample with all the necessary files and a simple Makefile. Download it here, extract and type:
make
This should compile and run with a test image, so you should see something like this: