OpenCV:无法从 contrib 存储库中找到模块(跟踪器,选择ROI)
OpenCV: Can't find modules from contrib repository (Tracker, selectROI)
我正在做一个涉及跟踪对象的项目,我正在尝试让OpenCV contrib repo的TrackerKCF工作。这是我在线获得的示例代码:
#include <opencv2/core/utility.hpp>
#include <opencv2/video/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
using namespace std;
using namespace cv;
int main( int argc, char** argv ){
// show help
if(argc<2){
cout<<
" Usage: example_tracking_kcf <video_name>n"
" examples:n"
" example_tracking_kcf Bolt/img/%04.jpgn"
" example_tracking_kcf faceocc2.webmn"
<< endl;
return 0;
}
// create the tracker
Ptr<Tracker> tracker = TrackerKCF::create();
// set input video
std::string video = argv[1];
VideoCapture cap(video);
Mat frame;
// get bounding box
cap >> frame;
Rect2d roi= selectROI("tracker", frame, true, false);
//quit if ROI was not selected
if(roi.width==0 || roi.height==0)
return 0;
// initialize the tracker
tracker->init(frame,roi);
// do the tracking
printf("Start the tracking process, press ESC to quit.n");
for ( ;; ){
// get frame from the video
cap >> frame;
// stop the program if no more images
if(frame.rows==0 || frame.cols==0)
break;
// update the tracking result
bool isfound = tracker->update(frame,roi);
if(!isfound)
{
cout << "The target has been lost...n";
waitKey(0);
return 0;
}
// draw the tracked object
rectangle( frame, roi, Scalar( 255, 0, 0 ), 2, 1 );
// show image with the tracked object
imshow("tracker",frame);
//quit on ESC button
if(waitKey(1)==27)break;
}
}
但是,我收到以下错误:
tracktest.cpp: In function ‘int main(int, char**)’:
tracktest.cpp:33:7: error: ‘Tracker’ was not declared in this scope
Ptr<Tracker> tracker = TrackerKCF::create();
^
tracktest.cpp:33:14: error: template argument 1 is invalid
Ptr<Tracker> tracker = TrackerKCF::create();
^
tracktest.cpp:33:26: error: ‘TrackerKCF’ has not been declared
Ptr<Tracker> tracker = TrackerKCF::create();
^
tracktest.cpp:43:54: error: ‘selectROI’ was not declared in this scope
Rect2d roi= selectROI("tracker", frame, true, false);
^
tracktest.cpp:50:10: error: base operand of ‘->’ is not a pointer
tracker->init(frame,roi);
^
tracktest.cpp:63:27: error: base operand of ‘->’ is not a pointer
bool isfound = tracker->update(frame,roi);
^
./tracktest.sh: line 5: ./tracktest: No such file or directory
我尝试重新安装 OpenCV 3.1.0 和相应的 contrib 存储库,似乎make
完成得很好。我还试图找到tracker.cpp
在我的OpenCV源目录中的位置,但没有弹出任何内容。
我认为这是因为我错误地安装了 contrib 模块,但我不确定。谁能弄清楚出了什么问题?提前谢谢。
由于我莫名其妙的愚蠢,我忘记了运行make install
.现在一切都好了!
相关文章:
- 尝试导入pybind-opencv模块时出现libgtk错误
- 光线跟踪器灯光反射错误
- 人脸跟踪arduino代码的优化
- 为什么当我解模块化时,这个C++代代码"效率较低"?
- 跟踪滚动条上的鼠标事件
- 如果C++对象的类在另一个boost模块中声明,如何使用boost将指向该对象的指针返回到python
- 内联如何影响模块接口中的成员函数
- C++返回 Numpy 数组的 Python 扩展模块
- 如何使用新运算符跟踪在循环中创建的 QLabel
- 当我尝试加载内核模块时,如何修复C++中的这个 malloc() 错误?
- 如何从线程中的不同模块调用函数?
- 如何使用 soong 命名空间来有条件地编译模块
- asn1c 不会从 asn.1 模块中提取八位字节字符串的默认值
- C++:跟踪类对象
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- CMake - 模块 + 库混淆
- 跟踪日志中的T.11803()是什么意思?
- 特征 LLT 模块给出不正确的结果?
- OpenCV:无法从 contrib 存储库中找到模块(跟踪器,选择ROI)
- 安装额外模块openCV后未定义跟踪器