36 lines
793 B
C++
36 lines
793 B
C++
#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;
|
|
}
|
|
} |