Ask Your Question

Revision history [back]

OpenCV expects a contour to be a list of points of connected pixels, in which the starting point is the top-most one (with lowest Y coordinate). Then, each point on the list has to be connected with the previous one in a counter-clockwise fashion.

Imagine a circle defined as list of points: the top-most point (lowest Y coordinate) is number one in the list, then follows each point in a counter-clockwise fashion.

Priority goes like this:

Number 1 in list -> top-most point (lowest Y coordinate pixel) Number n in the list -> connected to the n-1 pixel with the following priority:

  1. Lower X coordinate compared to previous point
  2. Higher Y coordinate compared to previous point
  3. Higher X coordinate compared to previous point
  4. Lower Y coordinate compared to previous point

OpenCV expects a contour to be a list of points of connected pixels, in which the starting point is the top-most one (with lowest Y coordinate). Then, each point on the list has to be connected with the previous one in a counter-clockwise fashion.

Imagine a circle defined as list of points: the top-most point (lowest Y coordinate) is number one in the list, then follows each point in a counter-clockwise fashion.

Priority goes like this:

Number 1 in list -> top-most point (lowest Y coordinate pixel) pixel)

Number n in the list -> connected to the n-1 pixel with the following priority:

  1. Lower X coordinate compared to previous point
  2. Higher Y coordinate compared to previous point
  3. Higher X coordinate compared to previous point
  4. Lower Y coordinate compared to previous point