FAQ: simple image processing on bf537 (2010-12-28)

Document created by Aaronwu Employee on Aug 28, 2013Last modified by sonic on Sep 8, 2013
Version 3Show Document
  • View in full screen mode

2010-12-28 07:29:47     simple image processing on bf537

Adam Therwitz (POLAND)

Message: 97033   

 

Hello.

 

 

 

I need to get few, simple 2d image operations work on my bf537stamp. Such as correlation, resizing etc.

 

I wonder now, what is the simpliest way to implement them in my system.

 

There are topics about openCV on blackfin, but I can't understand how to get it work. It's too complicated.

 

Is there any way to make f.e. CIMG library work on blackfin?

 

 

 

Summarizing, I need to :

 

- read and open a bmp file (the best form would be matrix(array)-like)

 

- do some cuts, filtering, resizing

 

- make an output bmp file

 

 

 

Do You have any ideas?

 

I know that my problem could be trivial, sorry for that.

 

 

 

Regards, DC.

QuoteReplyEditDelete

 

 

2010-12-28 12:31:09     Re: simple image processing on bf537

Mike Frysinger (UNITED STATES)

Message: 97036   

 

you could try imagemagick.  that's designed for command line based simple & dirty editing.

QuoteReplyEditDelete

 

 

2010-12-30 07:33:25     Re: simple image processing on bf537

Adam Therwitz (POLAND)

Message: 97070   

 

And what if I want to write a c/c++ programm, using such library? If it is an external library what should I do to make it run under uClinux?

QuoteReplyEditDelete

 

 

2010-12-30 11:41:12     Re: simple image processing on bf537

Mike Frysinger (UNITED STATES)

Message: 97071   

 

then link against it like any other 3rd party library

QuoteReplyEditDelete

 

 

2011-02-04 08:37:15     Re: simple image processing on bf537

Adam Therwitz (POLAND)

Message: 97926   

 

Cimg is a single header file library. It should be found in the project folder. It has been wokring great under host. So why not use it under uclinx? There is a topic about Cimg, but it make no progress for me.

 

  blackfin.uclinux.org/gf/project/uclinux-dist/forum/?_forum_action=ForumMessageBrowse&thread_id=3229&action=ForumBrowse

 

Nathalie went further, and asked about OpenCV. I wonder if that means it is hard to use Cimg after all?

 

  blackfin.uclinux.org/gf/project/uclinux-dist/forum/?_forum_action=ForumMessageBrowse&thread_id=3264&action=ForumBrowse

 

Cimg will be more usefull because it's only one file i think. So how to use a single file as a library? I know that compiler has to get specific options. But shoud I add a new library as it is written here :

 

  docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:libs:adding_libraries

 

Why the documentation is so hard to understand? Mike You look like an expert here Can You explain how to run Cimg under uclinx and is it possible at all? Many will be grateful.

 

 

 

Regards, DC.

QuoteReplyEditDelete

 

 

2011-02-04 10:29:24     Re: simple image processing on bf537

Robert Cochran (UNITED STATES)

Message: 97927   

 

I took a quick look at CImg this morning.

 

It's easy enough to compile on blackfin.  Here's a simple main.cpp file:

 

*************************** main.cpp **********************************************

 

#include <iostream>

#define cimg_OS         0               /* unix like */

#define cimg_display    0               /* disable display capabilities (X11 calls) */

#define cimg_verbosity  1               /* print library messages to console    */

 

#include "CImg.h"

using namespace cimg_library;

 

int main()      {

        std::cout << "hello world" << std::endl;

        CImg<unsigned char> image("dent.jpg"), visu(500,400,1,3,0);

        image.blur(2.5);

        image.save("dentblurred.jpg");

}

 

 

************************* end main.cpp ********************************************

 

I built it with "bfin-uclinux-g++ main.cpp -o test"  with CImg.h in my local directory.

 

I first tried it on my local x86 host after building with g++.  It worked fine and converted the file nicely.  When I tried to run it on blackfin, I got errors like: "sh: can't execute 'convert': No such file or directory"

 

It looks like the CImg library makes calls to imagemagick to do the image processing.   I don't see imagemagick in the uclinux distribution, but I remember it being discussed in the past.   Maybe someone from the blackfin team could tell us what's up with it.

 

I also tried to build up an example file with template instantiations.  One simple instantiation blew up to a 2.2 M executable.  Ouch!

 

My thought is that unless you have a strong attraction to their object oriented approach, you're probably best working with another library (perhaps just use imagmagick directly).

 

 

 

Bob

 

dentblurred.jpg

dent.jpg

QuoteReplyEditDelete

 

 

2011-02-04 12:06:17     Re: simple image processing on bf537

Mike Frysinger (UNITED STATES)

Message: 97933   

 

you need to be a little more specific than "the documentation is hard to understand".  i cant update documentation with feedback such as that.

QuoteReplyEditDelete

 

 

2011-02-05 10:52:51     Re: simple image processing on bf537

Adam Therwitz (POLAND)

Message: 97953   

 

Sorry for my mental leap about documentation. I mean that sometime is hard to figure out the procedure of making something particular under uclinux. For example i tried to use the SD/MMC reader. It works fine under u-boot. But when i want to use card reader under uclinux the documentation isnt helpfull. It does not working after all. This is just a casual suggestion with no offence. And it's not my point to talk about documentation. I cannot find info in documentation so I ask on the forum

 

Thanks for reply Robert. I also had problem with Cimg app working on blackfin. Thats why Im asking for help

 

So next step is to try Imagemagick. I understand that I need to add an external library like it is written here :

 

  docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:libs:adding_libraries

 

This is uclinux, but what I have to do under host? What about the compilation? What options should I add in compilation procedue? "Using The Library" topic in link above is missing

QuoteReplyEditDelete

 

 

2011-02-05 15:14:03     Re: simple image processing on bf537

Mike Frysinger (UNITED STATES)

Message: 97954   

 

what header files you include or libraries you link against depend completely on the library.  there's no way we could document that in the wiki.  this page talks about general staging dir usage with libraries compiled via uclinux-dist:

  docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:existing_libraries#using_libs_in_external_applications

 

but if you want to know how to use Cimg (includes/link lines/etc...), then you should read the Cimg documentation in the source tree and/or the Cimg homepage.

QuoteReplyEditDelete

 

 

2011-02-05 18:14:53     Re: simple image processing on bf537

Robert Cochran (UNITED STATES)

Message: 97955   

 

just took a quick look at the imagemagick configure script.  It has a lot of dependencies: doesn't seem appropriate for an embedded system to me.

QuoteReplyEditDelete

 

 

2011-02-06 14:47:23     Re: simple image processing on bf537

Adam Therwitz (POLAND)

Message: 97968   

 

Ok. So my investigation brings only one alternative now. OpenCV.

 

blackfin.uclinux.org/gf/project/uclinux-dist/forum/

 

Concerning to this thread there is a possibility to make it run on Blackfin (it would be like heaven instead of cimg or im :))

 

I found also something like that :

 

leanxcam.origo.ethz.ch/wiki/opencv

 

That's promising too I think. Can You peek at it?

QuoteReplyEditDelete

 

 

2011-02-09 06:39:51     Re: simple image processing on bf537

Adam Therwitz (POLAND)

Message: 98023   

 

Hi.

 

I tried to compile few opencv releases.

 

---------------------------------------------------------------------- opencv.1.1.0

 

- ok after $ sudo ./configure --build=i686-pc-linux-gnu --host=bfin-uclinux

 

- errors while $ sudo make

 

cxswitcher.cpp:60:19: błąd: dlfcn.h: Nie ma takiego pliku ani katalogu (cannot find folder)

cxswitcher.cpp: In function ‘int icvUpdatePluginFuncTab(CvPluginFuncInfo*)’:

cxswitcher.cpp:437: error: ‘dlsym’ was not declared in this scope

cxswitcher.cpp: In function ‘int cvUseOptimized(int)’:

cxswitcher.cpp:580: error: ‘dlclose’ was not declared in this scope

cxswitcher.cpp:607: error: ‘RTLD_LAZY’ was not declared in this scope

cxswitcher.cpp:607: error: ‘dlopen’ was not declared in this scope

make[3]: *** [cxswitcher.lo] Błąd 1 (error)

make[3]: Opuszczenie katalogu `/home/daniel/x/opencv-1.1.0/cxcore/src' (leaving dir)

make[2]: *** [all-recursive] Błąd 1 (error)

make[2]: Opuszczenie katalogu `/home/daniel/x/opencv-1.1.0/cxcore' (leaving dir)

make[1]: *** [all-recursive] Błąd 1 (error)

make[1]: Opuszczenie katalogu `/home/daniel/x/opencv-1.1.0' (leaving dir)

make: *** [all] Błąd 2 (error)

 

 

- don't know what happend because of :

 

blackfin.uclinux.org/gf/project/uclinux-dist/forum/ (15151 message).

 

- my ubuntu is bad I think

 

- Porting OpenCV on Blackfin.doc ... doesnt work

 

---------------------------------------------------------------------- opencv.2.2.0

 

- ok after $ sudo ./configure --build=i686-pc-linux-gnu --host=bfin-uclinux

 

- similar problems while make

 

- tried with different ./configure options (from leanxcamthing and the document attached) without progress

 

---------------------------------------------------------------------- opencv.2.x.x

 

- only this works :

 

leanxcam.origo.ethz.ch/wiki/opencv

 

- ./do-build works (configuration and make)

 

- libs are ok (for target and for host in diff folders)

 

---------------------------------------------------------------------- c/cpp file compilation

 

- static libraries (hidden .libs, and include/cv) in my project folder

 

- but while c/cpp file compilation for host I got error (g++ compiler cannot find my test.c file... ??)

 

- error after : $ sudo g++ -Wall -Wl,-o test test.c -I ./ -L./ -lcvaux -lcv -lcxcore -lpthread -lrt

 

- ok after : $ sudo bfin-uclinux-g++ -Wall -Wl,-elf2flt -o test test.c -I ./ -L./ -lbfdsp -lcvaux -lcv -lcxcore -lpthread -lrt

 

- tried with other compilers (gcc ...) and options

 

    host: -lcvaux -lcv -lcxcore -lpthread -ldl -lrt -lz

    target: -lbfdsp -lcvaux -lcv -lcxcore -lpthread -lrt

 

- I cannot understand why app for target compilation is ok while host fails

 

- I don't have my 537stamp now. I'll try the executable file in a week or so.

 

 

 

Any suggestions ?

 

Regards, DC.

 

Porting OpenCV on Blackfin.doc

QuoteReplyEditDelete

 

 

2011-02-09 10:15:21     Re: simple image processing on bf537

Mike Frysinger (UNITED STATES)

Message: 98032   

 

dlopen will only work with the FDPIC toolchain.  if you really really want to build it as FLAT, then you'll have to see if there's an option to disable dlopen support, or hack it away yourself.  assuming of course that the library doesnt use dlopen for everything, in which case you must use FDPIC.

QuoteReplyEditDelete

Attachments

Outcomes