Monday 21 May 2012

Compile ardrone SDK on ubuntu 12.04 -- error on video_codec/video_stage_ffmpeg_recorder



Recently I installed Ubuntu 12.04(precision pangolin) on my Mac OS X lion. As I would like to play with Parrot AR. Drone quadcopter platform, I have to install AR. Drone SDK firstly. Due to my colleague has made this SDK compile straight away on Ubuntu 11.10, I thought the same story happen on Ubuntu 12.04. Unfortunately, I encounter some video codec and recorder issue from ffmpeg and some library missing issue(e.g., libcwiid1.dev) .
Here I listed several issues I encounter when I compile this SDK on Ubuntu 12.04 as following:

In file included from ../../VLIB/../VLIB/video_controller.h:5:0,
from ../../VLIB/../VLIB/video_codec.h:4,
from ../../VLIB/video_codec.c:1:
../VP_Api/vp_api_picture.h:16:30: fatal error: libavutil/avutil.h: No such file or directory
compilation terminated.
make[4]: *** [../../Soft/Build/targets_versions/ffmpeg_Intel_PROD_MODE_Linux_3.2.0-24-generic-pae_GNU_Linux_gcc_4.6.3/video_codec.o] Error 1
make[3]: *** [all] Error 2
make[2]: *** [build_vlib] Error 2
make[1]: *** [all] Error 2
make: *** [build_libs] Error 2

Then I followed this link (https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide) to install ffmepg, and then compile SDK again. It seems like the above error is gone. However, I got the following error.

In file included from ../..//Soft/Lib/ardrone_tool/Video/video_stage_ffmpeg_recorder.c:43:0:
/usr/local/include/libavfilter/avfilter.h:992:19: fatal error: audio.h: No such file or directory
compilation terminated.
make
4: *** [../../Soft/Build/targets_versions/ardrone_lib_PROD_MODE_ffmpeg_Intel_Linux_3.2.0-24-generic_GNU_Linux_gcc_4.6.3/ardrone_tool/Video/video_stage_ffmpeg_recorder.o] Error 1
make
3: *** [all] Error 2
make
2: *** [build_lib] Error 2
make
1: *** [all] Error 2
make: *** [build_libs] Error 2

When I double check the ffmpeg library in my system, I found there are two identical header files about ffmepg in my system. One is under /usr/include/libavformat, the other is /usr/local/include/libavformat. By carefully comparing, they have different size even though their names are exactly the same. The one under /usr/include should be the latest one which are created when you follow the above ffmpeg link, while the other under /usr/local/include should be come with system. I just overwrite the system one by the latest one.

sudo cp -rf /usr/include/libavformat /usr/local/include

And then compile the SDK again, it passed the compilation. Hopefully it would help you as well.

By the way, if it keeps prompt you to install libcwiid1.dev when you are compilling, you can go to open ardrone_SDK/ARDroneLib/Soft/Build/check_dependencies.sh and then subtitute the libcwiid1.dev to libcwiid.dev, which works for me.

Friday 18 May 2012

Mac Mail shows unread messages which I can not find

It really funny. I set up several mailboxes in mail on my Mac, one is google which works fine, another two are from my university which use Microsoft exchange server. At the beginning, everything works perfect. However, recently one mailbox using Microsoft exchange shows there are 1 unread message, and so does the inbox of my mail. But I cannot find any unread message in that mailbox, even on the server where I searched really carefully.

I searched on google, but I still have not solved this issue. There is a way to "solve" this issue to some extend.  At least, the mail on the dock shows the right number of the unread messages.

Mail -> Mailbox -> New Smart Mailbox, when you create a new smart mailbox, you are prompt to input the name of smart mailbox. I name it as "Unread messages"(Of course you can name whatever you want). And then choose the rule condition as "Message is unread". Now on the left panel of your mail there is a SMART MAILBOXES menu.

Then, Mail -> Preferences -> General -> Dock unread count, choose the smart mailbox you just created. Now the number of unread message on the dock is correct.

I am still keep my eyes on this issue, hopefully I could find a way to solve this issue soon.


Thursday 17 May 2012

Triple OS on MacBook Pro8 2 -- missing operating system

Today I am trying to install Windows 7 64bit OS and Ubuntu 12.04 LTS 64bit OS on my Macbook pro (later 2011), I followed this link (http://lifehacker.com/5531037/how-to-triple+boot-your-mac-with-windows-and-linux-no-boot-camp-required) to install these extra two OS.

Everything goes well until I restart the computer to launch Ubuntu through rEFIt. When I restarted my Mac after installing windows and ubuntu, I can see three OS icon and I shift to ubuntu. After a screen flash, it pop up a black screen with one sentence on the top, say, missing operating system.

Initial guess is that Linux GRUB boot loader does not install properly, it might be corrupted by Windows MBR boot loader. Therefore a new boot loader should be created to make all OS can be detectable.

After several searching on google, I found this link (http://ubuntuforums.org/showthread.php?t=1908210) which solved my problem.  As this link addressed the whole installation procedure, given that we have already installed three operating systems, we only need to regenerate a boot loader if something is wrong when we start up computer.  I summarise them as following:

1) Download gdisk from here(http://sourceforge.net/projects/gptfdisk/)
2) Log in Mac OS
3) Open the "Terminal" in Mac OS (lauchpad->utility->terminal, or search from spotlight)
4) Run "sudo gdisk /dev/disk0"
5) Type 'r' and then 'p' to print out the partitions
6) Then type 'h' to create hmbr
7) Type in the partition number corresponding to different OS, for example, #2 for mac, #5 for windows and # 7 for ubuntu, you should type 2 5 7
8) Next select 'y' to place EFI partition first
9) Type in MBR hex code for each partition, usually 'AF' for lion, '07' for Windows and '83' for linux. You might notice that in your machine, the hex code for windows and linux are the same '07', it cause one system is missing which cannot be detected by current boot loader. Note that do not set any of the bootable flag.
10) Finally type 'w' and 'y' to update the MBR

Now when you restart your system, each OS should be working.

Good luck.

Thursday 3 May 2012

matlab script on converting ply to pcd

PCL from willow garage is really useful for 3D geometric process and visualization, and it requires its own data format, say, point cloud data (pcd). In pcd file, the x, y, z coordinates are stored as float datatype, while color information rgb is packed into a 4 byte unsigned integer. I know it could use float to represent the rgb(a) information, unfortunately I did not make this work properly.

I wrote two matlab scripts to convert ply file generated by meshlab to pcd. One that I called as naive one, which scan each line in ply and then write them into pcd with appropriate format. The other one that I referred as efficient one due to data block can be read and written only once, it is about 10 times faster than the naive one for large file.

With respect to color conversion, as the color is stored as 8-bit unsigned integer for r, g, b channel in ply, while rgb is packed as  32-bit unsigned integer in pcd. I convert r, g, b from decimal to hex, and then pack them together and convert them back to decimal format. 

N.B.: currently it only supports the ply file with x,y,z or x,y,z, r,g,b information.
Download: