maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   AR applications on N900 (OpenCV) (https://talk.maemo.org/showthread.php?t=54889)

klen 2010-06-02 10:12

AR applications on N900 (OpenCV)
 
1 Attachment(s)
Hello,

Just to make life easier to anyone who wants to do AR on N900 i have a few suggestions.

1.) Use openCV library for any tracking and image manipulation. It is an amazing library that is available in the repo.

M900:

$ apt-get install libcv4 libcvaux4 libhighgui4

Scratchbox:

$ apt-get install libcv4 libcv-dev opencv-doc libcvaux-dev libcvaux4 python-opencv libhighgui-dev libhighgui4

2.) For capturing video use openCV library calls or go through the hassle of GStreamer (appsink element) which can be integrated with QT using QGLWidget object. I attached source code of a project GstOpenGL that demonstrates how this can be done. Make sure you have qt 4.6 on your N900 or scratchbox. The GstOoenGL does not use openCV.

The code has not been cleaned and optimized but should save you time.
Klen

krk969 2010-06-02 10:15

Re: AR applications on N900 (OpenCV)
 
thanks Klen, very helpful.
would be nice if you have the link to the doxygen or details of api's.

Dorfmeister 2010-06-02 19:21

Re: AR applications on N900 (OpenCV)
 
a) Thank you very much, Klen.

b) krk969: Do you mean http://opencv.willowgarage.com/docum...cpp/index.html ? I also read parts of "Learning OpenCV: Computer Vision with the OpenCV Library", which seemed quite helpful.

The conventional resources are:
http://doc.qt.nokia.com/qt-maemo-4.6/classes.html
http://www.khronos.org/opengles/sdk/docs/man/
http://gstreamer.freedesktop.org/documentation/

Hope that helps. Since the main code chunks are taken from the tutorials and contain no doxygen documentation themselves, there shouldn't be any further resources imho.

Dorfmeister 2010-06-07 06:45

Re: AR applications on N900 (OpenCV)
 
If I open the .pro file via left click in Qt Creator, this happens:
build results in an error, so I have to qmake
then I get 22 errors with "gl* (glVertexAttribPointer etc.) was not declared" if I build or "gst/interfaces/photography.h: No such file or directory" if I rebuild

If I delete everything, unzip it again, open QtCreator manually and load the same .pro file via menu, it buils just fine, but if I change it into a format to be able to generate a Debian package easily later on I get "No rule to make target 'texture.qrc'"

Could anybody help me with this please? I seem not to be sufficiently familiar with qmake.

Oh - if I try to run it using MADDE (which again works fine with other programs), I get:
Code:

Files to deploy: /scratchbox/users/maemo/home/maemo/OwnProjects/AWESOME/DistanceQT-build/DistanceQT.
Deployment finished.
Starting remote application.
chmod u+x /home/developer/DistanceQT; source /etc/profile;  /h ome/developer/DistanceQT 
Pipline initialized!
GST error: v4l2camsrc_calls.c(686): gst_v4l2camsrc_open (): /GstPipeline:test-camera/GstV4l2CamSrc:camera_src:
system error: Permission denied
Aborted

Since this is for educational purposes: Could anybody show how to integrate OpenCV? That would be awesome. Developing for the N900 is really cumbersome. I've been looking into it for weeks now and I'm still struggling with beginner mistakes, whereas I could already have written a whole enterprise application for Android in the same time.

If I build another modification compilation works, but I get a
Code:

/scratchbox/tools/bin/misc_runner: /targets/links/scratchbox.config: No such file or directory
if I try to run it via ssh. And we're talking about minor changes - changing some array values. Why does so much happen if I don't really change anything?!

Btw: I use Qt 4.6.2 instead of 4.5. If there are any cleaned up versions, fixes for my problems, updates etc please let me know.

Best regards,
Dorfmeister

Dorfmeister 2010-06-10 15:14

Re: AR applications on N900 (OpenCV)
 
Hi,

I solved the issues (thanks, Klen) and now try to include OpenCV support. I installed the packages recommended by Klen and tried a test pipeline using gst-launch (based on http://vimeo.com/6866036):
Code:

gst-launch v4l2camsrc device=/dev/video0 ! video/x-raw-yuv,width=480,height=272 ! videorate ! capsfilter caps="video/x-raw-yuv,width=480,height=272,framerate=(fraction)12/1" ! queue ! ffmpegcolorspace ! faceblur ! ffmpegcolorspace ! xvimagesink
However, this results in
Code:

WARNING: erroneus pipeline: no element "faceblur"
, which is the only OpenCV component. Without it, the test runs fine. Has anybody working CV support? Could anybody post a minimal example or tell me how to make it run? If we want great CV apps for our N900 we should provide beginners with a solid starting point for OpenCV as well.

Thanks in advance.

EDIT:
There are simply no OpenCV-GStreamer plugins available according to Daniil (thanks!), which is the reason why the pipeline doesn't work.

I wrote a short example for using OpenCV myself, see here:
http://discussion.forum.nokia.com/fo...-in-Qt-example


Best regards,
Dorfmeister

klen 2010-08-27 09:43

Re: AR applications on N900 (OpenCV)
 
Quote:

Originally Posted by Dorfmeister (Post 708927)
Hi,
EDIT:
There are simply no OpenCV-GStreamer plugins available according to Daniil (thanks!), which is the reason why the pipeline doesn't work.
Dorfmeister

This is true, but the way you can intergrate gstreamer with OpenCV is to parse the captured raw image data into the IplImage object of the OpenCV Library.

The way to do this:
1.) create an IplImage object of the right size and format.
HTML Code:

IplImage *frame;
frame = cvCreateImageHeader(cvSize(CameraN900::buffer_width,CameraN900::buffer_hight), IPL_DEPTH_8U, 3);

2.) set the data part of the IplImage object.
HTML Code:

cvSetData(tracker->frame ,data,CameraN900::buffer_width*3);
3.) As the captured data is in RGB format and the openCV is in BGR this conversion is needed.
HTML Code:

cvResize(tracker->frame,tracker->frameBGR);
4.) Now you are ready to use your captured frame with any openCV function.

The other way to go is to compleatly skip the QT and work with OpenCV only. You have all the functions that you need for displaying the and capturing the video stream. And the run fast but did not compare them with this approach. I guess if you don't need QT integration this is the way to go.

Sorry for the late reply. I think I was not subscribed to this thread.

I hope this helps.

Cheers,
Klen

kev 2010-12-29 13:03

Re: AR applications on N900 (OpenCV)
 
There are OpenCV-GStreamer plugins in the repository, Gst-Opencv


http://maemo.org/packages/view/gst-opencv/


All times are GMT. The time now is 16:34.

vBulletin® Version 3.8.8