【发布时间】:2019-05-11 15:19:18
【问题描述】:
我正在使用 mmod_faces_detection 示例,我正在尝试获取面部矩形坐标但没有运气,这就是我正在做的事情:
std::vector<rectangle> getFacesVec(matrix<rgb_pixel> img)
{
net_type net;
deserialize("mmod_human_face_detector.dat") >> net;
std::vector<rectangle> r;
while(img.size() < 1800*1800)
pyramid_up(img);
auto dets = net(img);
for (auto&& d : dets) {
r.push_back(d.rect);
}
return r;
}
....
faces = getFacesVec(img);
for (auto f : faces) {
cout << "Rect left: " << f.left() << endl;
cout << "Rect right: " << f.right() << endl;
cout << "Rect top: " << f.top() << endl;
cout << "Rect bottom: " << f.bottom() << endl;
cout << "Rect width: " << f.width() << endl;
cout << "Rect height: " << f.height() << endl;
cv::Rect roi(f.left(), f.top() , f.right(), f.bottom());
cout << "Trying to print cropped face" << endl;
cout << "X = " << roi.x << " Y = " << roi.y << " Width = " << roi.width << " Height = " << roi.height << endl;
cv::Mat crop = m(roi);
sprintf(s, "%d.jpg", i++);
cv::imwrite(s, crop);
}
而且我的坐标超出了图像范围 像这样: 垫子行数:432 垫子列数:768 左矩形:1068 右方:1914 矩形顶部:480 矩形底部:1325 矩形宽度:847 矩形高度:846
我做错了什么?
【问题讨论】: