|
发表于 2008-10-24 10:56:07
|
显示全部楼层
Image step is wrong
感谢你的恢复,我现在可以好想知道了,是里面关于打开窗口什么的函数造成的,我把这些函数删掉,把程序改到最简单,然后可以编译通过,运行的时候出现了 Segmentation fault 的问题,我觉得应该是字节对齐的问题,可我不知道该怎么改,谢谢可以再给我讲一讲,万分感激,程序代码如下:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#ifdef _EiC
#define WIN32
#endif
static CvMemStorage* storage = 0;
static CvHaarClassifierCascade* cascade = 0;
void detect_and_draw( IplImage* image );
const char* cascade_name =
"haarcascade_frontalface_alt.xml";
/* "haarcascade_profileface.xml";*/
int main( int argc, char** argv )
{
IplImage *frame, *frame_copy = 0;
int optlen = strlen("--cascade=");
const char* input_name;
cascade_name = "./data/haarcascades/haarcascade_frontalface_alt2.xml";
input_name = "001.bmp";
cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 );
IplImage* image = cvLoadImage( input_name, 1 );
if( image )
{
storage = cvCreateMemStorage(0);
printf("width=%d,height%d\\n",image->width,image->height);
detect_and_draw( image );
cvReleaseImage( &image );
}
return 0;
}
void detect_and_draw( IplImage* img )
{
static CvScalar colors[] =
{
{{0,0,255}},
{{0,128,255}},
{{0,255,255}},
{{0,255,0}},
{{255,128,0}},
{{255,255,0}},
{{255,0,0}},
{{255,0,255}}
};
double scale = 1.3;
IplImage* gray = cvCreateImage( cvSize(img->width,img->height), 8, 1 );
//IplImage* small_img = cvCreateImage( cvSize( cvRound (img->width/scale),
// cvRound (img->height/scale)),
// 8, 1 );
int i;
cvCvtColor( img, gray, CV_BGR2GRAY );
//cvResize( gray, small_img, CV_INTER_LINEAR );
//cvEqualizeHist( small_img, small_img );
cvClearMemStorage( storage );
if( cascade )
{
double t = (double)cvGetTickCount();
CvSeq* faces = cvHaarDetectObjects( gray, cascade, storage,
1.1, 2, 0/*CV_HAAR_DO_CANNY_PRUNING*/,
cvSize(30, 30) );
t = (double)cvGetTickCount() - t;
printf( "detection time = %gms\\n", t/((double)cvGetTickFrequency()*1000.) );
for( i = 0; i < (faces ? faces->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
CvPoint center;
int radius;
center.x = cvRound((r->x + r->width*0.5)*scale);
center.y = cvRound((r->y + r->height*0.5)*scale);
radius = cvRound((r->width + r->height)*0.25*scale);
//cvCircle( img, center, radius, colors[i%8], 3, 8, 0 );
}
}
// cvShowImage( "result", img );
cvReleaseImage( &gray );
//cvReleaseImage( &small_img );
}
我是通过./configure --host=arm-linux --without-gtk --without-carbon --without-v4l --without-quicktime --without-1394libs --without-ffmpeg --without-python --without-swig
然后make,make install
arm-linux-gcc facedetect.c -o facetect `pkg-config --cflags --libs opencv`
编译没有问题,还是下到arm9的板子上出的上面的 Segmentation fault 错误!
你这样编译好像是动态库呀,不是静态库的话,你要指定动态库的目录!另外,1。建议你多加printf,看看到底是哪一句造成segmentation fault, 一般来说,这个错误是野指针造成的。 2。 建议参考http://www.opencv.org.cn/forum/viewtopic.php?p=4148 |
|