2008-02-18 17:44:35     basics on compiling openCV in uClinux

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-02-18 17:44:35     basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 51236    Hi,I have read the other two strings on openCV but my question is more basic. Do I compile openCV on my host computer then compile it into the kernel. Or do I load the openCV tar-ball onto the blackfin and unzip and compile it there? Thanks.

~Shane

QuoteReplyEditDelete

 

 

2008-02-18 18:19:09     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 51238    the Blackfin cannot compile code natively ... everything must be cross-compiled

QuoteReplyEditDelete

 

 

2008-02-18 20:41:58     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 51244   

 

So I understand this to mean that OpenCV must be compiled on the host and the selected in the menuconfig program inorder to compile.

QuoteReplyEditDelete

 

 

2008-02-18 20:53:28     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 51246    the uclinux-dist is only a convenience build system ... you can easily build applications without the distribution at all, or integrate it into the distribution so you can select it from the configuration menu ... it's up to you

QuoteReplyEditDelete

 

 

2008-02-18 21:33:36     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 51249    where do I learn about how to do this? That is, build applications into the distribution.

QuoteReplyEditDelete

 

 

2008-02-18 21:47:51     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 51250    the wiki documents everything:

http://docs.blackfin.uclinux.org/doku.php?id=adding_user_applications

QuoteReplyEditDelete

 

 

2008-02-19 11:32:48     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 51279    ok, so here is the procedure for putting an openCV program on the blackfin:

 

1.I have openCV on the host machine

2. compile a basic hello-world program on the host system(found here:http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html#SECTION00024000000000000000)

 

3.follow the instructions at the link: (http://docs.blackfin.uclinux.org/doku.php?id=adding_user_applications)

 

4. select the program in the menuconfig program (under Blackfin apps)

 

5. make and then test on the blackfin...

 

am I missing anything? Thanks.

~Shane

QuoteReplyEditDelete

 

 

2008-03-03 17:16:22     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 52004    Hi I started going through this doc (the one you posted):

http://docs.blackfin.uclinux.org/doku.php?id=adding_user_applications and I don't have this file:

<code>…/uClinux-dist/config/</code><code>Configure.help

nor do I have this file:

</code><code>…/uClinux-dist/config/</code><code>config.in

I am using 2007-R3 release

</code><code>Is there an alternate way to do this or do I need to create these files?

Thanks.

~Shane</code>

QuoteReplyEditDelete

 

 

2008-03-03 17:41:10     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 52005    those files exist in 2007R1 ... i dont know where you're looking, but they are clearly there

QuoteReplyEditDelete

 

 

2008-03-03 19:29:57     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 52008    Here is what I have:

 

skirkbri@buddha:~/bfin-sources/uclinux-dist/config$ ls

auto.conf   fixconfig  Kconfig   Makefile.conf  setconfig

autoconf.h  kconfig    Makefile  mkconfig

skirkbri@buddha:~/bfin-sources/uclinux-dist/config$

 

I'm guessing I am completely missing something...any ideas? Thanks.

QuoteReplyEditDelete

 

 

2008-03-04 06:31:23     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 52019    you said you were using 2007R1, but that is obviously svn trunk

 

the documentation does not cover svn trunk yet

QuoteReplyEditDelete

 

 

2008-03-04 11:06:44     Re: basics on compiling openCV in uClinux

Shane Kirkbride (UNITED STATES)

Message: 52034    Is there anywhere I can look to find out how to add a user application through the SVN trunk?

QuoteReplyEditDelete

 

 

2008-03-04 11:45:19     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 52039    the Makefile changes are the same as documented

 

you probably just need to update user/Kconfig to list your options

QuoteReplyEditDelete

 

 

2008-09-08 10:22:27     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 61783   

 

I'm kinda confused...  OpenCV isn't included in the uClinux/Blackfin distribution is it?  If it is, where is it?

QuoteReplyEditDelete

 

 

2008-09-08 13:11:07     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 61789   

 

it is not

QuoteReplyEditDelete

 

 

2008-09-08 13:47:46     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 61791   

 

That's what I thought...  Are you aware of anyone ever actually successfully running/using OpenCV on Blackfin/uClinux?  I'm in the process of building it now, so if there's anyone with prior experience, I'd shamelessly love to take advantage of that. :-)

QuoteReplyEditDelete

 

 

2008-09-08 14:02:29     Re: basics on compiling openCV in uClinux

Robin Getz (UNITED STATES)

Message: 61792   

 

Ed:

 

You might want to check with the SRV-1 folks - I think they were using parts/pieces of it.

 

http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl

 

-Robin

QuoteReplyEditDelete

 

 

2008-09-11 14:53:09     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62005   

 

Thanks Robin, I'm looking at the Surveyor stuff now.  Meanwhile, I've made some progress on my own.  It's built and I can install the OpenCV libraries and *almost* run one of the sample programs on my BF537 board.  The problem I have now is that my board doesn't have a display.  My guess is that somehow I will be able to hook openCV to ffmpeg and pipe the output of openCV into ffmpeg, then have ffmpeg output through mpegts to VLC running on my PC.  Does that seem like a reasonable goal for this?  If anyone reads this and has an alternate idea, or just thinks what I wanna do is stupid, please inform.

QuoteReplyEditDelete

 

 

2008-09-11 15:20:51     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 62008   

 

istr that there are simple ffmpeg programs to do both sides ... so you could pipe ffmpeg on the board to ffmpeg on your host ?

QuoteReplyEditDelete

 

 

2008-09-11 15:38:50     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62009   

 

Mike, sorry, I don't understand the question.

QuoteReplyEditDelete

 

 

2008-09-11 15:54:07     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 62010   

 

well, i wasnt asking a question ... i was suggesting a possibly simpler test method than getting vlc

 

have the Blackfin broadcast a stream using ffmpeg and have a host play it with ffplay ... but ive never tested this, i just recall snippets

 

perhaps the examples in the wiki would assist:

http://docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:ffmpeg

QuoteReplyEditDelete

 

 

2008-09-11 16:06:20     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62011   

 

Ok, then I guess that explains why I didn't understand it!  :-)

Anyway,  where does OpenCV fit into that?  I've already been able to use ffmpeg to push camera input off the board (to VLC),  my problem now is that I want OpenCV to be able to do the same.

QuoteReplyEditDelete

 

 

2008-09-11 16:19:34     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 62012   

 

i thought you wanted to test the display first to make sure it worked

 

1: test ffmpeg on board with file and display on host with ffplay/whatever

2: test ffmpeg on board with camera and display on host with ffplay/whatever

3: figure out how to pipe opencv to ffmpeg on the board ...

QuoteReplyEditDelete

 

 

2008-09-11 16:24:01     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62013   

 

Yea, #3 in your list is where I'm at.  That was what I was asking in my original question.

QuoteReplyEditDelete

 

 

2008-09-12 13:02:48     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62067   

 

Looks like my problem may be a little more fundamental than I originally thought.  I originally through that the opencv connection to V4L was working, but now I see that it isn't.  After investigating it a bit, I see that opencv is trying to query /dev/video0 for its capabilities using ioctl(VIDIOC_QUERYCAP); but then I looked at the v4l_test.c code in the distribution (which I've used successfully), and I see that it appears to do the same thing, but uses VIDIOCGCAP.

 

Further investigation of the code implies to me that VIDIOC_QUERYCAP is for V4L2, and VIDIOCGCAP is vor V4L, but I'm not sure.  Anyway, has the blackfin uclinux distribution ever been tested with V4L2 code to verify that it works?

QuoteReplyEditDelete

 

 

2008-09-12 13:08:17     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62068   

 

Hmmm... digging deeper I see that OpenCV tries V4L2, then if that fails, it tries V4L.  It appears to be trying to do the same V4L stuff as is done in user/blkfin-test/camera_test/v4l_test.c; however with v4l_test.c it works, but with openCV it does not.

 

Signed... puzzled.

QuoteReplyEditDelete

 

 

2008-09-13 07:50:10     Re: basics on compiling openCV in uClinux

Jean-Christian de Rivaz (SWITZERLAND)

Message: 62098   

 

How OpenCV fail in the target ? Did you get an error message ? If not you can try to start the application with 'strace' to get more information of what happens.

 

Note: I have see V4L application failed on blackfin because of mmap call in shared mode. Changing it to private have fixed the problem.

 

 

QuoteReplyEditDelete

 

 

2008-09-15 09:28:39     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62172   

 

I've had several problems...

 

uClinux didn't like OpenCV's V4L2 ioctl commands (i.e. VIDIOC_QUERYCAP).

 

Had to change mmap to use MAP_PRIVATE instead of MAP_SHARED (encountered a few other bugs in OpenCV as a result of this failure).

 

Had to create code in OpenCV for dealing with VIDEO_PALETTE_GREY (in cvcap_v4l.cpp), and I'm not sure if I've done it right.

 

My board (customized BF537 EZ-Kit) doesn't have a local screen, so I had to stub out the code in facedetect.c (samples/c/facedetect.c) that assumes it is there.  Sooner or later I need to figure out how to use VLC or ffmpeg for this.

 

The code in facedetect.c grabs a frame but then crashes with a page allocation error.  I'm assuming I'm just running out of heap, so I don't know what to do about this one yet.

 

Any ideas are welcome.

QuoteReplyEditDelete

 

 

2008-09-16 16:56:25     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62267   

 

Well, I'm actually running facedetect on the BF537 now; however, that ends the good news...

 

First, I'm not sure if I'm dealing with the fact that my camera is 8-bit grayscale, so I may not be feeding the correct image data to the algorithm.  Second, the OpenCV function that takes about 200msec to execute on my PC takes almost 4 minutes to run on my BF537.  That ain't good!  I'm guessing that the majority of the slow down is because of floating point, but supposedly OpenCV also has some intelligence that lets it take advantage of additional features in the pentium.  Anyway, I just hope there's things I can optimize to bring this down to a reasonable execution time.

 

By the way, the final problem that I had was that the facedetect program was crashing with a page allocation failure.  To fix this I had to change some of the memory allocation stuff in OpenCV.

QuoteReplyEditDelete

 

 

2008-09-17 13:58:48     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62327   

 

Are there any plans in the uClinux/Blackfin pipeline to tweek OpenCV to run on Blackfin?  Based on my preliminary results, its pretty clear that without a lot of tweeking, OpenCV just isn't practical on Blackfin.  Any thoughts?

QuoteReplyEditDelete

 

 

2008-09-17 14:55:38     Re: basics on compiling openCV in uClinux

Mike Frysinger (UNITED STATES)

Message: 62329   

 

currently there are no plans

QuoteReplyEditDelete

 

 

2008-09-17 15:09:56     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62331   

 

Mike,

 

Is that because there's just not enough time and/or demand?  Or is it because OpenCV is just more of a beast than Blackfin is designed to handle?  I ask because I'd like to get other folks (i.e. you) on whether or not it makes sense to just drop OpenCV now or to continue by attempting some of the optimizations myself (not sure if I'm capable of that, but sure wouldn't mind giving it a try).

QuoteReplyEditDelete

 

 

2008-09-17 19:40:23     Re: basics on compiling openCV in uClinux

Robin Getz (UNITED STATES)

Message: 62341   

 

Ed:

 

is more we have not have enough people asking for it to spend much time on it.

 

 

QuoteReplyEditDelete

 

 

2008-09-18 08:06:35     Re: basics on compiling openCV in uClinux

Ed Sutter (UNITED STATES)

Message: 62382   

 

Ok thanks...

 

Not sure what I'll do.  I'm by no means a linux or blackfin whiz, so this is likely a bigger development effort for me than I have time to allocate to it.  Sure woulda been nice though!

Attachments

    Outcomes