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:
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.
– danieltakeshi
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
– zampnrs
Seria this code? Edit the question with the link. Or see this
– danieltakeshi
Try to change
CV_32FC1
forCV_32SC1
because of this answer. Your mistake is in this part of the code:clog << "Negative images are being loaded...";
 load_images( neg_dir, full_neg_lst, false );
 sample_neg( full_neg_lst, neg_lst, pos_image_size );
 clog << "...[done]" << endl;
– danieltakeshi
Yes, it is the code of "this code". I will try the changes you suggested, thank you! Anything I comment here again!
– zampnrs
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?
– zampnrs
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?
– danieltakeshi
64 x 64 pixels
– zampnrs
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– danieltakeshi
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
– zampnrs