First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, joey For training stuck, you may meet the same problem like mine. The problem is caused because opencv_traincascade.exe doesn't get the image width and height correctly or the original image width and height are smaller than training window size. You can add two lines pointed by arrow in the follow code to opencv/appa/traincascade/imagestorage.cpp to solve the problem.

bool CvCascadeImageReader::NegReader::nextImg() { Point _offset = Point(0,0); size_t count = imgFilenames.size(); for( size_t i = 0; i < count; i++ ) { src = imread( imgFilenames[last++], 0 ); if(src.rows<winsize.height ||="" src.cols="" &lt;="" winsize.width)="" &lt;-----------="" continue;="" &lt;-----------="" if(="" src.empty()="" )="" continue;="" ....="" hope="" this="" solution="" will="" help="" you.<="" p="">

click to hide/show revision 2
No.2 Revision

updated Mar 19 '13

berak gravatar image

Hi, joey For training stuck, you may meet the same problem like mine. The problem is caused because opencv_traincascade.exe doesn't get the image width and height correctly or the original image width and height are smaller than training window size. You can add two lines pointed by arrow in the follow code to opencv/appa/traincascade/imagestorage.cpp to solve the problem.

bool CvCascadeImageReader::NegReader::nextImg()
{
    Point _offset = Point(0,0);
    size_t count = imgFilenames.size();
    for( size_t i = 0; i < count; i++ )
    {
        src = imread( imgFilenames[last++], 0 );
        if(src.rows<winsize.height ||="" src.cols="" &lt;="" winsize.width)="" &lt;-----------="" continue;="" &lt;-----------="" if(="" src.empty()="" )="" continue;="" ....="" hope="" this="" solution="" will="" help="" you.<="" p="">
if(src.rows<winSize.height || src.cols < winSize.width)   <-----------
            continue;                                             <-----------
        if( src.empty() )
            continue;
....

Hope this solution will help you.

click to hide/show revision 3
No.3 Revision

Hi, joey joey

For training stuck, you may meet the same problem like mine. mine.

The problem is caused because opencv_traincascade.exe doesn't get the image width and height correctly or the original image width and height are smaller than training window size. size.

You can add two lines pointed by arrow in the follow code to opencv/appa/traincascade/imagestorage.cpp to solve the problem.

bool CvCascadeImageReader::NegReader::nextImg()
{
    Point _offset = Point(0,0);
    size_t count = imgFilenames.size();
    for( size_t i = 0; i < count; i++ )
    {
        src = imread( imgFilenames[last++], 0 );
        if(src.rows<winSize.height || src.cols < winSize.width)   <-----------
            continue;                                             <-----------
        if( src.empty() )
            continue;
....

Hope this solution will help you.