What is the reason why the OpenCV program reports vector subscript out of range?

#include "opencv2/objdetect/objdetect.hpp"#incorporate "opencv2/highgui/highgui.hpp"#incorporate "opencv2/imgproc/imgproc.hpp"#incorporate #include using namespace std;making use of nameroom cv;/** Function declaration */void detectAndDisplay(Mat frame); /** Global variables */string face_cascade_name = "haarcascade_frontalface_alt.xml";string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml";CascadeClassifier face_cascade;CascadeClassifier eyes_cascade;string window_name = "Catch - Face detection";RNG rng(12345); /**
Main feature */int main(int argc, const char** argv) CvCapture* capture; Mat frame; //--- 1. Load the cascade classifier file if (!face_cascade.load(face_cascade_name)) printf("--(!)Error loading "); rerevolve -1; ; if (!eyes_cascade.load(eyes_cascade_name)) printf("--(!)Error loading "); return -1; ; //--- 2. Open the video stream of the built-in video camera capture = cvCaptureFromCAM(0); //If the screen is still gray, adjust it to -1 and try if (capture) while (true) frame = cvQueryFrame(capture); //Grab and rerotate a framework from the video camera or file //--- 3. Use the classifier to detect the existing frame if (!framework.empty()) detectAndDisplay(frame); else printf(" --(!) No captured frame -- Break!"); break; int c = waitKey(10); if ((char)c == "c") break; return 0; /**
feature detectAndDisplay */void detectAndDisplay(Mat frame){ std::vector faces; Mat frame_gray; encounters.resize(50000); cvtColor(frame, frame_gray, CV_BGR2GRAY); equalizeHist(frame_gray, frame_gray); //--- multi-dimension face detection face_cascade.detectMultiScale(frame_gray, encounters, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); for (int i = 0; i eyes; eyes.resize(50000); //--- detect both eyes on each challenge eyes_cascade.detectMultiScale(faceROI, eyes, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); for (int j = 0; j This is a straightforward regimen that obtains the camera and also then perdevelops challenge acknowledgment, eyes.resize(50000); and the previous redimension is included by myself, yet after the regimen runs for a while (around five minutes), report the vector subscript out of array error

cvRound((eyes.width + eyes.height)*0.25); // The j for eyes is typed wrong here

Intelligent Recommendation


Expression:vector subscript out of range

  The factor for this difficulty is that the vector container subscript is out of selection, that is, the selection is out of bounds.   The shortreduced sentence I have always supplied as soon as chatting ...

You watching: Vector subscript out of range c++

OpenCV:vector submanuscript out of range

Wrong vector submanuscript out of selection Source modify...


Two-dimensional vector, please be mindful around clear() procedure, beware of vector submanuscript out of variety problems

Today, I desire to usage vector to realize the feature of two-dimensional variety, and also I tried to usage two-dimensional vector. Who knew that I met Lei once I first started. The develop of the code is approximately a...


PCL learning: Surconfront reconstruction based on B-spline curve: Error in the regime "Expression: vector submanuscript out of range"

In debug mode: Error once executing code: The reason has not been located yet; yet, replacing other pcd files, editing and enhancing the input parameters, deserve to run normally; or curve_params.accuracy is collection to ...


C++:vector out of range

#C++:vector out of range# The following error was reported once debugging the code today. As a C++ novice, I was also perplexed. I did not discover the reason for debugging for a long time. Later, I carefu...

See more: Which Boon Do You Prefer? : Wow Boon Of The Butcher Which Boon Do You Prefer

More Recommendation


VS debug C ++ pop-up window throws an exception: debug assertion failed! Expression: Vector Submanuscript Out of Range XXXXXXX

Geneprice the above errors as soon as running C ++ code, the reason of this error is primarily brought about by invalid memory, such as: Generally use invalid iterators can likewise result in access to invalid memory, a...

Vector resize failed, bring about submanuscript out of bounds

Today I got a dump from other teams, and the evaluation showed that the stack is as adheres to Find the matching code as follows The red box is the dump corresponding code. The initially reactivity is...

swing table row is deleted submanuscript out of selection error

If you delete a row in the swing, submanuscript error occurs bereason a line is still in modify mode, you have to first cancel its editorial states: ...

c++ Expression: vector iterator + offset out of range

I encountered this trouble once creating code this day The error of this function is that the addition of the iterator is out of bounds, bereason mybigFlow()The function rerotate value is in between -1 and also n, s...

See more: Wow You Hear A Faint Caw In The Distance And Then Silence, Long Forgotten Hippogryph

The vector iterator offset out of variety problem in C++

C++ primer 3.24 iterator trouble Error code display: The main function of this regimen is to usage an iterator to find the sum of two numbers before and also after a collection of numbers. Report an error after runn...

Related Posts
Popular Posts
Recommended Posts
Related TagsVector errorc++opencvMistakes madeOpenCVTwo-dimensional arrayTwo-dimensional vectorvector submanuscript outclearbug

Categories: Q&A