#include <iostream>
#include <iomanip>
{
enum Mode { Default, Daimler } m;
public:
Detector() : m(Default), hog(), hog_d(
Size(48, 96),
Size(16, 16),
Size(8, 8),
Size(8, 8), 9)
{
}
void toggleMode() { m = (m == Default ? Daimler : Default); }
string modeName() const { return (m == Default ? "Default" : "Daimler"); }
{
vector<Rect> found;
if (m == Default)
else if (m == Daimler)
return found;
}
void adjustRect(
Rect & r)
const {
}
};
static const string keys = "{ help h | | print help message }"
"{ camera c | 0 | capture video from camera (device index starting from 0) }"
"{ video v | | use video as input }";
int main(int argc, char** argv)
{
parser.
about(
"This sample demonstrates the use of the HoG descriptor.");
{
return 0;
}
int camera = parser.
get<
int>(
"camera");
string file = parser.
get<
string>(
"video");
{
return 1;
}
if (file.empty())
else
{
}
{
cout << "Can not open video stream: '" << (file.empty() ? "<camera>" : file) << "'" << endl;
return 2;
}
cout << "Press 'q' or <ESC> to quit." << endl;
cout << "Press <space> to toggle between Default and Daimler detector" << endl;
for (;;)
{
cap >> frame;
if (frame.empty())
{
cout << "Finished reading: empty frame" << endl;
break;
}
vector<Rect> found = detector.detect(frame);
{
ostringstream buf;
buf << "Mode: " << detector.modeName() << " ||| "
putText(frame, buf.str(),
Point(10, 30),
FONT_HERSHEY_PLAIN, 2.0,
Scalar(0, 0, 255), 2,
LINE_AA);
}
for (vector<Rect>::iterator i = found.begin(); i != found.end(); ++i)
{
detector.adjustRect(r);
}
imshow(
"People detector", frame);
if (key == 27 || key == 'q')
{
cout << "Exit requested" << endl;
break;
}
else if (key == ' ')
{
detector.toggleMode();
}
}
return 0;
}