This repository was archived by the owner on Sep 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetector.cpp
More file actions
executable file
·62 lines (53 loc) · 1.6 KB
/
Copy pathDetector.cpp
File metadata and controls
executable file
·62 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "stdafx.h"
#include "Detector.h"
using namespace cv;
using namespace std;
PDetector::PDetector(Drawing *painter)
{
paint = painter;
//Detect Pedestrians using HOG using Daimler detector of OpenCV
//Parameters set are default tuning for Daimler detector
hog = HOGDescriptor(cv::Size(48, 96), cv::Size(16, 16), cv::Size(8, 8), cv::Size(8, 8), 9, 1,-1, cv::HOGDescriptor::L2Hys, 0.2, true, cv::HOGDescriptor::DEFAULT_NLEVELS);
hog.setSVMDetector(cv::HOGDescriptor::getDaimlerPeopleDetector());
vector<Rect> rects;
vector<Point2d> centers;
}
/**
Method used to
@param img: MAT object of the frame where pedestrians are detected
@param pedestrians: Vector in which all detected pedestrians are stored
**/
void PDetector::DetectPedestrians(Mat& img,vector<pedestrian>& pedestrians)
{
pedestrians.clear();
pedestrian p;
vector<Rect> found;
hog.detectMultiScale(img, found, 1.5, cv::Size(8,8), cv::Size(0,0), 1.05, 2);
for (i=0; i<found.size(); i++)
{
cv::Rect r = found[i];
p.rect = r;
p.center = (r.tl()+r.br())*0.5;
for (j=0; j<found.size(); j++)
if (j!=i && (r & found[j])==r)
break;
if (j==found.size())
{
p.center = (r.br()+r.tl())*0.5;
pedestrians.push_back(p);
}
}
paint->drawRectanglefromDetection(img,pedestrians);
}
/**
Method used to call Detect pedestrians to return list of pedestrians in frame
@param img: image in which pedestrians need to be detected
**/
vector<pedestrian> PDetector::Detect(Mat& img)
{
DetectPedestrians(img,pedestrians);
return pedestrians;
}
PDetector::~PDetector(void)
{
}