05/14 끝

This commit is contained in:
USW
2025-05-14 12:10:39 +09:00
parent 0d9c3ed470
commit 412a044828
30 changed files with 352858 additions and 0 deletions

36
ch13/hog/main.cpp Normal file
View 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;
}
}