ARM-wrestling with OpenCV
Posted on : 12-03-2009 | By : Igor Stepura | In : OpenCV
45
I played with two ARM9-based single board computers (SBC) recently to investigate how OpenCV would operate on embedded platforms. The SBCs are – TS-7800 and SBC2440-III.
OpenCV uses floating point operations a lot, but not all of the ARM processors have FP coprocessor, so developers should use either some FP library, or as in my case – use Linux kernel FP emulation. There are two types of such emulation OABI and EABI. More details can be found here and here. Kernel release 2.6.16 was the first one to include ARM EABI support.
Unfortunately, CPUs of both SBCs do not support floating point in hardware, but luckily enough, TS-7800 has Debian Linux with 2.6.21 kernel. So I had a chance to compare OpenCV performance for OABI and EABI.
Both SBCs have necessary tool-chains in package – TS-7800 has Linux and Windows(Cygwin) tool-chains, SBC-2440 – only Linux one. In addition to these I downloaded newer release of Codesourcery ARM tool-chain for Windows, because the one from TS-7800 SW package didn’t work properly with Cygwin.
I wrote a pretty simple script to ease OpenCV (version 1.1pre1 from here) configuration for various toolchains. Here it is:
#!/bin/bash ##======== TS-7800 environment settings====== #### Linux host. EABI complier #export DEVROOT=/opt/crosstool/arm-none-linux-gnueabi #export APP_PREFIX=arm-none-linux-gnueabi #export GCC_HOST=i686-pc-linux-gnu ##-O3 kills gcc : cvpyrsegmentation.cpp:1021: internal compiler error: in verify_local_live_at_start, at flow.c:546 #export OFLAGS=-O2 ### Linux host. OABI compiler #export DEVROOT=/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2 #export APP_PREFIX=arm-linux #export GCC_HOST=i686-pc-linux-gnu ##Any optimization causes SEGFAULTS during face detection application execution #export OFLAGS=-O0 ### Windows (Cygwin) host. EABI compiler (Codesourcery 2008q3-72) export APP_PREFIX=arm-none-linux-gnueabi export DEVROOT=/opt/crosstool/codesourcery export CYGPATH=d:/cygwin/bin/cygpath export GCC_HOST=i686-pc-cygwin ###Windows (Cygwin) host. OABI compiler #export APP_PREFIX=arm-unknown-linux-gnu #export DEVROOT=/opt/crosstool/gcc-3.3.4-glibc-2.3.2 #export CYGPATH=d:/cygwin/bin/cygpath #export GCC_HOST=i686-pc-cygwin ##Any optimization causes SEGFAULTS during face detection application execution #export OFLAGS=-O0 ##======== SBC2440-III environment settings====== ####Linux host only. OABI compiler only. (Out of the box kernel does not support EABI) #export DEVROOT=/usr/local/arm/3.4.1 #export APP_PREFIX=arm-linux #export GCC_HOST=i686-pc-linux-gnu ##Any optimization causes SEGFAULTS during face detection application execution #export OFLAGS=-O0 ##=============================================== export PATH=$DEVROOT/$APP_PREFIX/bin:$PATH ./configure \ --target=$APP_PREFIX \ --host==$APP_PREFIX \ --build=$GCC_HOST \ --disable-shared \ --enable-static \ --without-imageio --without-carbon \ --without-quicktime --without-python \ --without-gtk --without-swig \ --without-v4l \ --disable-apps \ --prefix=$DEVROOT/$APP_PREFIX \ CC=$DEVROOT/bin/$APP_PREFIX-gcc \ CXXFLAGS="-fsigned-char $OFLAGS -pipe" \ LD=$DEVROOT/bin/$APP_PREFIX-ld \ CPP=$DEVROOT/bin/$APP_PREFIX-cpp \ CXXCPP=$DEVROOT/bin/$APP_PREFIX-cpp \ CXX=$DEVROOT/bin/$APP_PREFIX-g++ \ AR=$DEVROOT/bin/$APP_PREFIX-ar \ RANLIB=$DEVROOT/bin/$APP_PREFIX-ranlib \ NM=$DEVROOT/bin/$APP_PREFIX-nm \ STRIP=$DEVROOT/bin/$APP_PREFIX-strip \ AS=$DEVROOT/bin/$APP_PREFIX-as
Just uncomment setting you need, and comment all the others and you’re all set. -fsigned-char in CXXFLAGS is a must. OpenCV will (somehow) work even without this flag, but some functionality will be broken – JPEG parser for example (to say the truth, it will still be broken event with -fsigned-char, but at least it will correctly parse JPEG headers).
After script finished run make and then make install . Libraries and headers will be placed in directory, specified with --prefix= parameter.
Now when OpenCV is built and ready it’s time to “feel the power in your ARMs”.
I used facedetect sample application (/samples/c/) to test OpenCV on SBCs. I had to remove UILib -related code and add ome more parameter to application, named --extension, which allows specifying of input file type (BMP, YML, JPG). Changes I made to file can be observed here
The makefile I sued to build the application is written in a way similar to the previous configure script:
# TS-7800 environment settings #DEVROOT=/opt/crosstool/arm-none-linux-gnueabi #APP_PREFIX=arm-none-linux-gnueabi #SBC2440-III environment settings #DEVROOT=/usr/local/arm/3.4.1 #APP_PREFIX=arm-linux #CodeSourcery setup DEVROOT=/opt/crosstool/codesourcery APP_PREFIX=arm-none-linux-gnueabi CC = $(DEVROOT)/bin/$(APP_PREFIX)-g++ CPP = $(DEVROOT)/bin/$(APP_PREFIX)-cpp LD=$(DEVROOT)/bin/$(APP_PREFIX)-ld CXXFLAGS = -I"$(DEVROOT)/$(APP_PREFIX)/include" -I"$(DEVROOT)/$(APP_PREFIX)/include/opencv" CXXFLAGS+= -fsigned-char LDFLAGS = -static -L"$(DEVROOT)/$(APP_PREFIX)/lib" -lcv -lhighgui -lcxcore -lml -lcvaux -lpthread -ldl all: facedetect.o $(CC) facedetect.o $(LDFLAGS) -o facedetect facedetect.o: $(CC) $(CXXFLAGS) -c facedetect.c clean: rm -f facedetect facedetect.o
Copy and paste this text to a file, say makefile_facedetect, and then use it: make -f makefile_facedetect. It will build statically linked executable – I didn’t want to bother with shared OpenCV libraries.
The file used to detect face was lena.jpg (512×512) from OpenCV samples/c/ directory. I also converted it to BMP and YML, since JPEG parser does not work properly on ARM.
Execution results
TS-7800
EABI build: detection time = 31 512.1ms
SBC-2440-III
OABI build: detection time = 448 151 ms
Conclusions:
1) EABI is MUCH better than OABI
2) Even with EABI FP support, there is still much needed to be improved in OpenCV to make it usable on ARM processors.



Which version of OpenCV you’ve used for performance measures?
I’m trying to complete the first step you mentioned, i.e. “make (i) Opencv
> work on the ARM-montavista-linux (which I did quite quickly)”.
>
> When I try to compile the OpenCV sources, I get the following error
> compiling cv/src/cvpyrsegmentation.cpp
>
> if /bin/sh ../../libtool –tag=CXX –mode=compile g++ -DHAVE_CONFIG_H -I.
> -I. -I../.. -I. -I../../cv/include -I../../cxcore/include -I../..
> -DNDEBUG -Wall -fno-rtti -pipe -O3 -fomit-frame-pointer -MT
> cvpyrsegmentation.lo -MD -MP -MF “.deps/cvpyrsegmentation.Tpo” -c -o
> cvpyrsegmentation.lo cvpyrsegmentation.cpp; \
> then mv -f “.deps/cvpyrsegmentation.Tpo” “.deps/cvpyrsegmentation.Plo”;
> else rm -f “.deps/cvpyrsegmentation.Tpo”; exit 1; fi
> g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I../../cv/include
> -I../../cxcore/include -I../.. -DNDEBUG -Wall -fno-rtti -pipe -O3
> -fomit-frame-pointer -MT cvpyrsegmentation.lo -MD -MP -MF
> .deps/cvpyrsegmentation.Tpo -c cvpyrsegmentation.cpp -fPIC -DPIC -o
> .libs/cvpyrsegmentation.o
> cvpyrsegmentation.cpp: In function `CvStatus
> icvPyrSegmentation8uC3R(uchar*, int, uchar*, int, CvSize, CvFilter,
> CvSeq**, CvMemStorage*, int, int, int)’:
> cvpyrsegmentation.cpp:1021: internal compiler error: in
> verify_local_live_at_start, at flow.c:546
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Send email to MontaVista Software, Inc. for instructions.
> make[3]: *** [cvpyrsegmentation.lo] Error 1
> make[3]: Leaving directory `/home/opencv/tmp/opencv-1.0.0/cv/src’
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/home/opencv/tmp/opencv-1.0.0/cv’
> make[1]: *** [all-recursive] Error 1
> make: *** [all] Error 2
> make[1]: Leaving directory `/home/opencv/tmp/opencv-1.0.0′
>
>
> Do you know something about it?
>
> Thanks in advance and regards.
This is exactly same error which is described in the very beginning of my configure script. Setting optimization level to -O2 or -O0 will help you.
Think you
my configure script is
root@danvinci-desktop:/work/opencv-1.1.0# export OFLAGS=-O2
root@danvinci-desktop:/work/opencv-1.1.0# ./configure –prefix=/opt/opencv1 –host=arm-linux –without-gtk –without-carbon –without-quicktime –without-1394libs –without-ffmpeg –without-python –without-swig –enable-static –disable-shared –disable-apps CXX=arm_v5t_le-g++ CPPFLAGS=-I/opt/mv_pro_4.0/montavista/pro/devkit/lsp/ti-davinci/include/ CC=arm_v5t_le-gcc AR=arm_v5t_le-ar RANLIB=arm_v5t_le-ranlib
but still the same error
cvpyrsegmentation.cpp:1021: internal compiler error: in
> verify_local_live_at_start, at flow.c:546
You set OFLAGS but never use it in your ./configure script execution. Just append CXXFLAGS=-O2 to ./configure parameters
It was OpenCV 1.1 pre1
Hello Igor.
First of all thank you for the great material.
I work with a similar SBC, the SBC2440-I. I used your script for the installation of opencv on the host computer (ubuntu 8.10, 32 bit), uncommenting from the line “== SBC2440-III environment settings==”. Although I successfully go through the installation, when I try to compile a simple test archive, I get the following errors:
/tmp/cc7ambMf.o(.text+0×2c): In function `main’:
: undefined reference to `cvLoadImage’
/tmp/cc7ambMf.o(.text+0×40): In function `main’:
: undefined reference to `cvNamedWindow’
/tmp/cc7ambMf.o(.text+0×4c): In function `main’:
: undefined reference to `cvShowImage’
/tmp/cc7ambMf.o(.text+0×54): In function `main’:
: undefined reference to `cvWaitKey’
/tmp/cc7ambMf.o(.text+0×60): In function `main’:
: undefined reference to `cvReleaseImage’
/tmp/cc7ambMf.o(.text+0×68): In function `main’:
: undefined reference to `cvDestroyWindow’
collect2: ld returned 1 exit status
Seems like it doesn’t know what to do with highgui functions.
The compilation comand I use is: /usr/local/arm/3.4.1/bin/arm-linux-gcc -I/usr/local/arm/3.4.1/arm-linux/include/opencv -lcv -lhighgui -lstdc++ -o Im1 Im1.cpp
where Im1 is the file name. This file compiles without a problem with gcc compiler with similar comand (gcc -I/usr/local/include/opencv -lhighgui -o Im1 Im1.cpp)
The file is a silly test file: (I only put it here in case you think it might be the problem)
#include
#include “cv.h”
#include “highgui.h”
int main(int argc, char** argv)
{
IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow(“Im1″,0);
cvShowImage(“Im1″,img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow(“Im1″);
}
I would greatly appreciate any help or advise you could give me on the subject
Thanks in advance
Valery,
1) You seem to be missing -L flag that specifies OpenCV libraries path in build command. In your case it should be -L/usr/local/arm/3.4.1/arm-linux/lib
2) The OpenCV build made with configure script from this post would have no UI support (–without-gtk parameter to configure script), so HighUI library will throw exceptions for any UI-related code. You’ll have to cross-compile GTK and remove “–without-gtk” from configure script to get UI working.
Do let me know if you have more questions.
Igor,
Thanks for the quick reply. I tried to follow your advise, but got into trouble cross-compiling gtk. Here’s what I did:
-Downloaded gtk+-2.12.12.tar.gz, extracted it.
-Downloaded the dev’s for pango atk and cairo and afterwards ran the following command:
./configure CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc –enable-shared –host=arm-linux –target=arm-linux –prefix=/usr/local/arm/3.4.1/arm-linux/ –without-libtiff –without-libjpeg –x-libraries=/usr/local/arm/3.4.1/arm-linux/lib
This returned the following error message:
checking for XOpenDisplay… no
configure: error: *** libX11 not found. Check ‘config.log’ for more details.
- Then I downloaded libx11-6_1.0.3-7_arm.deb (libx11 already configured for arm), extracted, manually copied the …/libx11-6_1.0.3-7_arm/usr/lib/libX11.so.6.2.0 to /usr/local/arm/3.4.1/arm-linux/lib,changed its mode to executable and created two soft links libX11.so and libX11.so.6. However this didn’t fix the problem.
- After searching the web I saw few people suggesting that it might be the absence of the libxext package. I downloaded and extracted libxext-dev_1.0.1-2_arm.deb and libxext6_1.0.1-2_arm.deb, (also configured for arm) and again, manually copied to /usr/local/arm/3.4.1/arm-linux/lib the files:libXext.a and libXext.so.6.4.0. I also created the links libXext.so and libXext.so.6
Unfortunately this didn’t help to install gtk ether, the error remained.
I would appreciate any suggestion you might have regarding the problem.
Thank you,
Valery
I haven’t tried cross-compilling of GTK yet, so I can’t say what could have caused your problem for sure. General advise for all the “dances” with ./configure – look into config.log to see exact cause of the failure. Usually configure script creates and compiless small test applications and determines if needed library is present basing on compilation/linking output. Just check why test code for XOpenDisplay failed.
Has anyone had any luck getting OpenCV running with the ARM-powered SheevaPlug w/Debian? I get the following error:
uvcvideo: Failed to submit URB 0 (-28)
VIDIOC_STREAMON error 28, No space left on device.
It seems like SheevaPlug / Debian recognizes my Logitech cameras, and it looks like I successfully open it from Python. However, when I try to grab a frame from it (using Python) I have problems.
Thanks for any ideas …
Brian, have you tried running luvcview on your SheevaPlug? I wonder would it work or not. According to “internets” ENOSPC(-28) could be caused either with USB bandwith or with memory problems.
Take a look at this post for example – http://lists.berlios.de/pipermail/linux-uvc-devel/2008-January/002775.html
You can try building OpenCV with libjpeg support, so it will get frames in MJPEG format, which requires less memory for each frame. May be it would help.
Great info.
How compatible are those optimizations for the iPhone ARM processors?
Hi Igor,
A long time since I had my first doubt…
As I stated in my last post, I use the SBC2440-I for image processing from webcam (starts with face detection)
I compiled OpenCV, and the program I want to run on ARM Qemu virtual machine as a native compilation, and it works fine. The program uses the Haar cascade classifier. It runs fine on the PC (the x86 compiled version), but on the SBC it returns “segmentation fault” message, once it gets to the instruction:
CvSeq* faces = cvHaarDetectObjects( img, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) );
I believe, the program you ran on the SBC2440-III uses the same classifier and the same function. I think, I ether extrapolate the memory with this command, or some pointer gets lost… Have you had this problem? The SBC-I and the SBC-III versions might be slightly different, my board has 64M or nand flash and 64M of RAM. It runs the 2.6.13 linux kernel with yaffs as the file folder system.
When I installed OpenCV on Qemu virtual machine I didn’t pass -fsigned-char in CXXFLAGS. Do you think that might be the problem?
Hope you can shed some light on my problem
Thanks in advance.
P.S. I decided it would probably be easier with the code, so here it is (pretty standard)
#include “highgui.h”
#include “cv.h”
#include
#include
#include
#include
#include
#include
using namespace std;
const char* cascade_name =
“haarcascade_frontalface_alt.xml”;
void detect_and_draw( IplImage* image );
int main( int argc, char** argv )
{
IplImage* img;
IplImage* frame;
IplImage* frame_copy;
clock_t start, end;
CvCapture* capture = cvCreateCameraCapture(0);
// get 20 frames:
for (int i=1; i<21 ; i++)
{
cout << “Frame ” << i << “. \n”;
//Tempo comeca aqui (timing execution)
start = clock();
///////////////////////////
frame=cvQueryFrame(capture);
if(!frame){ cout <width,frame->height),8,1);
cvCvtColor(frame,img,CV_BGR2GRAY);
detect_and_draw(img);
//Tempo verificado aqui
end = clock();
///////////////////////////////////////
printf (“Execution time: %.1f ms.\n”,(double)( ((end + 0.0)-(start + 0.0))*1000 / CLOCKS_PER_SEC) );
// Grava o vigesimo frame com janela de rosto no arquivo test1.jpg
// Saves the twentieth image
if (i==20){
cvSaveImage(“test1.jpg”,img);
}
cvReleaseImage( &img );
} // fecha o laco de 20 vezes
cvReleaseCapture(&capture);
return 0;
} //termina main end main
/////////////////////////////////////////////////////////////////////////////////
// Detecta face e desenha quadrado
void detect_and_draw( IplImage* img )
{
static CvMemStorage* storage = 0;
static CvHaarClassifierCascade* cascade = 0;
////////////////////////////////////////////////////
int scale = 1;
IplImage *temp = cvCreateImage( cvSize( img->width/scale, img->height/scale), 8, 3 );
CvPoint pt1, pt2;
pt1.x=0;
pt1.y=0;
int i;
cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 );
//////////////////////////////////////////////////////////////////////////
if( !cascade )
{
fprintf( stderr, “ERRO!: Nao carregou o classificador cascade\n” );
return;
}
storage = cvCreateMemStorage(0);
if( cascade )
{
CvSeq* faces = cvHaarDetectObjects( img, cascade, storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(40, 40) );
for( i = 0; i total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
cvRectangle( img, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
}
}
if (pt1.x == 0 && pt1.y == 0)
{
cout << ” Nao achei rosto \n”;
}
else { cout << ” rosto ok!\n”;
}
/////////////////////////////////////////////////////////////
cvReleaseImage( &temp );
cvReleaseHaarClassifierCascade( &cascade );
cvReleaseMemStorage(&storage );
}
I had SEGFAULTs on SBC2440-III when tried to run facedetect too. It faulted either in cvHaarDetectObjects() or in cvResize() depending on parameters I passed to sample facedetect application. Issue had gone when I set -O0 flag to compiler (Check comments in OABI compiler sections in my configuration script, I mentioned that). I still don’t know real root cause for these SEGFAULTs, but I suspect they have something to do with GCC version or with particular GCC build issues.
Igor
Thanks for the previous reply.
However, It still returns segfault.
This is the command I use to configure opencv:
./configure –host=i686-pc-linux-gnu –target=arm-linux CC=arm-linux-gcc CXX=arm-linux-g++ LD=arm-linux-ld CPP=arm-linux-cpp CXXCPP=arm-linux-cpp AR=arm-linux-ar RANLIB=arm-linux-ranlib NM=arm-linux-nm STRIP=arm-linux-strip AS=arm-linux-as –prefix=/usr/local/arm/ –exec-prefix=/usr/local/arm/ –disable-shared –enable-static –without-imageio –without-carbon –without-quicktime –without-python –without-gtk –without-swig –disable-apps CXXFLAGS=”-fsigned-char -O0″
I even changed the default CXXFLAG from -O3 to -O0 in the configure executable before running, as I saw that when I do make, it still used -O3 optimizing.
Then, after successful installation I create the binary code (also sucessfuly) with:
sudo arm-linux-g++ -fsigned-char -O0 -static /home/v/project/ACTSC.cpp -o /home/v/Desktop/TvoyuMat -I /usr/local/arm/include/opencv/ -L /usr/local/arm/lib/ -lcv -lhighgui -lcxcore -lcvaux -lpthread -ldl
But when I run it on the board, I still get segfault while executing cvHaarDetectObject. What am I doing wrong?
P.S. Humorous note: The name of the created binary file shows how I feel, he he he.
Thanks again
Igor, you also mentioned that you had segfaults depending on parameters you passed to the application. Which parameters didn’t result in segfault?
Valery, these SEGFAULTs seem to be caused with some compiler bug. I’ve compiled OpenCV & facedetect application myself today with 2 compilers – the one that was in SBC2440-III SW package (gcc 3.4.1) and the OABI compiler that went with TS-7800 (gcc 3.3.4). Application compiled with SBC2440-III compiler segfaulted, while application compiled with TS-7800 compiler ran fine. Most probably I used gcc 3.3.4 to build OpenCV to run on SBC2440-III (it was a while ago, so I don’t remember this for sure). You can get “good” compiler here – ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7200-linux/cross-toolchains/ . I’ve used crosstool-cygwin-gcc-3.3.4-glibc-2.3.2, you might want to use linux version crosstool-linux-gcc-3.4.4-glibc-2.3.2 or even try gcc 4.0.1.
I Igor, thanks for your infos on this topic. Your tutorial is the best one I found out on the web till now.
I’m working on ARM9 (Olimex SAM9-L9260). I have a question about compiler and EABI/OABI support. How can I get a EABI or OABI compiler and how can I distinguish if my compiler is EABi or OABI or neither of them?
I’m using crosstool provided by Dan kegel but I’m not able to configure his script to avoid the problem of SEGFAULT on face detection.
Any suggestions will be appreciated.
thanks in advance
francesco
Francesco, it’s pretty easy to check what ABI executable was build for.
Just do “
readelf -h | grep Flags” . In case of OABI binary it should displayor
For EABI:
or
You can also check your if embedded distro’s kernel supports EABI by grepping for “ABI” in kernel config – “
zcat /proc/config.gz | grep ABI”In case of EABI kernel it would display something like this:
If kernel supports only OABI, you migth try different toolchain (like the one I suggested for Valery).
Good luck.
P.S. Found interesting forum thread that might also be helpful http://forum.sparkfun.com/viewtopic.php?p=58439&sid=242428f3e3b32b6d505b60d23e1aa62e
Hi Igor,
face detection on my ARM board, thank to your support, work fine but computation time is too much for my application as you mentioned in your notes.
I need to develop an application for tracking moving objects. Do you have any suggestion to find a very simple Algorithm (for ARM Architecture with no FPU) able to check the presence of particular object in a given image?
thank you
F
Well, Francesco, welcome to the world of Computer Vision. I have no direct answer for you question, just very old and good advice “… seek, and ye shall find …”. This is where all fun starts.
You might want to start from looking at CMUcam – they were able to do face detection on ARM7. Source is at http://www.cmucam.org/browser
Hi Igor,
your support is very precious, i looked at the camera you suggested. This camera work at 60 Mhz and guarantee 1 face detection every 5 6 seconds. It’s not enough for our purpose. Might ARM9 (with FPU) be faster? Do you know any ARM9 evaluation board equipped with FPU?
Thank you again for your time.
F
Hi Igor,
I am trying to compile OpenCV source on WinXP + Cygwin, but when I try I get the following error I have no clue why. May be I am missing some thing.
/cxcore/cxdxt.cpp:59: error: expected `)’ before ‘/’ token
Configure options:
./configure –disable-shared –enable-static –without-imageio –without-carbon –without-quicktime –without-python –without-gtk –without-swig –without-v4l CC=$DEVROOT/bin/g++ CXXFLAGS=”-fsigned-char -O0 -pipe”
Thanks
Sen
What OpenCV version do you try to compile? I never saw this error with OpenCV 1.1pre1.
I have no ideas about what could have caused it, but you might try looking at preprocessor output to see what exactly is passed to compiler in /cxcore/cxdxt.cpp:59 (there’s a lot of macro-typedefs-to-break-your-brains there). To get preprocessor output you’ll have to edit /cxcore/src/Makefile and change the line that goes after
.cpp.o:target.You’ll need to change -c option to -E, so the whole line will look like
$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -E -o $@ $<.After that run make cxdxt.o from /cxcore/src/ and you will get cxdxt.o as a preprocessed source file you can inspect.
Add a #undef log2 above the log2 function defined in cxdxt.cpp — basically the pre-compiler is pulling the log2 macro from cmath.h and replacing the method declaration with the macro definition.
Hi, this helped me, but brought me an other error:
cxcore/cxmatmul.cpp: in function ‘void cv::gemm(const cv::Mat&, const cv::Mat&, double, const cv::Mat6):
cxcore/cxmatmul.cpp:624: error: requested for member ‘data’ in ‘32′, which is of non-class type ‘int’
[...]
hi Igor,
I’ve try your tutorial with my source code. like this:
#include “cv.h”
#include “ml.h”
#include “cxcore.h”
#include “cxtypes.h”
#include “highgui.h”
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage( “edk.jpg” );
cvNamedWindow( “Example1″, CV_WINDOW_AUTOSIZE );
cvShowImage(“Example1″, img);
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( “Example1″ );
return 0;
}
It seems compiled successfully and yield ‘tescv’ application.I want to apply it to my Mini2440 board. After I copy tescv and edk.jpg, and executing, there is no response from my Mini2440. what is the problem?
I use arm-linux-g++ 3.4.1 like the tutorial but the board use 4.3.2, does it matter?
thanks, Enas -Indonesia
Enas. OpenCV configured and built using my script will not have GUI support, any call to GUI functions will cause program abort. This might be the reason why your program hangs. Moreover, as I wrote in post, OpenCV has issues with JPEG files on ARM, so they won’t be properly loaded.
hello Igor, can I have the source code you use in this tutorial? I have some error when compile the source code in ’samples’ folder
thanks
Enas, you can take a look at the code here – http://computer-vision-software.com/blog/wp-content/uploads/2009/03/diff.htm
Dear Igor,
Do you have any idea how to make program with opencv in mini2440? (like sbc2440) I have angstrom-linux in my mini2440
Hi there,
first of all thanks for your skript. It helped me to understand how to get going with compiling opencv for ARM. Nonetheless i’m stucking right at the beginning. I used your script and modified it to fit my needs.
Here it comes:
#!/bin/bash
### Windows (Cygwin) host.
export APP_PREFIX=arm-none-eabi
export DEVROOT=/cygdrive/c/_devtools/CodeSourcery/SourceryG++Lite
export CYGPATH=C:/Program\ Files/cygwin/bin/
./configure \
–target=$APP_PREFIX \
–host=$GCC_HOST \
–disable-shared \
–enable-static \
–without-imageio –without-carbon \
–without-quicktime –without-python \
–without-gtk –without-swig \
–without-v4l \
–disable-openmp \
–disable-apps \
–prefix=$DEVROOT/$APP_PREFIX \
CC=$DEVROOT/$APP_PREFIX/bin/gcc \
CXXFLAGS=”-fsigned-char $OFLAGS -pipe” \
LD=$DEVROOT/$APP_PREFIX/bin/ld \
CPP=$DEVROOT/$APP_PREFIX/bin/cpp \
CXXCPP=$DEVROOT/$APP_PREFIX/bin/cpp \
CXX=$DEVROOT/$APP_PREFIX/bin/g++ \
AR=$DEVROOT/$APP_PREFIX/bin/ar \
RANLIB=$DEVROOT/$APP_PREFIX/bin/ranlib \
NM=$DEVROOT/$APP_PREFIX/bin/nm \
STRIP=$DEVROOT/$APP_PREFIX/bin/strip \
AS=$DEVROOT/$APP_PREFIX/bin/as
When executing the script file opencv won’t configure correctly but end with an error:
configure: error: in /cygdrive/opencv
configure: error: C++ compiler cannot create executables.
The config.log shows:
configure:3079: $? = 0
configure:3086: /cygdrive/c/_devtools/CodeSourcery/SourceryG++Lite/arm-none-eabi/bin/g++ -v >&5
Using built-in specs.
Target: arm-none-eabi
Configured with: /scratch/maxim/arm-lite/src-4.3-arm-none-eabi-lite/gcc-4.3/configure –build=i686-pc-linux-gnu –host=i686-mingw32 –target=arm-none-eabi –enable-threads –disable-libmudflap –disable-libssp –disable-libstdcxx-pch –with-gnu-as –with-gnu-ld –enable-languages=c,c++ –disable-shared –with-newlib –with-pkgversion=’Sourcery G++ Lite 2009q1-161′ –with-bugurl=https://support.codesourcery.com/GNUToolchain/ –disable-nls –prefix=/opt/codesourcery –with-headers=yes –with-sysroot=/opt/codesourcery/arm-none-eabi –with-build-sysroot=/scratch/maxim/arm-lite/install-4.3-arm-none-eabi-lite/host-i686-mingw32/arm-none-eabi –with-libiconv-prefix=/scratch/maxim/arm-lite/obj-4.3-arm-none-eabi-lite/host-libs-2009q1-161-arm-none-eabi-i686-mingw32/usr –with-gmp=/scratch/maxim/arm-lite/obj-4.3-arm-none-eabi-lite/host-libs-2009q1-161-arm-none-eabi-i686-mingw32/usr –with-mpfr=/scratch/maxim/arm-lite/obj-4.3-arm-none-eabi-lite/host-libs-2009q1-161-arm-none-eabi-i686-mingw32/usr –disable-libgomp –enable-poison-system-directories –with-build-time-tools=/scratch/maxim/arm-lite/obj-4.3-arm-none-eabi-lite/tools-i686-pc-linux-gnu-2009q1-161-arm-none-eabi-i686-mingw32/arm-none-eabi/bin –with-build-time-tools=/scratch/maxim/arm-lite/obj-4.3-arm-none-eabi-lite/tools-i686-pc-linux-gnu-2009q1-161-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-161)
configure:3090: $? = 0
configure:3097: /cygdrive/c/_devtools/CodeSourcery/SourceryG++Lite/arm-none-eabi/bin/g++ -V >&5
g++.exe: ‘-V’ option must have argument
configure:3101: $? = 1
configure:3124: checking for C++ compiler default output file name
configure:3146: /cygdrive/c/_devtools/CodeSourcery/SourceryG++Lite/arm-none-eabi/bin/g++ -fsigned-char -pipe conftest.cpp >&5
g++.exe: CreateProcess: No such file or directory
configure:3150: $? = 1
configure:3188: result:
configure: failed program was:
Do you have an idea what i’ve done wrong?
Hi there,
thanks for your great script. I get opencv 1.1pre1 configured in no time, but i’m having trouble compiling it.
When typing “make” I get the following errors:
cxerror.cpp:96: error: ‘pthread_key_t’ does not name a type
cxerror.cpp:424: error: ‘g_TlsIndex’ was not declared in this scope
cxerror.cpp:424: error: ‘phtread_key_create’ was not declared in this scope
Do you have any idea why this happens?
I reckon you’re using Cygwin host. Have you set CYGPATH variable before running the script? Section 2.6.1.2 “Working with Cygwin” of Sourcery G++ Lite “Getting Started” document.
I am bit confused why most websites who have an article state argument to./configure attribute –host = arm-linux. while in your case you states –host=i686-pc-linux. Now is the host the real host (e.g. x86 based laptop on which we are compiling) or is it the target which hosts the compiled program – either after NFS mounted or other method (e.g. Gumstix, Davinci, Beagleboard) ?
Good catch! I checked with autoconf documentation and you’re right – the –host parameter specifies “the type of system on which the package runs”. So in my case it should be set to $APP_PREFIX and –build should be set to $GCC_HOST.
It didn’t cause errors with CodeSourcery toolchains, however, since they always compile for arm-linux and –host could be set to any value only to enable cross-compilation mode for “configure” script.
http://www.gnu.org/software/autoconf/manual/html_node/Specifying-Target-Triplets.html#Specifying-Target-Triplets
Hello Igor!
Thanks for the information, it’s been very useful.
I’m trying to setup opencv on a ts7250 board, to use it for some small processing and then streaming it to another program on my computer to make heavier processing on the video.
After a LOT of tweaking, I managed to compile the example code that I obtained in http://nashruddin.com/StrEAMinG_oPENcv_vIdEos_ovER_tHe_nEtWoRk as a first try, but I’m not displaying the video on the board (I’ve commented it out of stream_server.c code) because it does not have a video output. I’ve used a OABI compiler and the shared opencv libraries.
The problem is: cvCapture fails. So I thought “I guess it means that I need to compile the videodev driver, modprobe it, and then run the program again.”
Well, I did it, but still no success.
You have any pointers on what should I do now?
Lucas, if you’re going to use web-camera as video source for OpenCV you need to:
1) Make sure that your kernel has v4l2 support (check kernel config)
2) Enable v4l support in OpenCV (it’s disabled in my script). Add “–with-v4l” option to ./configure parameters
Igor, I am using the -with-v4l option in the configure parameters, and also I’ve managed to compile a patched 2.6.32.3 kernel with the modules:
gspca_pac207, gspca_main, v4l1-compat, v4l2-common, v4l2-int-device, videodev (it looks like the gspca_pac207 driver needs the v4l1-compat module).
But when I try to run that test application, a new error appears:
HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream.: Bad file descriptor
HIGHGUI ERROR: V4L: Unable to determine size of incoming image
cvCapture failed
I am using the 1.1pre1 opencv version.
Lucas, it looks like your camera outputs video in its own weird format. You can check http://hansdegoede.livejournal.com/3636.html and http://forum.skype.com/index.php?showtopic=225971 on how people deal with that.
Francesco, I’d say that having face detection in 5-6 sec. on 60MHz ARM7 is very good results. ARM9 will certainly be faster, however my guess is that having FPU on board won’t speed up detection a lot. This is the case, when algorithm tweaking adds much more performance boost than simple HW changes.
You might want to experiment with OpenCV algorithms/cascades – in some cases decreasing detection quality (for example – increasing detection “window” size, or reducing number of stages in cascade) will result in significant performance gains.
Igor, another questions…….
where can I found the variables in charge of decreasing/increasing window size and the number of stages of the algorithm?
Where can I found a tutorial for OpenCV beginners (with regard to face detection)?
Thank you again
Francesco, window size I mentioned was a parameter for cvHaarDetectObjects(). You can find brief function description here http://opencv.willowgarage.com/documentation/pattern_recognition.html#cvHaarDetectObjects. “Number of stages” meant number of stages in cascade, that OpenCV uses to detect faces. Decreasing number of stages might improve detection speed on the price of detection quality (higher false positives ratio). You can get general idea of cascades from original Viola-Jones article named “Robust Real-time Object Detection” – just Google for “viola jones face detection”.
There is a book on OpenCV – “Learning OpenCV: computer vision with the OpenCV library” with limited preview available on GoogleBooks here, you might find it interesting.