概述
1. 搭载环境
步骤1:下载Demo: Zdenek Kalal的openTLD,见https://github.com/zk00006/OpenTLD
步骤2:安装Matlab2014b,VS2013,OpenCV2.4.9(需要将dll路径添加到环境变量的path中)
步骤3:设置编译器:mex -setup,选择VS2013
步骤4:修改compile.m,执行
步骤5:执行run_TLD.m
2. 编译
将compile.m文件修改如下(如果想要在cpp中debug,需要在mex后添加'-g',见点击打开链接):
% Copyright 2011 Zdenek Kalal
%
% This file is part of TLD.
%
% TLD is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% TLD is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with TLD. If not, see <http://www.gnu.org/licenses/>.
% Compiles mex files
clc; clear all; cd mex;
if ispc
disp('PC');
include = ' -Id:opencvbuildincludeopencv -Id:opencvbuildinclude';
libpath = 'd:opencvbuildx64vc12lib';
files = dir([libpath '*.lib']);
lib = [];
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
eval(['mex lk.cpp -O' include lib]);
mex -O -c tld.cpp
mex -O fern.cpp tld.obj
mex -O linkagemex.cpp
mex -O bb_overlap.cpp
mex -O warp.cpp
mex -O distance.cpp
end
if ismac
disp('Mac');
include = ' -I/opt/local/include/opencv/ -I/opt/local/include/';
libpath = '/opt/local/lib/';
files = dir([libpath 'libopencv*.dylib']);
lib = [];
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
eval(['mex lk.cpp -O' include lib]);
mex -O -c tld.cpp
mex -O fern.cpp tld.o
mex -O linkagemex.cpp
mex -O bb_overlap.cpp
mex -O warp.cpp
mex -O distance.cpp
end
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']);
lib = [];
for i = 1:length(files),
lib = [lib ' ' libpath files(i).name];
end
eval(['mex lk.cpp -O' include lib]);
mex -O -c tld.cpp
mex -O fern.cpp tld.o
mex -O linkagemex.cpp
mex -O bb_overlap.cpp
mex -O warp.cpp
mex -O distance.cpp
end
cd ..
disp('Compilation finished.');
3.TroubleShooting
Error: 无法找到"Program Files..."
解决办法:include和libpath中的opencv路径不能有空格。将opencv的安装包extract到别的盘符下,重新cmake一遍,再用vs编译一遍。见《opencv3编程入门》
Error: 错误使用 mex
正在创建库 lk.lib 和对象 lk.exp
lk.obj : error LNK2019: 无法解析的外部符号 cvAlloc,该符号在函数 mexFunction 中被引用....
解决办法:对于x64系统,需将libpath = 'd:opencvbuildx86vc12lib';改为libpath = 'd:opencvbuildx64vc12lib';
Error: c:Matlabr2014bexternincludematrix.h(266) : error CC4430:缺少类型说明符 -假定为int。注意:C++不支持int
解决办法:
在lk.cpp, fern.cpp, and bb_overlap.cpp中注释掉这些代码: #ifdef _CHAR16_T #define CHAR16_T #endif
Error: bb_overlap.cpp(35) : error C3861: “min”: 找不到标识符
解决办法:修改TLD代码包中mex文件夹下bb_overlap.cpp文件,在头部加上#include "minmax.h"
Error: 找不到 'FSPECIAL' 的完全匹配项(区分大小写)。
解决办法:h = FSPECIAL('gaussian',csize,sigma);改为fspecial
Error:Invalid MEX-file 'D:TLDOpenTLD-mastermexlk.mexw64':找不到指定的模块
解决办法:虽然安装了OpenCV,但是没有将DLL添加到Path中,lk.mexw64(其实也是个DLL)就会找不到关于opencv的DLL。在环境变量->系统变量->Path中添加openCV的dll路径,如d:opencvbuildx64vc12bin. (x64指64位系统,vc12指vs2013),改完后要重启系统。原帖:https://github.com/kyamagu/mexopencv#2-install-opencv-library
解决办法:按空格退出
最后
以上就是香蕉溪流为你收集整理的TLD学习(1)-搭建环境的全部内容,希望文章能够帮你解决TLD学习(1)-搭建环境所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复