Life is a game, take it seriously

Archive for July, 2012|Monthly archive page

Recording 3D video(oni) files that align rgb image with depth image

In Computer Vision, Point Cloud Library on July 15, 2012 at 10:51 am

by Gooly (Li Yang Ku)

Kinect or xtion like devices provide an easy way to capture 3D depth image or videos. The OpenNI interface that is compatible with these devices comes with a handy tool “NiViewer” that captures 3D video into an oni file. The tool is located under “Samples/Bin/x64-Release/NiViewer” for Linux; and should be in the startup menu if you use Windows. After starting up the tool, you can right click and show the menu. By clicking “Start Capture” and then “Stop” should generate an oni video file in the same folder.

However the rgb video and depth video in the oni file are recorded seperately and not aligned. (Turns out it should be aligned if you press 9, but it didn’t work on my machine, see comment) This is due to the camera position difference between the IR sensor and the rgb sensor. OpenNI do provide functions to adjust the depth image to match the rgb image (Note that it is not doable the other way around). By adding some additional code to the NiViewer, you should be able to record depth video that is aligned with the rgb image.

First open the file “src/NiViewer/Capture.cpp”; change the code that adds the depth node under the “captureFrame()” function to the following.

nRetVal = g_Capture.pRecorder->AddNodeToRecording(*getDepthGenerator(), g_Capture.nodes[CAPTURE_DEPTH_NODE].captureFormat);
START_CAPTURE_CHECK_RC(nRetVal, "add depth node");
g_Capture.nodes[CAPTURE_DEPTH_NODE].bRecording = TRUE;
DepthGenerator* depth = getDepthGenerator();
depth->SetIntProperty ("RegistrationType", 1);
nRetVal = depth->GetAlternativeViewPointCap().SetViewPoint(*getImageGenerator());
if(XN_STATUS_OK != nRetVal)
{
	depth->SetIntProperty ("RegistrationType", 2);
	nRetVal = depth->GetAlternativeViewPointCap().SetViewPoint(*getImageGenerator());
	if(XN_STATUS_OK != nRetVal)
	{
		displayMessage("Getting and setting AlternativeViewPoint failed");
	}
}
g_Capture.nodes[CAPTURE_DEPTH_NODE].pGenerator = depth;

Then type make in the terminal under the NiViewer folder. The new NiViewer binary should be generated.
Kinect and xtion sensor uses different methods to generate this alternative view depth image. Kinect does the adjustment in software and xtion does it in hardware. This is why different “RegistrationType” are set in the code above.

Advertisements

A good alternative for Matlab

In Computer Vision, Matlab on July 11, 2012 at 4:56 am

by Wen

Matlab is one of the most popular tools in the field of image processing. I’ve been using Matlab for years when I was in the schools. Soon after my graduation, I found that I was not able to use Matlab anymore. I tried to buy it for personal use and found it to be very expensive. I was very frustrated until I found Octave, which is developed to be compatible with matlab. The good thing is that the old functions I developed under matlab environment can still be used with little modification most of the times. Octave also runs on windows machine using cygwin. I would like to share two problems that I encountered while trying to run octave on windows machine using cygwin.

  • “Unable to open display” while trying to create drawings

The problem is that gnuplot doesn’t draw figures in cygwin terminal. Running octave in x window will solve the problem. Typing “startx” in cygwin terminal will start the x server needed.

  • /usr/bin/octave-3.4.2.exe: error while loading shared libraries: ?

In my case, octave ran in my cygwin terminal but failed to lunch in the x window. The error message indicates that there is something missing in PATH. By comparing the PATH parameters in the cygwin terminal and x window, I found that it’s lapack that is missing. For me, “PATH=$PATH:/usr/lib/lapack” solved the problem.

Here’s how it looks like.