I just started programming. I have a task to determine on the video machine. The Opencv library has the standard getDefaultPeopleDetector method for defining people. Here is the code for determining the people in the photo:

#include <assert.h> #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <conio.h> using namespace cv; using namespace std; int main() { // Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ тСстовоС ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Mat img = imread("1856.jpg"); // ΡƒΠ²Π΅Π»ΠΈΡ‡ΠΈΠ²Π°Π΅ΠΌ Π½Π°Ρ‡Π°Π»ΡŒΠ½Ρ‹ΠΉ ΠΌΠ°ΡΡˆΡ‚Π°Π± изобраТСния для // поиска ΠΌΠ΅Π»ΠΊΠΈΡ… ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² resize(img, img, Size(2 * img.cols, 2 * img.rows)); // ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ HOG-дСскриптора ΠΈ Π΄Π΅Ρ‚Π΅ΠΊΡ‚ΠΎΡ€Π° int nbins = 9; Size cellSize(8, 8); Size blockSize(16, 16); Size blockStride(8, 8); Size winSize(64, 128); Size winStride(4, 4); // создаСм HOG-дСскриптор/Π΄Π΅Ρ‚Π΅ΠΊΡ‚ΠΎΡ€ HOGDescriptor hog(winSize, blockSize, blockStride, cellSize, nbins); // устанавливаСм Π² качСствС ΠΌΠΎΠ΄Π΅Π»ΠΈ // Π»ΠΈΠ½Π΅ΠΉΠ½ΡƒΡŽ ΠΌΠ°ΡˆΠΈΠ½Ρƒ ΠΎΠΏΠΎΡ€Π½Ρ‹Ρ… Π²Π΅ΠΊΡ‚ΠΎΡ€ΠΎΠ², // ΡΠΎΠΎΡ‚Π²Π΅Ρ‚ΡΡ‚Π²ΡƒΡŽΡ‰ΡƒΡŽ Ρ€Π°Π·ΠΌΠ΅Ρ€Ρƒ ΠΎΠΊΠ½Π° дСтСктирования 64x128. hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector()); // провСряСм соотвСтствиС количСства коэффициСнтов // гипСрплоскости SVM ΠΈ Ρ€Π°Π·ΠΌΠ΅Ρ€Π° HOG-дСскриптора // ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΎΠΊΠ½Π° дСтСктирования assert(hog.checkDetectorSize()); // ΠΏΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΠΌ Π΄Π΅Ρ‚Π΅ΠΊΡ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ vector<Rect> locations; vector<double> weights; hog.detectMultiScale(img, locations, weights, 0.0, winStride, Size(), 1.05, 2., true); // ΡƒΠΌΠ΅Π½ΡŒΡˆΠ°Π΅ΠΌ ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ Π΄ΠΎ Π½Π°Ρ‡Π°Π»ΡŒΠ½Ρ‹Ρ… Ρ€Π°Π·ΠΌΠ΅Ρ€ΠΎΠ² resize(img, img, Size(img.cols / 2, img.rows / 2)); // отрисовываСм срабатывания Π΄Π΅Ρ‚Π΅ΠΊΡ‚ΠΎΡ€Π° Π½Π° ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠΈ for (size_t i = 0; i < locations.size(); ++i) { Rect detection = locations[i]; detection.x /= 2; detection.y /= 2; detection.width /= 2; detection.height /= 2; rectangle(img, detection, Scalar(0, 0, 255), 2); } // ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅ΠΌ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ namedWindow("detections"); imshow("detections", img); waitKey(); destroyAllWindows(); return 0; } 

With the transfer of this algorithm to the video, there were problems. Please help with this.

  • Please explain exactly what problems have occurred. - Cerbo
  • When I try to run this algorithm on every video frame I get an error with the memory "Unhandled exception at 0x00007FFE298F7788 in SVM_HOG.exe: Microsoft C ++ exception: cv :: Exception at memory location 0x000000E6CE95F500" Here I select each frame for further work: - Sergey Kalinin
  • int main () {string filename = "Street.MP4"; VideoCapture capture (filename); Mat frame; namedWindow ("w", 1); for (;;) {capture >> frame; if (frame.empty ()) break; Mat img; Mat framecopy = frame.clone (); - Sergey Kalinin

0