问题描述
我想估计 Pitag 标记的位置(源代码在这里:https://github.com/mpetroff/pi-tag-detector)
按照自述文件,“可以使用 ./pitag-test 模型文件图像文件调用包含的测试程序,它将打印检测到的标签列表及其点的图像像素位置。”,我打印了一个标记并将其放入一个图片文件JPG/PNG,检测正常。
现在我想做同样的事情,但使用实时摄像机,这意味着如果我移动标记,输出会显示标记已移动等。 但它不起作用,我不知道如何。
这是我的代码:
cv::VideoCapture inputVideo;
inputVideo.open(0);
while (inputVideo.grab())
{
cv::Mat image;
cv::Mat im;
inputVideo.retrieve(im);
im.copyTo(image);
unsigned long ret_val = RET_OK;
std::vector<t_points> vec_points;
if (tag_detector->GetPoints(image,vec_points) & RET_Failed)
{
puts("No tags detected");
//return -1;
}
for (unsigned int i=0; i<vec_points.size(); i++)
{
std::cout << "Detected Tag " << vec_points[i].id << ": " << vec_points[i].image_points << std::endl;
}
cv::imshow("out",image);
char key = (char) cv::waitKey(10);
if(key == 27)
break;
}
使用实时摄像头时,我总是“未检测到标签”,我不知道为什么,也不知道如何更改代码。 也许它不适合实时相机,但如果在照片上检测到标签,我不知道为什么在实时相机上检测不到。
/// Locates the fiducial within the image
/// @param image scene image
/// @param vec_points Vector of points from all detected tags
/// @return <code>RET_Failed</code> if no tag Could be detected
/// <code>RET_OK</code> on success
virtual unsigned long GetPoints(cv::Mat& image,std::vector<t_points>& vec_points) = 0;
函数 GetPoints 返回 RET_Failed,但我不知道为什么
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)