gou*_*oer 11 c++ opencv image-processing
我成功地跟踪了视频中的移动物体.

但是我想决定一个对象是否是人.我HOGDescriptor在OpenCV中尝试过.HOGDescriptor有两种检测人的方法:HOGDescriptor::detect和HOGDescriptor::detectMultiScale.OpenCV "sources\samples\cpp\peopledetect.cpp"演示了如何使用HOGDescriptor::detectMultiScale,它以不同的比例搜索图像并且非常慢.
就我而言,我已经跟踪了矩形中的对象.我认为使用HOGDescriptor::detect检测矩形内部会更快.但OpenCV文件只有gpu::HOGDescriptor::detect(我仍然无法猜测如何使用它)而错过了HOGDescriptor::detect.我想用HOGDescriptor::detect.
任何人都可以提供一些c ++代码片段来演示使用HOGDescriptor::detect?
谢谢.
jet*_*t47 11
由于您已经有了一个对象列表,因此可以HOGDescriptor::detect为所有对象调用该方法并检查输出foundLocations数组.如果它不是空的,则该对象被归类为人.唯一的问题是HOG 64x128默认使用Windows,因此您需要重新调整对象:
std::vector<cv::Rect> movingObjects = ...;
cv::HOGDescriptor hog;
hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());
std::vector<cv::Point> foundLocations;
for (size_t i = 0; i < movingObjects.size(); ++i)
{
cv::Mat roi = image(movingObjects[i]);
cv::Mat window;
cv::resize(roi, window, cv::Size(64, 128));
hog.detect(window, foundLocations);
if (!foundLocations.empty())
{
// movingObjects[i] is a person
}
}
Run Code Online (Sandbox Code Playgroud)