2 duhao358231384 duhao358231384 于 2015.06.07 18:18 提问

opencv移植到arm上的问题

参考1:http://www.ebaina.com/bbs/forum. ... &extra=page%3D1
参考2: http://ebaina.com/bbs/forum.php? ... mp;highlight=opencv

我用的系统是ubuntu12.04.4 64位,安装了海思HI3515官方配套的SDK,gcc版本是4.6.3,cmake是2.8.10.1,然后新建一个build和output文件夹:
root@duhao-virtual-machine:/home/study/hi-opencv-2.4.10# ls
build opencv-2.4.10 output test
进入opencv-2.4.10,进行cmake-gui,然后配置是按参考2中的配置,输出选成上面的output目录
之后进入build目录,开始make和make install,最后在output里面生成 include,lib,share,LICENSE 。没有生成bin文件。:
root@duhao-virtual-machine:/home/study/hi-opencv-2.4.10/output# ls
include lib LICENSE share
然后将include下的opencv和opencv2拷贝到交叉编译器的include下

把lib下的文件也拷贝到交叉编译器的lib文件下

arm-hisiv100-linux-uclibcgnueabi-g++ face.cpp -I/home/study/hi-opencv-2.4.10/output/include/opencv -lopencv_highgui -lopencv_imgproc -lopencv_core -lpthread -lrt -ljpeg -lpng -lxml2 -lopencv_objdetect -o face 来编译以下参考1的程序

/***********Author:9crk 2014-12-24*****************************/
#include "cv.h"
#include "highgui.h"
#include "stdio.h"
/******************for time mesurement*************************/
#include
struct timeval tpstart,tpend;
unsigned long timeuses;
void timeRec()
{
gettimeofday(&tpstart,0);
}
int timeRep()
{
gettimeofday(&tpend,0);
timeuses=(tpend.tv_sec-tpstart.tv_sec)*1000000+tpend.tv_usec-tpstart.tv_usec;
printf("use time: %uus\n",timeuses);
return timeuses;
}
/********************end**************************************/

int main(int argc, char* argv[])
{
IplImage* img = NULL;
IplImage* cutImg = NULL;
CvMemStorage* storage = cvCreateMemStorage(0);
CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*)cvLoad("./haarcascade_frontalface_alt2.xml", 0, 0, 0);
CvSeq* faces;

img = cvLoadImage(argv[1], 0);

timeRec();
faces = cvHaarDetectObjects(img, cascade, storage, 1.2, 2, 0, cvSize(25,25) );
timeRep();
if (faces->total == 0){
printf("no face!\n");
}
cvSetImageROI(img, ((CvRect)cvGetSeqElem( faces, 0)));
cvSaveImage("face.bmp", img);

cvResetImageROI(img);
printf("face detected! in face.bmp!\n");
}

出现以下错误:
/usr/local/hi-arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libxml2.so: warning: gethostbyname is obsolescent, use getnameinfo() instead.
/usr/local/hi-arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_objdetect.a(haar.cpp.obj): In function cvHaarDetectObjectsForROC(void const*, CvHaarClassifierCascade*, CvMemStorage*, std::vector<int, std::allocator<int> >&, std::vector<double, std::allocator<double> >&, double, int, int, CvSize, CvSize, bool)':
haar.cpp.text._Z25cvHaarDetectObjectsForROCPKvP23CvHaarClassifierCascadeP12CvMemStorageRSt6vectorIiSaIiEERS5_IdSaIdEEdii6CvSizeSC_b+0x538): undefined reference to
cvCvtColor'
haar.cpp.text._Z25cvHaarDetectObjectsForROCPKvP23CvHaarClassifierCascadeP12CvMemStorageRSt6vectorIiSaIiEERS5_IdSaIdEEdii6CvSizeSC_b+0x16e8): undefined reference to cvCanny'
/usr/local/hi-arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_objdetect.a(cascadedetect.cpp.obj): In function
cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vectorcv::Rect_<int, std::allocatorcv::Rect_<int > >&, std::vector >&, std::vector >&, double, int, int, cv::Size_, cv::Size_, bool)':
cascadedetect.cpp.text._ZN2cv17CascadeClassifier16detectMultiScaleERKNS_3MatERSt6vectorINS_5Rect_IiEESaIS6_EERS4_IiSaIiEERS4_IdSaIdEEdiiNS_5Size_IiEESH_b+0x2b4): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
collect2: ld returned 1 exit status

这几个错误不懂要怎么改。希望大神来指导一下,感激不尽啊!!!

上面cmake-gui时的配置如下:
图片说明
图片说明

只是输出改成了上面新建的文件夹output。。。望大神指点一下啊,上面的问题要怎么解决额。

5个回答

wangyaninglm
wangyaninglm   Ds   Rxr 2015.06.07 22:24

你把,错误的部分截图贴出来看看,那个我觉得好像是依赖的东西没放对地方

duhao358231384
duhao358231384 恩恩,你好,截图在下面,请帮忙看看啊
2 年多之前 回复
duhao358231384
duhao358231384   2015.06.08 09:16

arm-hisiv100-linux-uclibcgnueabi-g++ face.cpp -I/home/study/hi-opencv-2.4.10/output/include/opencv -lopencv_highgui -lopencv_imgproc -lopencv_core -lpthread -lrt -ljpeg -lpng -lxml2 -lopencv_objdetect -o face 来编译。结果:
图片说明

wangyaninglm
wangyaninglm   Ds   Rxr 2015.06.08 13:41

我看你用的opencv2,但是函数用的opencv1,是不是这个原因?

duhao358231384
duhao358231384 好像不是这个问题,但是有一点觉得比较奇怪,交叉编译opencv后没有生成bin文件,而且生成的lib下都是.a文件,不是.so文件
2 年多之前 回复
duhao358231384
duhao358231384   2015.06.09 11:19
datou431
datou431   Rxr 2015.06.09 18:23

你用的opencv2?

duhao358231384
duhao358231384 2.4.10
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片