我正在使用 Ubuntu 16.04 和 MatLAB R2016b 学生版,OpenCV 3.1 安装如下本教程。
我下载了 OpenTLD 跟踪算法的源代码,并尝试运行 compile.m 文件,但遇到以下错误
顺便说一句,我已经实施了一些更改,以解决查找 cv.h 头文件时出现的问题
定义是
(#include "cv.h")
(#include "highgui.h")
并改为
(#include <opencv/cv.h>)
运行 compile.m 时收到的错误
Error using mex
/tmp/mex_36621193718999_4249/lk.o: In function `normCrossCorrelation(_IplImage*, _IplImage*, CvPoint2D32f*, CvPoint2D32f*,
int, char*, float*, int, int)':
lk.cpp:(.text+0x1a0): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x1b9): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x1d6): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x214): undefined reference to `cvGetRectSubPix'
lk.cpp:(.text+0x227): undefined reference to `cvGetRectSubPix'
lk.cpp:(.text+0x23b): undefined reference to `cvMatchTemplate'
lk.cpp:(.text+0x274): undefined reference to `cvReleaseImage'
lk.cpp:(.text+0x27d): undefined reference to `cvReleaseImage'
lk.cpp:(.text+0x286): undefined reference to `cvReleaseImage'
/tmp/mex_36621193718999_4249/lk.o: In function `mexFunction':
lk.cpp:(.text+0x323): undefined reference to `cvReleaseImage'
lk.cpp:(.text+0x341): undefined reference to `cvReleaseImage'
lk.cpp:(.text+0x438): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x455): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x4be): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x4dc): undefined reference to `cvCreateImage'
lk.cpp:(.text+0x553): undefined reference to `cvAlloc'
lk.cpp:(.text+0x565): undefined reference to `cvAlloc'
lk.cpp:(.text+0x578): undefined reference to `cvAlloc'
lk.cpp:(.text+0x613): undefined reference to `cvAlloc'
lk.cpp:(.text+0x61e): undefined reference to `cvAlloc'
/tmp/mex_36621193718999_4249/lk.o:lk.cpp:(.text+0x626): more undefined references to `cvAlloc' follow
/tmp/mex_36621193718999_4249/lk.o: In function `mexFunction':
lk.cpp:(.text+0x6c1): undefined reference to `cvCalcOpticalFlowPyrLK'
lk.cpp:(.text+0x73e): undefined reference to `cvCalcOpticalFlowPyrLK'
collect2: error: ld returned 1 exit status
Error in compile (line 77)
eval(['mex lk.cpp -O' include lib]);
答案1
看起来所提供的compile.m
是针对特定版本(和位置)的 OpenCV 的硬连线:
if isunix
disp('Unix');
include = ' -I/usr/local/include/opencv/ -I/usr/local/include/';
libpath = '/usr/local/lib/';
files = dir([libpath 'libopencv*.so.2.2']);
libopencv-dev
通过进行以下更改,我能够使用来自存储库的标准 2.4.9 在 64 位 Ubuntu 16.04 上进行编译和链接:
if isunix
disp('Unix');
include = ' -I/usr/include/opencv/ -I/usr/include/';
libpath = '/usr/lib/x86_64-linux-gnu/';
files = dir([libpath 'libopencv*.so.2.4'])
注意:我没有尝试测试结果mexa64
对象