OPENCV Error: Vector subscript out of range

Source: Internet
Author: User

Author: zf19921020
* Reprint Please indicate the source *

From the basic situation of the error is that the definition of vector vectors subscript overrun, and through the search and their own inquiry, reported the possibility of the following kinds of errors.
1, a vector for the violation of the subscript access, that is, when the vector is not initialized with the [] operator to access the vector, here is explained that the recommended way to access vectors is the use of vectors: Access by iterator or by using the Vector.at method. Before accessing the subscript, you must ensure that the position of the vector represented by the subscript is present, because the compiler does not check the error for you, but only when the programmer himself checks for code.
2, in the function or a scope to define a pointer to the vector and not manually delete it is also possible to report this error, because the memory is not released, it is possible to generate such errors, the recommendation here is the definition of pointers and use of smart pointers to complete, that is, shared_ptr, which is a new feature of c++11 , you can automatically manage and release pointers to objects. The shared_ptr is defined in the memory header file.
3, the last kind of error situation is very special, using VS2013+OPENCV for human face and human eye recognition, if the confirmation vector is not overrun, also no use of the pointer is not released, but the single-step debugging found in leaving some functions of the function of the report vector subscript out of Range this error or _CRTISVALIDHEAP, it is possible that your VS13 version is linked to the 10 version of the VS OpenCV library. We can see it through the solutiong->properties->configuration properties->vc++ directorys->library Directorys, If the address of the OPENCV's link library contains VC10, then the vs2010 version of the link is linked, and VS12 represents vs2013 and the above version.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.