duhao

duhao

0个粉丝

8

问答

0

专栏

0

资料

duhao  发布于  2015-06-09 11:11:23
采纳率 0%
8个问答
8634

opencv2.4.10移植到hi3515c

[i=s] 本帖最后由 duhao 于 2015-6-9 11:19 编辑 [/i]

开贴之前,首先感谢9crk大哥的无私耐心的帮助,真心非常感激!!!

下面开始: 参考1:http://www.ebaina.com/bbs/forum.php?mod=viewthread&tid=4858&extra=page%3D1 参考2: http://ebaina.com/bbs/forum.php? ... mp;highlight=opencv

我用的系统是ubuntu12.04.4 64位,安装了海思3515官方配套的SDK,交叉编译的编译器环境是uclibc的编译器环境,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中的配置,配置如下:[attach]2474[/attach]

[attach]2474[/attach]

[attach]2475[/attach]

输出选成上面的output目录,既配置时CMAKE_INSTALL_PREFIX我设定的是/home/study/hi-opencv-2.4.10/output 之后进入build目录,开始make和make install,编译过程没有出现多少错误,记得一个,就是下面这样的: undefined reference to pthread_once'; undefined reference topthread_spin_lock'; 这样的类型的错误,好些个。 解决办法:参考一中提供的: 修改CMakeCache.txt大约195行处 //Flags used by the linker. CMAKE_EXE_LINKER_FLAGS:STRING= -lpthread -lrt 接着 make,后面好像没什么错误

最后在output里面生成 include,lib,share,LICENSE 。没有生成bin文件。: root@duhao-virtual-machine:/home/study/hi-opencv-2.4.10/output# ls include lib LICENSE share

之后进行编译测试 然后将output下生成的include下的opencv和opencv2拷贝到交叉编译器的include下 cp include/ /usr/local/hi-arm/arm-hisiv100-linux/arm-hisiv100-linux-uclibcgnueabi/include/ -r 把output下生成的lib下的文件也拷贝到交叉编译器的lib文件下 cp lib/ /usr/local/hi-arm/arm-hisiv100-linux/arm-hisiv100-linux-uclibcgnueabi/lib/ 可能还需要把output下的lib下的文件拷贝到/usr/local/hi-arm/arm-hisiv100-linux/target/lib下; cp lib/* /usr/local/hi-arm/arm-hisiv100-linux/target/lib 然后来编译参考1中给的如下人脸检测程序,编译命令如下:

arm-hisiv100-linux-uclibcgnueabi-g++ face.cpp -I /opt/opencv-2.2.4/Hi3518e/include/opencv -lopencv_highgui -lopencv_core -lopencv_imgproc -lpthread -lrt -lopencv_objdetect -o face

检测程序如下: /*Author:9crk 2014-12-24***/

include "cv.h"

include "highgui.h"

include "stdio.h"

/**for time mesurement*****/

include <sys/time.h>

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/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In function cv:ngDecoder::readDataFromBuf(void*, unsigned char*, unsigned int)': grfmt_png.cpp.text._ZN2cv10PngDecoder15readDataFromBufEPvPhj+0x14): undefined reference topng_get_io_ptr' grfmt_png.cpp.text._ZN2cv10PngDecoder15readDataFromBufEPvPhj+0x12c): undefined reference to png_error' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In functioncv:ngDecoder::close()': grfmt_png.cpp.text._ZN2cv10PngDecoder5closeEv+0x4c): undefined reference to png_destroy_read_struct' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In functioncv:ngDecoder::readHeader()': grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x34): undefined reference to png_create_read_struct' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x44): undefined reference topng_create_info_struct' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x50): undefined reference to png_create_info_struct' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0xa8): undefined reference topng_set_longjmp_fn' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x118): undefined reference to png_init_io' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x170): undefined reference topng_read_info' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x1a0): undefined reference to png_get_IHDR' grfmt_png.cpp:(.text._ZN2cv10PngDecoder10readHeaderEv+0x358): undefined reference topng_set_read_fn' grfmt_png.cpp:(.text._ZN2cv10PngDecoder10readHeaderEv+0x3a0): undefined reference to png_get_tRNS' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In functioncv:ngEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&)': grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x38): undefined reference to png_create_write_struct' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xb0): undefined reference topng_create_info_struct' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xd8): undefined reference to png_set_longjmp_fn' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x118): undefined reference topng_set_write_fn' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x3c0): undefined reference to png_destroy_write_struct' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x420): undefined reference topng_set_compression_level' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x430): undefined reference to png_set_compression_strategy' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4a4): undefined reference topng_set_IHDR' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4b4): undefined reference to png_write_info' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4c8): undefined reference topng_set_packing' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4d4): undefined reference to png_set_bgr' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4f8): undefined reference topng_set_swap' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x66c): undefined reference to png_write_image' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x67c): undefined reference topng_write_end' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x804): undefined reference to png_init_io' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x81c): undefined reference topng_set_filter' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x82c): undefined reference to png_set_compression_level' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In functioncv:ngEncoder::writeDataToBuf(void, unsigned char, unsigned int)': grfmt_png.cpp:(.text._ZN2cv10PngEncoder14writeDataToBufEPvPhj+0x24): undefined reference to png_get_io_ptr' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_png.cpp.obj): In functioncv:ngDecoder::readData(cv::Mat&)': grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x140): undefined reference to png_set_longjmp_fn' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x208): undefined reference topng_set_gray_to_rgb' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x210): undefined reference to png_set_interlace_handling' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x21c): undefined reference topng_read_update_info' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x2ec): undefined reference to png_read_image' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x2f8): undefined reference topng_read_end' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x320): undefined reference to png_set_rgb_to_gray' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x32c): undefined reference topng_set_bgr' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x338): undefined reference to png_set_strip_alpha' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x344): undefined reference topng_set_swap' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x358): undefined reference to png_set_expand_gray_1_2_4_to_8' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x364): undefined reference topng_set_strip_16' grfmt_png.cpp:(.text._ZN2cv10PngDecoder8readDataERNS_3MatE+0x378): undefined reference to png_set_palette_to_rgb' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functioncv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&)': grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xcc): undefined reference to jpeg_CreateCompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xd8): undefined reference tojpeg_std_error' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x340): undefined reference to jpeg_set_defaults' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x354): undefined reference tojpeg_set_quality' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x364): undefined reference to jpeg_start_compress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x474): undefined reference tojpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4b0): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4e0): undefined reference tojpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x518): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x544): undefined reference tojpeg_write_scanlines' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj):grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x570): more undefined references to jpeg_write_scanlines' follow /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functioncv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&)': grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x5bc): undefined reference to jpeg_finish_compress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x5cc): undefined reference tojpeg_destroy_compress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x6ec): undefined reference to jpeg_stdio_dest' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x77c): undefined reference tojpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x7f0): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x858): undefined reference tojpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x8c8): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x92c): undefined reference tojpeg_write_scanlines' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj):grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x990): more undefined references to jpeg_write_scanlines' follow /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functioncv::JpegDecoder::close()': grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder5closeEv+0x18): undefined reference to jpeg_destroy_decompress' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functioncv::JpegDecoder::readHeader()': grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x34): undefined reference to jpeg_std_error' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x80): undefined reference tojpeg_CreateDecompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x17c): undefined reference to jpeg_stdio_src' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x198): undefined reference tojpeg_read_header' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x290): undefined reference to jpeg_resync_to_restart' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functionT.419': grfmt_jpeg.cpp:(.text.T.419+0x358): undefined reference to jpeg_alloc_huff_table' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_highgui.a(grfmt_jpeg.cpp.obj): In functioncv::JpegDecoder::readData(cv::Mat&)': grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0xe0): undefined reference to jpeg_start_decompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x1ac): undefined reference tojpeg_read_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x1dc): undefined reference to jpeg_finish_decompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x298): undefined reference tojpeg_read_scanlines' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function icvGets(CvFileStorage*, char*, int)': persistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x224): undefined reference togzgets' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function T.3367': persistence.cpp:(.text.T.3367+0x1b8): undefined reference togzeof' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function icvXMLSkipSpaces(CvFileStorage*, char*, int)': persistence.cpp:(.text._ZL16icvXMLSkipSpacesP13CvFileStoragePci+0x2b8): undefined reference togzeof' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function icvYMLSkipSpaces(CvFileStorage*, char*, int, int)': persistence.cpp:(.text._ZL16icvYMLSkipSpacesP13CvFileStoragePcii+0x1cc): undefined reference togzeof' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function icvPuts(CvFileStorage*, char const*)': persistence.cpp:(.text._ZL7icvPutsP13CvFileStoragePKc+0x1dc): undefined reference togzputs' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function icvClose(CvFileStorage*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)': persistence.cpp:(.text._ZL8icvCloseP13CvFileStoragePSs+0x2b0): undefined reference togzclose' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(persistence.cpp.obj): In function cvOpenFileStorage': persistence.cpp:(.text.cvOpenFileStorage+0x614): undefined reference togzrewind' persistence.cpp:(.text.cvOpenFileStorage+0x7d0): undefined reference to gzclose' persistence.cpp:(.text.cvOpenFileStorage+0x87c): undefined reference togzopen' persistence.cpp:(.text.cvOpenFileStorage+0xe20): undefined reference to gzclose' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::trylock()': system.cpp:(.text._ZN2cv5Mutex7trylockEv+0x8): undefined reference to pthread_spin_trylock' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::unlock()': system.cpp:(.text._ZN2cv5Mutex6unlockEv+0x4): undefined reference to pthread_spin_unlock' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::lock()': system.cpp:(.text._ZN2cv5Mutex4lockEv+0x4): undefined reference to pthread_spin_lock' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex:perator=(cv::Mutex const&)': system.cpp:(.text.ZN2cv5MutexaSERKS0+0x54): undefined reference to pthread_spin_destroy' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::~Mutex()': system.cpp:(.text._ZN2cv5MutexD1Ev+0x40): undefined reference to pthread_spin_destroy' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::~Mutex()': system.cpp:(.text._ZN2cv5MutexD2Ev+0x40): undefined reference to pthread_spin_destroy' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::Mutex()': system.cpp:(.text._ZN2cv5MutexC1Ev+0x18): undefined reference to pthread_spin_init' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_core.a(system.cpp.obj): In functioncv::Mutex::Mutex()': system.cpp:(.text._ZN2cv5MutexC2Ev+0x18): undefined reference to pthread_spin_init' /usr/local/arm/arm-hisiv100-linux/bin/../lib/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabi/lib/libopencv_imgproc.a(templmatch.cpp.obj): In functioncv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Size, int, cv:oint, double, int)': templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x4a4): undefined reference to cv::getOptimalDFTSize(int)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x4c4): undefined reference tocv::getOptimalDFTSize(int)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0xbd8): undefined reference to cv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x15e8): undefined reference tocv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x167c): undefined reference to cv::mulSpectrums(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, bool)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x16b8): undefined reference tocv::dft(cv::_InputArray const&, cv::_OutputArray const&, int, int)' /usr/local/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 tocvCvtColor' haar.cpp:(.text._Z25cvHaarDetectObjectsForROCPKvP23CvHaarClassifierCascadeP12CvMemStorageRSt6vectorIiSaIiEERS5_IdSaIdEEdii6CvSizeSC_b+0x15e4): undefined reference to cvCanny' /usr/local/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 functioncv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect, std::allocator<cv::Rect > >&, std::vector<int, std::allocator >&, std::vector<double, std::allocator >&, 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

解决方法: 1.对于grfmt_png.cpp的各种undefined reference to,原因是交叉编译环境缺少libpng,解决办法是下载libpng,然后进行交叉编译,编译后生成include和lib文件夹,分别把include和lib下的文件拷贝到交叉编译环境的include和lib文件下,我的也就是上面的/usr/local/hi-arm/arm-hisiv100-linux/arm-hisiv100-linux-uclibcgnueabi/include/和/usr/local/hi-arm/arm-hisiv100-linux/arm-hisiv100-linux-uclibcgnueabi/lib/ 然后再进行编译,记得编译命令上加上-lpng,然后发现grfmt_png.cpp的错误都没有了。 2.对于grfmt_jpeg.cpp的各种undefined reference to,是交叉编译环境缺少了libjpeg,解决办法参考上面的1,下载libjpeg,交叉编译,拷贝include和lib文件到交叉编译环境的include和lib下,编译加上-ljpeg 3对于persistence.cpp的各种undefined reference to,是交叉编译环境缺少了libxml2,解决办法同上,编译时加上-xlm2后,这个错误就没了。

对于后面剩下的问题,发现是链接库的顺序导致的,下面是我修改了编译命令: arm-hisiv100-linux-uclibcgnueabi-g++ face.cpp -I/home/study/hi-opencv-2.4.4/output/include/opencv -lopencv_highgui -lopencv_imgproc -lopencv_core -lpthread -lrt -ljpeg -lpng -lxml2 -lopencv_objdetect -o face

顺序为: -lopencv_highgui -lopencv_imgproc -lopencv_core 编译后,错误为: /usr/local/hi-arm/arm-hisiv100-linux/bin/..b/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabibbxml2.so: warning: gethostbyname is obsolescent, use getnameinfo() instead. /usr/local/hi-arm/arm-hisiv100-linux/bin/..b/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabibbopencv_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 tocvCvtColor' haar.cpp.text._Z25cvHaarDetectObjectsForROCPKvP23CvHaarClassifierCascadeP12CvMemStorageRSt6vectorIiSaIiEERS5_IdSaIdEEdii6CvSizeSC_b+0x16e8): undefined reference to cvCanny' /usr/local/hi-arm/arm-hisiv100-linux/bin/..b/gcc/arm-hisiv100-linux-uclibcgnueabi/4.4.1/../../../../arm-hisiv100-linux-uclibcgnueabibbopencv_objdetect.a(cascadedetect.cpp.obj): In functioncv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect, std::allocator<cv::Rect > >&, std::vector<int, std::allocator >&, std::vector<double, std::allocator >&, 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

这个问题两天还没解决,最后发现是因为编译命令漏掉了之前的-lopencv_objdetect,说来惭愧,因为无意漏掉这个导致两天没解决错误。最后还是在9crk大哥的帮助下一步一步找出问题所在的,希望大家引以为戒,平时学习做事都要细心一些。最后编译命令为:

arm-hisiv100-linux-uclibcgnueabi-g++ face.cpp -I/home/study/hi-opencv-2.4.4/output/include/opencv -lopencv_objdetect -lopencv_highgui -lopencv_imgproc -lopencv_core -lpthread -lrt -ljpeg -lpng -lxml2 -lopencv_objdetect -o face

发现没有错误了,就只有一个警告,后面发现这个警告没影响。有生成二进制文件,把生成的二进制文件face,lena.jpg,haarcascade_frontalface_alt2.xml拷贝到ubuntu下的nfs目录,同时把output下lib里面的libopencv_imgproc.so,libopencv_objdetect.so,libopencv_highgui.so,libopencv_core.so这四个文件拷贝到ubuntu下的nfs目录,把然后通过nfs挂载到开发板hi3515,到开发板端做软连接库到/lib目录下; ln -s nfsroot/libopencv_imgproc.so /lib/libopencv_imgproc.so ln -s nfsroot/libopencv_objdetect.so /lib/libopencv_objdetect.so ln -s nfsroot/libopencv_highgui.so /lib/libopencv_highgui.so ln -s nfsroot/libopencv_core.so /lib/libopencv_core.so 然后在face文件处,执行./face lena.jpg。 提醒有错误: 意思就是libjpeg.so.62没加载,libpng15.so.15没加载,libxml2.so.2没加载这样的问题。 原因是arm板上lib里面缺少这些库 解决方法: 在交叉编译环境把这三个文件拷贝到nfs下,nfs挂载到开发板后,然后在开发板作软连接,将这三个库软连接到arm上的lib下: ln -s nfsroot/libjpeg.so.62 /lib/libjpeg.so.62 ln -s nfsroot/libpng15.so.15 /lib/libpng15.so.15 ln -s nfsroot/libxml2.so.2 /lib/libxml2.so.2 再在face目录下执行:./face lena.jpg 结果没有错误,可以正常运行,生成图片文件。

到这里,就结束了,希望能给移植opencv的人提供一些帮助,尽量少走一些弯路! 最后,再次郑重感谢9crk大哥的无私帮助。非常非常感谢。。。

我来回答
回答7个
时间排序
认可量排序

persona

0个粉丝

2

问答

0

专栏

0

资料

persona 2015-06-09 12:04:21
认可0
学习,感谢搂主分享。

9crk

1个粉丝

34

问答

0

专栏

6

资料

9crk 2015-06-09 12:14:41
认可0
赞一个。。么么哒~

duhao

0个粉丝

8

问答

0

专栏

0

资料

duhao 2015-06-09 12:16:45
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=16937&ptid=7828]9crk 发表于 2015-6-9 12:14[/url]
赞一个。。么么哒~[/quote]

:lol:lol:lol

尼斯特路易

0个粉丝

2

问答

0

专栏

2

资料

尼斯特路易 2017-08-15 16:08:43
认可0
谢谢,人脸检测用得到OpenCV

lzts

0个粉丝

0

问答

0

专栏

0

资料

lzts 2018-03-12 17:24:00
认可0
学习下,谢谢分享

wangy2000

0个粉丝

0

问答

0

专栏

0

资料

wangy2000 2018-05-05 07:44:24
认可0
好资料,学习,积累,提高。谢谢,

gc5218112

0个粉丝

0

问答

0

专栏

0

资料

gc5218112 2016-11-17 20:19:27
认可0
必须赞:lol:lol:lol
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区