Floating point Exception (core dumped) when running trainhog.cpp from Opencv

Asked

Viewed 108 times

0

Hello, I am developing a solution for object detection in an image, using HOG+SVM. So far I have only set up my database of positive and negative samples.

I was using the sample code of Opencv trainghog.cpp, just entered my parameters as below:

const char* keys =
    {
        "{help h|     | show help message}"
        "{pd    |../../amostras/positivas| path of directory contains possitive images}"
        "{nd    |../../amostras/negativas| path of directory contains negative images}"
        "{td    |../../testes| path of directory contains test images}"
        "{tv    |     | test video file name}"
        "{dw    |64| width of the detector}"
        "{dh    |64| height of the detector}"
        "{d     |false| train twice}"
        "{t     |false| test a trained detector}"
        "{v     |true| visualize training steps}"
        "{fn    || file name of trained SVM}"
    };

I have not changed any other line in the code. Positive images are read, when it is the turn of negative images, this appears:

inserir a descrição da imagem aqui

Does anyone know what this mistake could be?

As suggested, here is the link that contains the example code: https://github.com/opencv/opencv/blob/master/samples/cpp/train_HOG.cpp

  • I believe that with code it would help other users understand the problem.

  • The code has about 400 lines and comes together when installing opencv, so I did not post here, it would be very big, but if you find relevant I post

  • Seria this code? Edit the question with the link. Or see this

  • 1

    Try to change CV_32FC1 for CV_32SC1 because of this answer. Your mistake is in this part of the code: clog << "Negative images are being loaded...";&#xA; load_images( neg_dir, full_neg_lst, false );&#xA; sample_neg( full_neg_lst, neg_lst, pos_image_size );&#xA; clog << "...[done]" << endl;

  • Yes, it is the code of "this code". I will try the changes you suggested, thank you! Anything I comment here again!

  • I changed CV_32FC1 to CV_32SC1 as you suggested, but I keep getting the same error. I believe the problem is in the sample_neg function, because I changed the false of load_images to visualize and they were loaded. Any idea?

  • 1

    This error occurs when there is some invalid operation, division by zero, overflow, underflow or inaccurate. I think it is something of the size of the images, what is the resolution of the images in pd and in nd?

  • 64 x 64 pixels

  • 1

    Odd, probably ( full_neg_lst[i].rows - size_y ) or ( full_neg_lst[i].cols - size_x ) is giving zero. Try changing the size of the images, or a test summing 1 in these lines. But if this is happening, I suggest opening a Issue on Github

  • Thanks for the help! Sorry for the delay, over time I forgot about the HOG. I’m going to open an Issue in the same, recent github I went to touch the HOG again and I couldn’t solve this problem

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.