1

I was going through this program which was basically about calculating the convexity defects in an image. I cant seem to clear my confusion about the following-

*vector<vector<Point>> hull( contours.size() );
vector<vector<int> > hullsI(contours.size());
vector<vector<Vec4i>> convdefect(contours.size());*

The link of the above mentioned program is as follows:- Calculating convexityDefects using OpenCV 2.4 in c++

Intuitively i know what vector means in physics terms but can someone explain me in simple concept what does the concept of vectors mean in opencv(specially the point,integer and vec4i) and what is the difference between the above mentioned terms.? Any link or suggestions would be really helpful. Thanks

Community
  • 1
  • 1
  • 1
    A `vector` in this context has nothing to do with physics. A [`std::vector`](http://www.cplusplus.com/reference/vector/vector/) is a sequence container representing a contiguous array that can change in size. This has nothing specifically to do with OpenCV, it is simply a container from the STL. – Cory Kramer Aug 12 '14 at 00:36
  • Googling opencv + any of those terms would lead you straight to http://www.cplusplus.com/reference/vector/vector/ and http://docs.opencv.org/modules/core/doc/basic_structures.html – Bull Aug 12 '14 at 01:20

1 Answers1

3

A vector is a std::vector. The other data structures you have referred to are readily found in the documentation of OpenCV's basic structures.

However I notice that the code you linked to contains a cv::vector. If you look in OpenCV 2.4.9's core.hpp you will find this

#include <vector>
...
namespace cv {
    ...
    using std::vector;
    ...
}

It has made vector appear in the cv namespace; that is, a cv::vector is in fact a std::vector. I think the authors of core.hpp would have done this to avoid internal clutter in their code - for user code to create a cv::vector only serves to create confusion in my opinion, particularly when cv::vector is being used together with std::vector and vector as though they all might be something different -- look at this excerpt from that code:

cv::vector<cv::Vec4i> hierarchy;    
std::vector<std::vector<cv::Point> > contours;
...
vector<cv::vector<cv::Point> >hull( contours.size() );

In fact, from what I have seen of the way header files have been reorganized, I don't think cv::vector will exist in the next major version of OpenCV (3.0.0).

Community
  • 1
  • 1
Bull
  • 11,771
  • 9
  • 42
  • 53