diff --git a/apps/detector_razumov.cpp b/apps/detector_razumov.cpp new file mode 100644 index 0000000..2161193 --- /dev/null +++ b/apps/detector_razumov.cpp @@ -0,0 +1,99 @@ +#include +#include +#include + +#include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/objdetect/objdetect.hpp" + +using namespace std; +using namespace cv; + +const char* params = + "{ h | help | false | print usage }" + "{ | detector | | XML file with a cascade detector }" + "{ | image | | image to detect objects on }" + "{ | video | | video file to detect on }" + "{ | camera | false | whether to detect on video stream from camera }"; + + +void drawDetections(const vector& detections, + const Scalar& color, + Mat& image) +{ + for (size_t i = 0; i < detections.size(); ++i) + { + rectangle(image, detections[i], color, 2); + } +} + +const Scalar red(0, 0, 255); +const Scalar green(0, 255, 0); +const Scalar blue(255, 0, 0); +const Scalar colors[] = {red, green, blue}; + +int main(int argc, char** argv) +{ + CascadeClassifier detec; + + // Parse command line arguments. + CommandLineParser parser(argc, argv, params); + // If help flag is present, print help message and exit. + if (parser.get("help")) + { + parser.printParams(); + return 0; + } + + string detector_file = parser.get("detector"); + CV_Assert(!detector_file.empty()); + string image_file = parser.get("image"); + string video_file = parser.get("video"); + bool use_camera = parser.get("camera"); + + // TODO: Load detector. + detec.load(detector_file); + + if (!image_file.empty()) + { + Mat img = imread(image_file); + vector logos; + detec.detectMultiScale(img, logos, 1.1, 3, 0, Size(10, 10), Size(200,200)); + cout< faces; + + VideoCapture cap(0); if(!cap.isOpened()) cout<<"can't open video from camera" ; + namedWindow("noname",1); + while(true) + { + cap >> yourface; + face_cascade.detectMultiScale(yourface, faces, 1.1, 3, 0, Size(10, 10), Size(200,200)); + if(faces.size()>0) imshow("noname", yourface); + else cout<<"where are you?"; + if(waitKey(30) >= 0) break; + } + } + else + { + cout << "Declare a source of images to detect on." << endl; + } + + return 0; +} + + +