Problem related to access chain code value

asked 2013-06-01 21:30:06 -0500

Nihad gravatar image

I am trying to extract contour from gray label image. My interest is I want to access/show numerical value of chain code. How can I do this? Here is my code segment.

int main(..)
  Mat src_gray;
  //read src_gray;
  Mat canny_output;
  vector<vector<Point> > contours;
  vector<Vec4i> hierarchy;
  int thresh=100; 

  /// Detect edges using canny
  Canny( src_gray, canny_output, thresh, thresh*2, 3 );
  /// Find contours
  findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_CODE, Point(0, 0) );

  ///Want to see chain code of contour here/How to access chain code value?

edit retag flag offensive close merge delete


Didn't know that CV_CHAIN_CODE even exists, since it's not listed in the docu...

Guanta gravatar imageGuanta ( 2013-06-02 14:15:51 -0500 )edit

Thanks. May be I need to use ApproxChain class.

Nihad gravatar imageNihad ( 2013-06-02 19:34:03 -0500 )edit

@Guanta is there any function in current version which can represent contour as chain code?

Nihad gravatar imageNihad ( 2013-06-04 19:35:05 -0500 )edit

I think a chain-code representation doesn't exist or at least I don't know of it. Is it that important? findContours() gives you all the contours as vector of points which you can then process further.

Guanta gravatar imageGuanta ( 2013-06-05 03:08:59 -0500 )edit

Chain code is a kind of boundary descriptor. We can produce it from contour points. No problem if there is no function available. I need to develop code. Cheers!!

Nihad gravatar imageNihad ( 2013-06-05 05:31:15 -0500 )edit

i am also have the same problem to get the chain code,if you have some solution then plaese post it

sujay gravatar imagesujay ( 2014-03-11 08:27:00 -0500 )edit