Ask Your Question

prince0fpersia's profile - activity

2020-09-20 05:19:48 -0500 received badge  Popular Question (source)
2014-06-29 04:44:37 -0500 asked a question Bad argument(Invalid response array), SVM classifier

Hi Why this error occurs?

2014-06-28 06:45:00 -0500 commented question Why this code gives me this error: "train data must be floating-point matrix"

I meant x=row position and y=column position of a pixel of an image! In past my image was grayscale 8-bit image, and I could read each pixel intensity by that code, but now I've changed my code and my input image is a 32bit image , so i don't know how can I find black pixels in my images!

2014-06-28 03:06:13 -0500 commented question Why this code gives me this error: "train data must be floating-point matrix"

I changed the code but a new problem occurred. In my detection function I got the images intensity values by this code " int pix_val=(int)<uchar>(x,y); "

But now I don't know how can I get the values? I should say my images are binary(black and white) with ".bmp" format. I used that code to know which pixels are black! now, how can I do that?

2014-06-28 01:51:14 -0500 commented question Why this code gives me this error: "train data must be floating-point matrix"

Thank you for reply, But I think the whole of code is relative to problem. Ok I will change it.

2014-06-28 00:36:03 -0500 asked a question Why this code gives me this error: "train data must be floating-point matrix"

How can I correct this program? I want to read 100 binary images, do some process on them, save the results as 40 length arrays, give a label to each picture and finally train them in SVM classification. This is my first experience to use SVM and I don't know how can I correct the problem?

int detection









    } //detection

    //SVM classification (Our fitness function)

    int svm()
            CvSVM SVM;

        for(g1=0; g1<100; g1++)
        for(number=0; number<10; number++)
            Mat img(32, 32, CV_32FC1);
            img=imread(format("/home/chris/bang/bn%04d%d.bmp",g1,number ), CV_LOAD_IMAGE_GRAYSCALE);

        Mat labelsMat(100, 1, CV_32FC1, labels);

        CvSVMParams params;
        params.svm_type    = CvSVM::C_SVC;
        params.kernel_type = CvSVM::RBF;

        SVM.train(img, labelsMat, Mat(), Mat(), params);

        int random=(rand() % 6000);

        Mat image=imread(format("/home/chris/bang/bn%05d",random), CV_LOAD_IMAGE_GRAYSCALE);
        response= SVM.predict(image);

    return response;

2014-06-19 11:33:48 -0500 asked a question How can I read sequnce images, apply my funcs on it and save the results?

I don't know could ask my question true, then I ask with an example. I have a file that has 6000 pictures within. The name of the pics has a prefix and then the number of each image {bn00000, bn00001, bn00002, ...., bn5999}.

How can I write a function with OpenCV to read all of them respectively? In fact I want to read image number one(bn00000), do some works on it and save the results, then load next image and continue as same way.

I did this code:

for(int i=00000; i<05999; i++)
    string s1="/home/chris/6000_dataset/bn";
    string s2=".bmp";
    int numm=i;
    string s=o.str();
    img=imread("s", CV_LOAD_IMAGE_GRAYSCALE);

But I got an ambiguous error! The next problem is that I don't know how can I iterate from 00000 to 05999?

2014-06-14 09:53:03 -0500 received badge  Student (source)
2014-06-14 08:54:17 -0500 asked a question Help about "shadow" and "octant centroid" features in an image!

Hi I've read this article but I can't understand the 2.1 and 2.2 parts about shadow features and octant centroid features. Could anyone help me please? I want to implement this article but I'm confused about this 2 parts!

Thanks a lot in advance![^]

2014-06-13 09:32:13 -0500 asked a question How can I use SVM functions to recognize numbers?

Hi I want to use SVM methods to recognize digit images. I think at first I must write some functions and apply them into some images(training set) and then apply them in rest of my image database(testing set) and finally input both of them to SVM function as training and testing sets respectively.

Am I right? Is this all of the story?

Is there any examples to help me? I don't know how can I use SVM in OpenCV!

2014-06-12 07:38:05 -0500 received badge  Editor (source)
2014-06-12 07:35:43 -0500 asked a question How does work this code?

Hi I can't understand how does work this line of following code:

Mat sampleMat = (Mat_<float>(1,2) << i,j);

what is "Mat_" ? Why (1,2)?

Vec3b green(0,255,0), blue (255,0,0);

for (int i = 0; i < image.rows; ++i)
    for (int j = 0; j < image.cols; ++j)
    Mat sampleMat = (Mat_<float>(1,2) << i,j);
    float response = SVM.predict(sampleMat);

    if (response == 1)<Vec3b>(j, i)  = green;
    if (response == -1)<Vec3b>(j, i)  = blue;

Also why in if-else conditions it uses (j,i) not (i,j) ?

The complete explanation is exist here :

2014-05-09 02:03:12 -0500 received badge  Supporter (source)
2014-05-08 23:22:25 -0500 asked a question How can I read the pixels value in opencv?

I am trying this code to calculate my binary image pixels value by this code :

int main()

Mat img;

img=imread("/home/2b.jpeg", CV_LOAD_IMAGE_UNCHANGED);
namedWindow("win", WINDOW_AUTOSIZE);
imshow("win", img);

for(int i=0; i< img.rows ;i++)
    for(int j=0; j< img.cols ; j++)



    return 0;

But i get 3 types of value: 0, -1 and some big different numbers like (24342234 , 1324244242, etc)

What is the problem? I drew one black line in paint programs and save the image, or download binary image from internet but i get same results!

I thought when i use binary images i must get 0 for white pixels and 255 for black ones.

2012-10-13 11:00:29 -0500 asked a question how do i find corners like L and T with EMGU ?

hi , at first i'm sorry for my bad english

I want to find the corners of the football field And then I can use it to locate the robot in the field I used the HoughLines() functions , but have not answered

Please, if you have a sample code about, put it to me

This is the code I used:

foreach (LineSegment2D l1 in lines)
    foreach (LineSegment2D l2 in lines)
        if (Math.Abs(l1.P2.X) - Math.Abs( l1.P1.X) != 0 &&
            Math.Abs(l2.P2.X )- Math.Abs(l2.P1.X) != 0)

            slope_l1 = Math.Abs(l1.P2.Y - l1.P1.Y) / Math.Abs(l1.P2.X - l1.P1.X);
            slope_l2 = Math.Abs(l2.P2.Y - l2.P1.Y) / Math.Abs(l2.P2.X - l2.P1.X);

            angle_l1 = Math.Atan(slope_l1) *180/  Math.PI;
            angle_l2 = Math.Atan(slope_l2) * 180/ Math.PI;

            if (

                Math.Abs(angle_l2 - angle_l1) > 80 && Math.Abs(angle_l2 - angle_l1) < 110))

               img.Draw(l1, new Bgr(Color.Yellow), 2);


    this.Invoke(new Action(delegate()

        pictureBox1.Image = img.Bitmap;

And If I change the condition to

if(   Math.Abs(angle_l2 - angle_l1) > 80 && Math.Abs(angle_l2 - angle_l1) < 110)
                              && ((l1.P1 == l2.P2)|| (l1.P2==l2.P1)
                              || (l1.P1==l2.P1) ||(l1.P2 == l2.P2) ))

There was no line display