#include <iostream>
#include <stdexcept>
const char* keys =
{
"{ help h | | print help message }"
"{ image i | | specify input image}"
"{ camera c | | enable camera capturing }"
"{ video v | ../data/vtest.avi | use video as input }"
"{ directory d | | images directory}"
};
{
vector<Rect> found, found_filtered;
for(size_t i = 0; i < found.size(); i++ )
{
size_t j;
for ( j = 0; j < found.size(); j++ )
if ( j != i && (r & found[j]) == r )
break;
if ( j == found.size() )
found_filtered.push_back(r);
}
for (size_t i = 0; i < found_filtered.size(); i++)
{
Rect r = found_filtered[i];
}
}
int main(int argc, char** argv)
{
{
cout << "\nThis program demonstrates the use of the HoG descriptor using\n"
" HOGDescriptor::hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());\n";
cout << "During execution:\n\tHit q or ESC key to quit.\n"
"Note: camera device number must be different from -1.\n" << endl;
return 0;
}
string pattern_glob = "";
string video_filename = "../data/vtest.avi";
int camera_id = -1;
if (parser.
has(
"directory"))
{
pattern_glob = parser.
get<
string>(
"directory");
}
else if (parser.
has(
"image"))
{
pattern_glob = parser.
get<
string>(
"image");
}
else if (parser.
has(
"camera"))
{
camera_id = parser.
get<
int>(
"camera");
}
else if (parser.
has(
"video"))
{
video_filename = parser.
get<
string>(
"video");
}
if (!pattern_glob.empty() || camera_id != -1 || !video_filename.empty())
{
vector<String> filenames;
if (!pattern_glob.empty())
{
}
else if (camera_id != -1)
{
{
stringstream msg;
msg << "can't open camera: " << camera_id;
throw runtime_error(msg.str());
}
}
else
{
vc.
open(video_filename.c_str());
throw runtime_error(string("can't open video file: " + video_filename));
}
vector<String>::const_iterator it_image = filenames.begin();
for (;;)
{
if (!pattern_glob.empty())
{
bool read_image_ok = false;
for (; it_image != filenames.end(); ++it_image)
{
cout << "\nRead: " << *it_image << endl;
{
++it_image;
read_image_ok = true;
break;
}
}
if (!read_image_ok)
{
}
}
else
{
vc >> frame;
}
break;
detectAndDraw(hog, frame);
imshow(
"people detector", frame);
if ( c == 'q' || c == 'Q' || c == 27)
break;
}
}
return 0;
}