Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

concatenate contour vector

Hi

Firstly, I am trying to recognize the shape of an object, compare it with the database and give out the result.

I successfully extract the contour of the test object as well as training database by function

cv::findcontour

As I care only about the outer shape, the contour output is taken as contour[0] for comparision

cv::findContours(input,contour,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE,cv::Point(0,0));

I would like to use cv::matchshape function with Hu moment, but before that, I will combine contour of all database image into on vector like below

std::vector<std::vector<cv::Point> > trainingDatabase;
//trainingDatabase contain all the outer contours of database image

then when making comparision, I only have to do like this

for (int i=0;i<trainingDatabase.size();i++){
double result=cv::matchShapes(contour[0],trainingData[i],CV_CONTOURS_MATCH_I1,0);}

But could you please suggest me how to concatenate all the contour into one single trainingDatabase vector?

Thank you very much

click to hide/show revision 2
retagged

updated 2014-02-28 14:08:23 -0600

berak gravatar image

concatenate contour vector

Hi

Firstly, I am trying to recognize the shape of an object, compare it with the database and give out the result.

I successfully extract the contour of the test object as well as training database by function

cv::findcontour

As I care only about the outer shape, the contour output is taken as contour[0] for comparision

cv::findContours(input,contour,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE,cv::Point(0,0));

I would like to use cv::matchshape function with Hu moment, but before that, I will combine contour of all database image into on vector like below

std::vector<std::vector<cv::Point> > trainingDatabase;
//trainingDatabase contain all the outer contours of database image

then when making comparision, I only have to do like this

for (int i=0;i<trainingDatabase.size();i++){
double result=cv::matchShapes(contour[0],trainingData[i],CV_CONTOURS_MATCH_I1,0);}

But could you please suggest me how to concatenate all the contour into one single trainingDatabase vector?

Thank you very much