Ask Your Question

Lupin's profile - activity

2020-07-10 10:10:14 -0600 received badge  Notable Question (source)
2017-04-16 00:14:18 -0600 received badge  Popular Question (source)
2014-03-02 16:18:46 -0600 commented question concatenate contour vector

with knn in OpenCV, the task is done only by push contour vector into a "super vector", which holds the training data to train classifier. I should think of it from beginning.........

2014-03-02 16:15:16 -0600 commented question concatenate contour vector

Thank you very much for your reply.

You are quite right, it is not possible to do it in such a primitive way. As matchShape function seems to focus only on 2 contour-comparision, I decided to implement K-Nearest neighbour matching. The result is much nicer, and most importantly the calculation time is shorter than matchShapes function

Looks like knn will be my choice.

@berak: you are right, I should find out a smarter distance mesurement from beginning

2014-02-28 13:58:59 -0600 asked a question 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

2013-10-27 06:52:25 -0600 commented answer image display with imread not functioning

I found the problem. It is not related to the code, the code is all right. Just my image. The image suppose to be RGB image and in my case it is not. I changed it to several other different ones and it is o.k.

Thanks for your attention

2013-10-26 14:45:30 -0600 received badge  Supporter (source)
2013-10-26 14:45:14 -0600 commented answer image display with imread not functioning

It debugged successfully. Build in was nice. Just that annoying error. What else should I do, please?

p.s: char* imageName =argv[1] was to take the name of the image. What do you mean by pass the second argument? I do not get it clearly, Do you mind please give some more explanation?

2013-10-26 12:57:29 -0600 commented question image display with imread not functioning

I just did that, no thing changed. The same errors happen. Having no clue why... any suggestions, please ? :D

2013-10-26 11:58:42 -0600 asked a question image display with imread not functioning

Hi everybody. I am new to OpenCV, I was following the material here link text Here is my code

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
 #include <iostream>

using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
 char* imageName = argv[1];

 Mat image;

 image = cvLoadImage("D:\\b.png",1);
 if( argc != 2  )
 {
     cout <<  "Could not open or find the image" << std::endl ;


   return -1;
 }

 Mat gray_image;
 cvtColor( image, gray_image, CV_BGR2GRAY );

 imwrite( "D:\\C++\\output.jpg", gray_image);

 namedWindow( imageName, CV_WINDOW_AUTOSIZE );
 namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );

 imshow( imageName, image );
 imshow( "Gray image", gray_image );



 return 0;
}

Everything is working, I open a png image, convert it to gray scale and save it to a jpg image. It functions well, however, this error appear:

Could not open or find the image

RUN FAILED (exit value -1, total time: 1s)

I am using Netbean 7.4 on windows 8.1 64 bit.

Strange is that the image is successfully processed and saved, but not display and the error appears.