- 收藏
- 点赞
- 分享
- 举报
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 to
pthread_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 to
png_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 function
cv: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 function
cv:ngDecoder::readHeader()':
grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x34): undefined reference to png_create_read_struct' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x44): undefined reference to
png_create_info_struct'
grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x50): undefined reference to png_create_info_struct' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0xa8): undefined reference to
png_set_longjmp_fn'
grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x118): undefined reference to png_init_io' grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x170): undefined reference to
png_read_info'
grfmt_png.cpp.text._ZN2cv10PngDecoder10readHeaderEv+0x1a0): undefined reference to png_get_IHDR' grfmt_png.cpp:(.text._ZN2cv10PngDecoder10readHeaderEv+0x358): undefined reference to
png_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 function
cv:ngEncoder::write(cv::Mat const&, std::vector<int, std::allocatorpng_create_write_struct' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xb0): undefined reference to
png_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 to
png_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 to
png_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 to
png_set_IHDR'
grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4b4): undefined reference to png_write_info' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4c8): undefined reference to
png_set_packing'
grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4d4): undefined reference to png_set_bgr' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4f8): undefined reference to
png_set_swap'
grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x66c): undefined reference to png_write_image' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x67c): undefined reference to
png_write_end'
grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x804): undefined reference to png_init_io' grfmt_png.cpp:(.text._ZN2cv10PngEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x81c): undefined reference to
png_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 function
cv: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 function
cv: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 to
png_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 to
png_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 to
png_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 to
png_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 to
png_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 to
png_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 function
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocatorjpeg_CreateCompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xd8): undefined reference to
jpeg_std_error'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x340): undefined reference to jpeg_set_defaults' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x354): undefined reference to
jpeg_set_quality'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x364): undefined reference to jpeg_start_compress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x474): undefined reference to
jpeg_write_scanlines'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4b0): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x4e0): undefined reference to
jpeg_write_scanlines'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x518): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x544): undefined reference to
jpeg_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 function
cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocatorjpeg_finish_compress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x5cc): undefined reference to
jpeg_destroy_compress'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x6ec): undefined reference to jpeg_stdio_dest' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x77c): undefined reference to
jpeg_write_scanlines'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x7f0): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x858): undefined reference to
jpeg_write_scanlines'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x8c8): undefined reference to jpeg_write_scanlines' grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x92c): undefined reference to
jpeg_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 function
cv::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 function
cv::JpegDecoder::readHeader()':
grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x34): undefined reference to jpeg_std_error' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x80): undefined reference to
jpeg_CreateDecompress'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x17c): undefined reference to jpeg_stdio_src' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder10readHeaderEv+0x198): undefined reference to
jpeg_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 function
T.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 function
cv::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 to
jpeg_read_scanlines'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x1dc): undefined reference to jpeg_finish_decompress' grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x298): undefined reference to
jpeg_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 to
gzgets'
/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 to
gzeof'
/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 to
gzeof'
/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 to
gzeof'
/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 to
gzputs'
/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 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(persistence.cpp.obj): In function cvOpenFileStorage': persistence.cpp:(.text.cvOpenFileStorage+0x614): undefined reference to
gzrewind'
persistence.cpp:(.text.cvOpenFileStorage+0x7d0): undefined reference to gzclose' persistence.cpp:(.text.cvOpenFileStorage+0x87c): undefined reference to
gzopen'
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 function
cv::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 function
cv::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 function
cv::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 function
cv::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 function
cv::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 function
cv::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 function
cv::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 function
cv::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 function
cv::crossCorr(cv::Mat const&, cv::Mat const&, cv::Mat&, cv::Sizecv::getOptimalDFTSize(int)' templmatch.cpp:(.text._ZN2cv9crossCorrERKNS_3MatES2_RS0_NS_5Size_IiEEiNS_6Point_IiEEdi+0x4c4): undefined reference to
cv::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 to
cv::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 to
cv::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 to
cvCvtColor'
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 function
cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect
解决方法: 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 to
cvCvtColor'
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 function
cv::CascadeClassifier::detectMultiScale(cv::Mat const&, std::vector<cv::Rect
这个问题两天还没解决,最后发现是因为编译命令漏掉了之前的-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大哥的无私帮助。非常非常感谢。。。
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
-
2015-06-06 22:07:14
-
2015-04-26 17:03:01
-
2015-05-26 17:55:34
-
2016-01-29 17:28:20
-
2015-12-16 15:51:00
-
2014-09-21 15:42:00
-
2015-01-19 16:54:20
-
2018-05-28 16:26:37
-
2018-12-14 10:37:21
-
2015-01-20 22:07:13
-
2017-02-22 14:32:22
-
2014-10-24 09:41:52
-
2020-06-18 10:31:02
-
2015-03-29 22:12:15
-
2014-10-24 19:25:36
-
2018-06-28 14:52:58
-
2019-06-16 11:26:53
-
2017-05-12 14:43:37
-
2019-01-26 09:46:16
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
-
5有偿求HI3516DV500 + OV5647驱动
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明