05/14 끝
This commit is contained in:
36
ch13/hog/main.cpp
Normal file
36
ch13/hog/main.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
#include "opencv2/opencv.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
int main() {
|
||||
VideoCapture cap("../../resources/images/vtest.avi");
|
||||
|
||||
HOGDescriptor hog;
|
||||
hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());
|
||||
|
||||
Mat frame;
|
||||
while (true) {
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
break;
|
||||
|
||||
vector<Rect> detected;
|
||||
vector<double> weights;
|
||||
hog.detectMultiScale(frame, detected, weights);
|
||||
|
||||
for (int i = 0; i < detected.size(); i++) {
|
||||
Scalar c = Scalar(rand() & 255, rand() & 255, rand() & 255);
|
||||
if (weights[i] < .8f)
|
||||
continue;
|
||||
rectangle(frame, detected[i], c);
|
||||
putText(frame, "conf: " + to_string(weights[i]), detected[i].tl(), FONT_HERSHEY_SIMPLEX, 1, c, 2, LINE_AA);
|
||||
}
|
||||
|
||||
imshow("frame", frame);
|
||||
|
||||
if (waitKey(10) == 27)
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user