Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Count the number of pixels in a line

I used the code in the object detection tutorial on the opencv site. After detecting the object a line in drawn to object. I need to know the length of this line in pixels. I used LineIterator to count the length, i says it iterating pixels. I'm new to opencv and want to make sure that i'm doing it right

this is the iterator code:

  LineIterator it = LineIterator(img_matches, scene_corners[0] + offset, scene_corners[1] + offset, 8, false);
  int i;
  for (i = 0; i < it.count; i++, ++it){}
  objectPixels = i;

In the constructor the 4th arg is 4-connected line or 8-connected line what does it mean?