Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
mark12
Posts: 33
Registered: ‎01-02-2012
My Device: 9900

Re: OpenCV sample project and troubles

Im on windows tho, trying to comile it, but no luck duno what im doing wrong...if some one can write up a few steps explaining how to set it up, cmake the libraries in windows. I'm using cmake gui, and the instruction are not relavent to windows??,

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: OpenCV sample project and troubles

Okay.. I followed the README instructions from our github partial port of OpenCV here:

https://github.com/blackberry/OpenCV

On MacOS X, this built fine. no problems.

 

If you are using some gui and not following the published instructions, then you are unfortunately on your own, as I do not know what sort of gui you are using, nor do I know how to use it, nor do I have a copy of it, etc.  I am assuming you are an expert at using your tools, so this shouldn't be too difficult for you to figure out.  If you are not, then I would suggest using the recommended tools for this.  Note that once you have your library built, you should be able to link it against code generated from whatever development environment you want.

 

In any event...

 

I got my libopencv_*.so files built.  Then I created a new project in momentics called HelloOpenCV as an empty C++ screen project (Makefile).  I then opened up my common.mk, and added the path to my OpenCV libs to EXTRA_LIBVPATH and added opencv_core to LIBS.  At this point, you'll notice that the recursive makefile system will throw an error because it can't find libopencv_core.a.  Just create an empty placeholder file in the libs directory alongside the .so file and you'll be fine.  Add libopencv_core.so to your bar-descriptor assets, and you should be good to go.  (well, you'll also want to update your EXTRA_INCVPATH appropriately when you start including headers).

I found that opencv was looking for some other include files not on my include path (ext/atomicity.h and bits/c++config.h).. I found those in my NDK installation and also added the appropriate paths to my EXTRA_INCVPATH.


For the record, here are my EXTRA_INCVPATH, EXTRA_LIBVPATH, and LIBS lines (excuse the hard-coding):

EXTRA_INCVPATH+=$(QNX_TARGET)/usr/include/freetype2 \
	$(QNX_TARGET)/../target-override/usr/include \
	/Users/smcveigh/git/OpenCV/modules/core/include \
	/Users/smcveigh/git/OpenCV/modules/highgui/include \
	$(QNX_TARGET)/usr/include/c++/4.6.3 \
	$(QNX_TARGET)/usr/include/c++/4.6.3/arm-unknown-nto-qnx8.0.0eabi

# Extra library search path for target overrides and patches
EXTRA_LIBVPATH+=$(QNX_TARGET)/../target-override/$(CPUVARDIR)/lib \
	$(QNX_TARGET)/../target-override/$(CPUVARDIR)/usr/lib \
	/Users/smcveigh/git/OpenCV/build/lib

LIBS+=bps screen m opencv_core

 

I cut & paste a chunk of code from this sample into my code (excluding the part that draws to the screen):

https://github.com/blackberry/OpenCV/blob/2_4_1/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp

 

I deployed and ran this binary on my device and I can see that libopencv_core.so was loaded, and my code ran fine:

 

# pidin -p HelloOpenCV mem
     pid tid name               prio STATE            code  data        stack
54386923   1 native/HelloOpenCV  10r RECEIVE             0 4060K   12K(516K)*
54386923   2 native/HelloOpenCV  10r REPLY               0 4060K  4096(132K)
54386923   3 native/HelloOpenCV  10r RECEIVE             0 4060K  4096(132K)
            HelloOpenCV        @ 8048000             8192  8192
            libc.so.3          @ 1d10000             532K   16K
            libpps.so.1        @78000000              24K  8192
            libproxyinfo.so.1  @78018000             8192  8192
            opencv_core.so.2.4 @7801e000            1324K   28K
            libz.so.2          @78171000              60K  8192
            libm.so.2          @78190000             128K  8192
            libstdc++.so.6     @781c0000             624K   36K
            libsocket.so.3     @78277000             124K   24K
            libscreen.so.1     @782a0000              68K  8192
            libbps.so.3        @78bc0000             256K  8192
            /dev/mem           @28d00000 (       0)       3840K

So everything looks ready to use... however...

 

NOTE: our OpenCV port is using GNU STL, whereas Cascades I believe is using the Dinkum variant of those libs.  It is not likely you will be able to use this library with a Cascades project today.  We are going to look at unmangling OpenCV from GNU STL, but I cannot give a timeline for this work.

 

Cheers,

Sean

Contributor
mark12
Posts: 33
Registered: ‎01-02-2012
My Device: 9900

Re: OpenCV sample project and troubles

Hey sean,

when you compile the opencv using cmake, what kind of generator are we suppose to use, is it Mingw compiler or Eclipse CDT 4 Mingw generator, or something else?

Thanks,

 

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: OpenCV sample project and troubles

[ Edited ]

I don't know what a generator is.

I just followed the readme: called the configure script, ran ccmake to clear some options, and then ran make.

I am using the BB10 NDK's armle-v7 cross-compiling toolchain.

 

Isn't mingw for compiling windows binaries?  You are not compiling OpenCV for windows.

 

take a look at the configure-qsk script and see what options it is setting up?

Contributor
mark12
Posts: 33
Registered: ‎01-02-2012
My Device: 9900

Re: OpenCV sample project and troubles

Yes I'm using windows that's why I'm have such difficulties.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: OpenCV sample project and troubles

[ Edited ]

yes, but you are not trying to build opencv to run on windows.

 

Have you installed the BB10 NDK yet?  If so, have you installed a copy of cmake?  If so, you now have all of the tools to follow the readme and build opencv.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: OpenCV sample project and troubles

We'll get the readme updated with the windows-specific instructions shortly.

Developer
lewellyn
Posts: 110
Registered: ‎10-22-2011
My Device: PlayBook, Bold 9650, Dev Alpha A

Re: OpenCV sample project and troubles

Until the readme is updated, you might have some luck with the binary libraries I compiled.

 

http://www.greenviolet.net/~lewellyn/OpenCV-QNX.zip

 

I will be removing this archive once the readme is updated. :smileyhappy:

 

Note that I haven't had time to test them. But it's compiled per the documented instructions.

 

(And I can pretty much guarantee the person who wrote those instructions was not on Windows...)



Is there a helpful or useful post in this thread? Click the thumbs up on it so that other people can find it more easily!
Like this post too! :smileyvery-happy:
Developer
sbeeckma
Posts: 20
Registered: ‎10-09-2010
My Device: Bold 9700

Re: OpenCV sample project and troubles

New Developer
jordaan0_gmail
Posts: 23
Registered: ‎08-03-2012
My Device: BlackBerry Playbook, BlackBerry 10 dev alpha device

Re: OpenCV sample project and troubles

when the monentics ide gives the error about how it cannot find the libopencv_core.a file you say tha

Just create an empty placeholder file in the libs directory alongside the .so file and you'll be fine

 what do you mean by this statement?