+++ /dev/null
-#include <iostream>\r
-#include <fstream>\r
-#include <string>\r
-#include <sstream>\r
-#include <iomanip>\r
-#include <stdexcept>\r
-#include "opencv2/gpu/gpu.hpp"\r
-#include "opencv2/highgui/highgui.hpp"\r
-\r
-using namespace std;\r
-using namespace cv;\r
-\r
-\r
-/** Contains all properties of application (including those which can be\r
-changed by user in runtime) */\r
-class Settings\r
-{\r
-public:\r
- /** Sets default values */\r
- Settings();\r
-\r
- /** Reads settings from command args */\r
- static Settings Read(int argc, char** argv);\r
-\r
- string src;\r
- bool src_is_video;\r
- bool make_gray;\r
- bool resize_src;\r
- double resize_src_scale;\r
- double scale;\r
- int nlevels;\r
- int gr_threshold;\r
- double hit_threshold;\r
- int win_width;\r
- int win_stride_width;\r
- int win_stride_height;\r
-};\r
-\r
-\r
-/** Describes aplication logic */\r
-class App\r
-{\r
-public:\r
- /** Initializes application */\r
- App(const Settings& s);\r
-\r
- /** Runs demo using OpenCV highgui module for GUI building */\r
- void RunOpencvGui();\r
-\r
- /** Processes user keybord input */\r
- void HandleKey(char key);\r
-\r
- void HogWorkBegin();\r
- void HogWorkEnd();\r
- double HogWorkFps() const;\r
-\r
- void WorkBegin();\r
- void WorkEnd();\r
- double WorkFps() const;\r
-\r
- const string GetPerformanceSummary() const;\r
-\r
-private:\r
- App operator=(App&);\r
-\r
- Settings settings;\r
- bool running;\r
-\r
- bool use_gpu;\r
- bool make_gray;\r
- double scale;\r
- int gr_threshold;\r
- int nlevels;\r
- double hit_threshold;\r
-\r
- int64 hog_work_begin;\r
- double hog_work_fps;\r
-\r
- int64 work_begin;\r
- double work_fps;\r
-};\r
-\r
-\r
-int main(int argc, char** argv)\r
-{\r
- try\r
- {\r
- if (argc < 2)\r
- {\r
- cout << "Usage:\nsample_hog\n"\r
- << " -src <path_to_the_source>\n"\r
- << " [-src_is_video <true/false>] # says to interp. src as img or as video\n"\r
- << " [-make_gray <true/false>] # convert image to gray one or not\n"\r
- << " [-resize_src <true/false>] # do resize of the source image or not\n"\r
- << " [-resize_src_scale <double>] # preprocessing image scale factor\n"\r
- << " [-hit_threshold <double>] # classifying plane dist. threshold (0.0 usually)\n"\r
- << " [-scale <double>] # HOG window scale factor\n"\r
- << " [-nlevels <int>] # max number of HOG window scales\n"\r
- << " [-win_width <int>] # width of the window (48 or 64)\n"\r
- << " [-win_stride_width <int>] # distance by OX axis between neighbour wins\n"\r
- << " [-win_stride_height <int>] # distance by OY axis between neighbour wins\n"\r
- << " [-gr_threshold <int>] # merging similar rects constant\n";\r
- return 1;\r
- }\r
- App app(Settings::Read(argc, argv));\r
- app.RunOpencvGui();\r
- }\r
- catch (const Exception& e) { return cout << "Error: " << e.what() << endl, 1; }\r
- catch (const exception& e) { return cout << "Error: " << e.what() << endl, 1; }\r
- catch(...) { return cout << "Unknown exception" << endl, 1; }\r
- return 0;\r
-}\r
-\r
-\r
-Settings::Settings()\r
-{\r
- src_is_video = false;\r
- make_gray = false;\r
- resize_src = true;\r
- resize_src_scale = 1.5;\r
- scale = 1.05;\r
- nlevels = 13;\r
- gr_threshold = 8;\r
- hit_threshold = 1.4;\r
- win_width = 48;\r
- win_stride_width = 8;\r
- win_stride_height = 8;\r
-}\r
-\r
-\r
-Settings Settings::Read(int argc, char** argv)\r
-{\r
- cout << "Parsing command args" << endl;\r
-\r
- Settings settings;\r
- for (int i = 1; i < argc - 1; i += 2)\r
- {\r
- string key = argv[i];\r
- string val = argv[i + 1];\r
- if (key == "-src") settings.src = val;\r
- else if (key == "-src_is_video") settings.src_is_video = (val == "true");\r
- else if (key == "-make_gray") settings.make_gray = (val == "true");\r
- else if (key == "-resize_src") settings.resize_src = (val == "true");\r
- else if (key == "-resize_src_scale") settings.resize_src_scale = atof(val.c_str());\r
- else if (key == "-hit_threshold") settings.hit_threshold = atof(val.c_str());\r
- else if (key == "-scale") settings.scale = atof(val.c_str());\r
- else if (key == "-nlevels") settings.nlevels = atoi(val.c_str());\r
- else if (key == "-win_width") settings.win_width = atoi(val.c_str());\r
- else if (key == "-win_stride_width") settings.win_stride_width = atoi(val.c_str());\r
- else if (key == "-win_stride_height") settings.win_stride_height = atoi(val.c_str());\r
- else if (key == "-gr_threshold") settings.gr_threshold = atoi(val.c_str());\r
- else throw runtime_error((string("Unknown key: ") + key));\r
- }\r
-\r
- cout << "Command args are parsed\n";\r
- return settings;\r
-}\r
-\r
-\r
-App::App(const Settings &s)\r
-{\r
- settings = s;\r
- cout << "\nControls:\n"\r
- << "\tESC - exit\n"\r
- << "\tm - change mode GPU <-> CPU\n"\r
- << "\tg - convert image to gray or not\n"\r
- << "\t1/q - increase/decrease HOG scale\n"\r
- << "\t2/w - increase/decrease levels count\n"\r
- << "\t3/e - increase/decrease HOG group threshold\n"\r
- << "\t4/r - increase/decrease hit threshold\n"\r
- << endl;\r
-\r
- use_gpu = true;\r
- make_gray = settings.make_gray;\r
- scale = settings.scale;\r
- gr_threshold = settings.gr_threshold;\r
- nlevels = settings.nlevels;\r
- hit_threshold = settings.hit_threshold;\r
-\r
- if (settings.win_width != 64 && settings.win_width != 48)\r
- settings.win_width = 64;\r
-\r
- cout << "Scale: " << scale << endl;\r
- cout << "Group threshold: " << gr_threshold << endl;\r
- cout << "Levels number: " << nlevels << endl;\r
- cout << "Win width: " << settings.win_width << endl;\r
- cout << "Win stride: (" << settings.win_stride_width << ", " << settings.win_stride_height << ")\n";\r
- cout << "Hit threshold: " << hit_threshold << endl;\r
- cout << endl;\r
-}\r
-\r
-\r
-void App::RunOpencvGui()\r
-{\r
- running = true;\r
-\r
- Size win_size(settings.win_width, settings.win_width * 2); //(64, 128) or (48, 96)\r
- Size win_stride(settings.win_stride_width, settings.win_stride_height);\r
-\r
- vector<float> detector;\r
-\r
- if (win_size == Size(64, 128))\r
- detector = cv::gpu::HOGDescriptor::getPeopleDetector_64x128();\r
- else\r
- detector = cv::gpu::HOGDescriptor::getPeopleDetector_48x96();\r
-\r
- // GPU's HOG classifier\r
- cv::gpu::HOGDescriptor gpu_hog(win_size);\r
- gpu_hog.setSVMDetector(detector);\r
-\r
- // CPU's HOG classifier\r
- cv::HOGDescriptor cpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9, 1, -1, HOGDescriptor::L2Hys, 0.2, true, HOGDescriptor::DEFAULT_NLEVELS);\r
- cpu_hog.setSVMDetector(detector);\r
-\r
- // Make endless cycle from video (if src is video)\r
- while (running)\r
- {\r
- VideoCapture vc;\r
- Mat frame;\r
-\r
- if (settings.src_is_video)\r
- {\r
- vc.open(settings.src.c_str());\r
- if (!vc.isOpened())\r
- throw runtime_error(string("Can't open video file: " + settings.src));\r
- vc >> frame;\r
- }\r
- else\r
- {\r
- frame = imread(settings.src);\r
- if (frame.empty())\r
- throw runtime_error(string("Can't open image file: " + settings.src));\r
- }\r
-\r
- Mat img_aux, img, img_to_show;\r
- gpu::GpuMat gpu_img;\r
-\r
- // Iterate over all frames\r
- while (running && !frame.empty())\r
- {\r
- WorkBegin();\r
-\r
- vector<Rect> found;\r
-\r
- // Change format of the image (input must be 8UC3)\r
- if (make_gray)\r
- cvtColor(frame, img_aux, CV_BGR2GRAY);\r
- else if (use_gpu)\r
- cvtColor(frame, img_aux, CV_BGR2BGRA);\r
- else\r
- img_aux = frame;\r
-\r
- // Resize image\r
- if (settings.resize_src)\r
- resize(img_aux, img, Size(int(frame.cols * settings.resize_src_scale), int(frame.rows * settings.resize_src_scale)));\r
- else\r
- img = img_aux;\r
- img_to_show = img;\r
-\r
- gpu_hog.nlevels = nlevels;\r
- cpu_hog.nlevels = nlevels;\r
-\r
- // Perform HOG classification\r
- HogWorkBegin();\r
- if (use_gpu)\r
- {\r
- gpu_img = img;\r
- gpu_hog.detectMultiScale(gpu_img, found, hit_threshold, win_stride, Size(0, 0), scale, gr_threshold);\r
- }\r
- else\r
- cpu_hog.detectMultiScale(img, found, hit_threshold, win_stride, Size(0, 0), scale, gr_threshold);\r
- HogWorkEnd();\r
-\r
- // Draw positive classified windows\r
- for (size_t i = 0; i < found.size(); i++)\r
- {\r
- Rect r = found[i];\r
- rectangle(img_to_show, r.tl(), r.br(), CV_RGB(0, 255, 0), 3);\r
- }\r
-\r
- WorkEnd();\r
-\r
- // Show results\r
- putText(img_to_show, GetPerformanceSummary(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 255), 2);\r
- imshow("opencv_gpu_hog", img_to_show);\r
- HandleKey((char)waitKey(1));\r
-\r
- if (settings.src_is_video)\r
- {\r
- vc >> frame;\r
- }\r
- }\r
- }\r
-}\r
-\r
-\r
-void App::HandleKey(char key)\r
-{\r
- switch (key)\r
- {\r
- case 27:\r
- running = false;\r
- break;\r
- case 'm':\r
- case 'M':\r
- use_gpu = !use_gpu;\r
- cout << "Switched to " << (use_gpu ? "CUDA" : "CPU") << " mode\n";\r
- break;\r
- case 'g':\r
- case 'G':\r
- make_gray = !make_gray;\r
- cout << "Convert image to gray: " << (make_gray ? "YES" : "NO") << endl;\r
- break;\r
- case '1':\r
- scale *= 1.05;\r
- cout << "Scale: " << scale << endl;\r
- break;\r
- case 'q':\r
- case 'Q':\r
- scale /= 1.05;\r
- cout << "Scale: " << scale << endl;\r
- break;\r
- case '2':\r
- nlevels++;\r
- cout << "Levels number: " << nlevels << endl;\r
- break;\r
- case 'w':\r
- case 'W':\r
- nlevels = max(nlevels - 1, 1);\r
- cout << "Levels number: " << nlevels << endl;\r
- break;\r
- case '3':\r
- gr_threshold++;\r
- cout << "Group threshold: " << gr_threshold << endl;\r
- break;\r
- case 'e':\r
- case 'E':\r
- gr_threshold = max(0, gr_threshold - 1);\r
- cout << "Group threshold: " << gr_threshold << endl;\r
- break;\r
- case '4':\r
- hit_threshold+=0.25;\r
- cout << "Hit threshold: " << hit_threshold << endl;\r
- break;\r
- case 'r':\r
- case 'R':\r
- hit_threshold = max(0.0, hit_threshold - 0.25);\r
- cout << "Hit threshold: " << hit_threshold << endl;\r
- break;\r
- }\r
-}\r
-\r
-\r
-inline void App::HogWorkBegin() { hog_work_begin = getTickCount(); }\r
-\r
-\r
-inline void App::HogWorkEnd()\r
-{\r
- int64 delta = getTickCount() - hog_work_begin;\r
- double freq = getTickFrequency();\r
- hog_work_fps = freq / delta;\r
-}\r
-\r
-\r
-inline double App::HogWorkFps() const { return hog_work_fps; }\r
-\r
-\r
-inline void App::WorkBegin() { work_begin = getTickCount(); }\r
-\r
-\r
-inline void App::WorkEnd()\r
-{\r
- int64 delta = getTickCount() - work_begin;\r
- double freq = getTickFrequency();\r
- work_fps = freq / delta;\r
-}\r
-\r
-\r
-inline double App::WorkFps() const { return work_fps; }\r
-\r
-\r
-inline const string App::GetPerformanceSummary() const\r
-{\r
- stringstream ss;\r
- ss << (use_gpu ? "GPU" : "CPU") << " HOG FPS: " << setiosflags(ios::left) << setprecision(4) <<\r
- setw(7) << HogWorkFps() << " Total FPS: " << setprecision(4) << setw(7) << WorkFps();\r
- return ss.str();\r
-}\r
--- /dev/null
+#include <iostream>\r
+#include <fstream>\r
+#include <string>\r
+#include <sstream>\r
+#include <iomanip>\r
+#include <stdexcept>\r
+#include "opencv2/gpu/gpu.hpp"\r
+#include "opencv2/highgui/highgui.hpp"\r
+\r
+using namespace std;\r
+using namespace cv;\r
+\r
+\r
+/** Contains all properties of application (including those which can be\r
+changed by user in runtime) */\r
+class Settings\r
+{\r
+public:\r
+ /** Sets default values */\r
+ Settings();\r
+\r
+ /** Reads settings from command args */\r
+ static Settings Read(int argc, char** argv);\r
+\r
+ string src;\r
+ bool src_is_video;\r
+ bool make_gray;\r
+ bool resize_src;\r
+ double resize_src_scale;\r
+ double scale;\r
+ int nlevels;\r
+ int gr_threshold;\r
+ double hit_threshold;\r
+ int win_width;\r
+ int win_stride_width;\r
+ int win_stride_height;\r
+};\r
+\r
+\r
+/** Describes aplication logic */\r
+class App\r
+{\r
+public:\r
+ /** Initializes application */\r
+ App(const Settings& s);\r
+\r
+ /** Runs demo using OpenCV highgui module for GUI building */\r
+ void RunOpencvGui();\r
+\r
+ /** Processes user keybord input */\r
+ void HandleKey(char key);\r
+\r
+ void HogWorkBegin();\r
+ void HogWorkEnd();\r
+ double HogWorkFps() const;\r
+\r
+ void WorkBegin();\r
+ void WorkEnd();\r
+ double WorkFps() const;\r
+\r
+ const string GetPerformanceSummary() const;\r
+\r
+private:\r
+ App operator=(App&);\r
+\r
+ Settings settings;\r
+ bool running;\r
+\r
+ bool use_gpu;\r
+ bool make_gray;\r
+ double scale;\r
+ int gr_threshold;\r
+ int nlevels;\r
+ double hit_threshold;\r
+\r
+ int64 hog_work_begin;\r
+ double hog_work_fps;\r
+\r
+ int64 work_begin;\r
+ double work_fps;\r
+};\r
+\r
+\r
+int main(int argc, char** argv)\r
+{\r
+ try\r
+ {\r
+ if (argc < 2)\r
+ {\r
+ cout << "Usage:\nsample_hog\n"\r
+ << " -src <path_to_the_source>\n"\r
+ << " [-src_is_video <true/false>] # says to interp. src as img or as video\n"\r
+ << " [-make_gray <true/false>] # convert image to gray one or not\n"\r
+ << " [-resize_src <true/false>] # do resize of the source image or not\n"\r
+ << " [-resize_src_scale <double>] # preprocessing image scale factor\n"\r
+ << " [-hit_threshold <double>] # classifying plane dist. threshold (0.0 usually)\n"\r
+ << " [-scale <double>] # HOG window scale factor\n"\r
+ << " [-nlevels <int>] # max number of HOG window scales\n"\r
+ << " [-win_width <int>] # width of the window (48 or 64)\n"\r
+ << " [-win_stride_width <int>] # distance by OX axis between neighbour wins\n"\r
+ << " [-win_stride_height <int>] # distance by OY axis between neighbour wins\n"\r
+ << " [-gr_threshold <int>] # merging similar rects constant\n";\r
+ return 1;\r
+ }\r
+ App app(Settings::Read(argc, argv));\r
+ app.RunOpencvGui();\r
+ }\r
+ catch (const Exception& e) { return cout << "Error: " << e.what() << endl, 1; }\r
+ catch (const exception& e) { return cout << "Error: " << e.what() << endl, 1; }\r
+ catch(...) { return cout << "Unknown exception" << endl, 1; }\r
+ return 0;\r
+}\r
+\r
+\r
+Settings::Settings()\r
+{\r
+ src_is_video = false;\r
+ make_gray = false;\r
+ resize_src = true;\r
+ resize_src_scale = 1.5;\r
+ scale = 1.05;\r
+ nlevels = 13;\r
+ gr_threshold = 8;\r
+ hit_threshold = 1.4;\r
+ win_width = 48;\r
+ win_stride_width = 8;\r
+ win_stride_height = 8;\r
+}\r
+\r
+\r
+Settings Settings::Read(int argc, char** argv)\r
+{\r
+ cout << "Parsing command args" << endl;\r
+\r
+ Settings settings;\r
+ for (int i = 1; i < argc - 1; i += 2)\r
+ {\r
+ string key = argv[i];\r
+ string val = argv[i + 1];\r
+ if (key == "-src") settings.src = val;\r
+ else if (key == "-src_is_video") settings.src_is_video = (val == "true");\r
+ else if (key == "-make_gray") settings.make_gray = (val == "true");\r
+ else if (key == "-resize_src") settings.resize_src = (val == "true");\r
+ else if (key == "-resize_src_scale") settings.resize_src_scale = atof(val.c_str());\r
+ else if (key == "-hit_threshold") settings.hit_threshold = atof(val.c_str());\r
+ else if (key == "-scale") settings.scale = atof(val.c_str());\r
+ else if (key == "-nlevels") settings.nlevels = atoi(val.c_str());\r
+ else if (key == "-win_width") settings.win_width = atoi(val.c_str());\r
+ else if (key == "-win_stride_width") settings.win_stride_width = atoi(val.c_str());\r
+ else if (key == "-win_stride_height") settings.win_stride_height = atoi(val.c_str());\r
+ else if (key == "-gr_threshold") settings.gr_threshold = atoi(val.c_str());\r
+ else throw runtime_error((string("Unknown key: ") + key));\r
+ }\r
+\r
+ cout << "Command args are parsed\n";\r
+ return settings;\r
+}\r
+\r
+\r
+App::App(const Settings &s)\r
+{\r
+ settings = s;\r
+ cout << "\nControls:\n"\r
+ << "\tESC - exit\n"\r
+ << "\tm - change mode GPU <-> CPU\n"\r
+ << "\tg - convert image to gray or not\n"\r
+ << "\t1/q - increase/decrease HOG scale\n"\r
+ << "\t2/w - increase/decrease levels count\n"\r
+ << "\t3/e - increase/decrease HOG group threshold\n"\r
+ << "\t4/r - increase/decrease hit threshold\n"\r
+ << endl;\r
+\r
+ use_gpu = true;\r
+ make_gray = settings.make_gray;\r
+ scale = settings.scale;\r
+ gr_threshold = settings.gr_threshold;\r
+ nlevels = settings.nlevels;\r
+ hit_threshold = settings.hit_threshold;\r
+\r
+ if (settings.win_width != 64 && settings.win_width != 48)\r
+ settings.win_width = 64;\r
+\r
+ cout << "Scale: " << scale << endl;\r
+ cout << "Group threshold: " << gr_threshold << endl;\r
+ cout << "Levels number: " << nlevels << endl;\r
+ cout << "Win width: " << settings.win_width << endl;\r
+ cout << "Win stride: (" << settings.win_stride_width << ", " << settings.win_stride_height << ")\n";\r
+ cout << "Hit threshold: " << hit_threshold << endl;\r
+ cout << endl;\r
+}\r
+\r
+\r
+void App::RunOpencvGui()\r
+{\r
+ running = true;\r
+\r
+ Size win_size(settings.win_width, settings.win_width * 2); //(64, 128) or (48, 96)\r
+ Size win_stride(settings.win_stride_width, settings.win_stride_height);\r
+\r
+ vector<float> detector;\r
+\r
+ if (win_size == Size(64, 128))\r
+ detector = cv::gpu::HOGDescriptor::getPeopleDetector_64x128();\r
+ else\r
+ detector = cv::gpu::HOGDescriptor::getPeopleDetector_48x96();\r
+\r
+ // GPU's HOG classifier\r
+ cv::gpu::HOGDescriptor gpu_hog(win_size);\r
+ gpu_hog.setSVMDetector(detector);\r
+\r
+ // CPU's HOG classifier\r
+ cv::HOGDescriptor cpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9, 1, -1, HOGDescriptor::L2Hys, 0.2, true, HOGDescriptor::DEFAULT_NLEVELS);\r
+ cpu_hog.setSVMDetector(detector);\r
+\r
+ // Make endless cycle from video (if src is video)\r
+ while (running)\r
+ {\r
+ VideoCapture vc;\r
+ Mat frame;\r
+\r
+ if (settings.src_is_video)\r
+ {\r
+ vc.open(settings.src.c_str());\r
+ if (!vc.isOpened())\r
+ throw runtime_error(string("Can't open video file: " + settings.src));\r
+ vc >> frame;\r
+ }\r
+ else\r
+ {\r
+ frame = imread(settings.src);\r
+ if (frame.empty())\r
+ throw runtime_error(string("Can't open image file: " + settings.src));\r
+ }\r
+\r
+ Mat img_aux, img, img_to_show;\r
+ gpu::GpuMat gpu_img;\r
+\r
+ // Iterate over all frames\r
+ while (running && !frame.empty())\r
+ {\r
+ WorkBegin();\r
+\r
+ vector<Rect> found;\r
+\r
+ // Change format of the image (input must be 8UC3)\r
+ if (make_gray)\r
+ cvtColor(frame, img_aux, CV_BGR2GRAY);\r
+ else if (use_gpu)\r
+ cvtColor(frame, img_aux, CV_BGR2BGRA);\r
+ else\r
+ img_aux = frame;\r
+\r
+ // Resize image\r
+ if (settings.resize_src)\r
+ resize(img_aux, img, Size(int(frame.cols * settings.resize_src_scale), int(frame.rows * settings.resize_src_scale)));\r
+ else\r
+ img = img_aux;\r
+ img_to_show = img;\r
+\r
+ gpu_hog.nlevels = nlevels;\r
+ cpu_hog.nlevels = nlevels;\r
+\r
+ // Perform HOG classification\r
+ HogWorkBegin();\r
+ if (use_gpu)\r
+ {\r
+ gpu_img = img;\r
+ gpu_hog.detectMultiScale(gpu_img, found, hit_threshold, win_stride, Size(0, 0), scale, gr_threshold);\r
+ }\r
+ else\r
+ cpu_hog.detectMultiScale(img, found, hit_threshold, win_stride, Size(0, 0), scale, gr_threshold);\r
+ HogWorkEnd();\r
+\r
+ // Draw positive classified windows\r
+ for (size_t i = 0; i < found.size(); i++)\r
+ {\r
+ Rect r = found[i];\r
+ rectangle(img_to_show, r.tl(), r.br(), CV_RGB(0, 255, 0), 3);\r
+ }\r
+\r
+ WorkEnd();\r
+\r
+ // Show results\r
+ putText(img_to_show, GetPerformanceSummary(), Point(5, 25), FONT_HERSHEY_SIMPLEX, 1.0, Scalar(0, 0, 255), 2);\r
+ imshow("opencv_gpu_hog", img_to_show);\r
+ HandleKey((char)waitKey(1));\r
+\r
+ if (settings.src_is_video)\r
+ {\r
+ vc >> frame;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+\r
+void App::HandleKey(char key)\r
+{\r
+ switch (key)\r
+ {\r
+ case 27:\r
+ running = false;\r
+ break;\r
+ case 'm':\r
+ case 'M':\r
+ use_gpu = !use_gpu;\r
+ cout << "Switched to " << (use_gpu ? "CUDA" : "CPU") << " mode\n";\r
+ break;\r
+ case 'g':\r
+ case 'G':\r
+ make_gray = !make_gray;\r
+ cout << "Convert image to gray: " << (make_gray ? "YES" : "NO") << endl;\r
+ break;\r
+ case '1':\r
+ scale *= 1.05;\r
+ cout << "Scale: " << scale << endl;\r
+ break;\r
+ case 'q':\r
+ case 'Q':\r
+ scale /= 1.05;\r
+ cout << "Scale: " << scale << endl;\r
+ break;\r
+ case '2':\r
+ nlevels++;\r
+ cout << "Levels number: " << nlevels << endl;\r
+ break;\r
+ case 'w':\r
+ case 'W':\r
+ nlevels = max(nlevels - 1, 1);\r
+ cout << "Levels number: " << nlevels << endl;\r
+ break;\r
+ case '3':\r
+ gr_threshold++;\r
+ cout << "Group threshold: " << gr_threshold << endl;\r
+ break;\r
+ case 'e':\r
+ case 'E':\r
+ gr_threshold = max(0, gr_threshold - 1);\r
+ cout << "Group threshold: " << gr_threshold << endl;\r
+ break;\r
+ case '4':\r
+ hit_threshold+=0.25;\r
+ cout << "Hit threshold: " << hit_threshold << endl;\r
+ break;\r
+ case 'r':\r
+ case 'R':\r
+ hit_threshold = max(0.0, hit_threshold - 0.25);\r
+ cout << "Hit threshold: " << hit_threshold << endl;\r
+ break;\r
+ }\r
+}\r
+\r
+\r
+inline void App::HogWorkBegin() { hog_work_begin = getTickCount(); }\r
+\r
+\r
+inline void App::HogWorkEnd()\r
+{\r
+ int64 delta = getTickCount() - hog_work_begin;\r
+ double freq = getTickFrequency();\r
+ hog_work_fps = freq / delta;\r
+}\r
+\r
+\r
+inline double App::HogWorkFps() const { return hog_work_fps; }\r
+\r
+\r
+inline void App::WorkBegin() { work_begin = getTickCount(); }\r
+\r
+\r
+inline void App::WorkEnd()\r
+{\r
+ int64 delta = getTickCount() - work_begin;\r
+ double freq = getTickFrequency();\r
+ work_fps = freq / delta;\r
+}\r
+\r
+\r
+inline double App::WorkFps() const { return work_fps; }\r
+\r
+\r
+inline const string App::GetPerformanceSummary() const\r
+{\r
+ stringstream ss;\r
+ ss << (use_gpu ? "GPU" : "CPU") << " HOG FPS: " << setiosflags(ios::left) << setprecision(4) <<\r
+ setw(7) << HogWorkFps() << " Total FPS: " << setprecision(4) << setw(7) << WorkFps();\r
+ return ss.str();\r
+}\r