Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

problems with using Haar Cascade

I have problems with using Haar Cascade. I'd like to train каскад to find certain birds(Toucan) on the photos.. Cascade works if I just cut out Toucan with frame and background, but with bird it finds part of the background. If I cut out only the bird with grabcut ( and fill background with white, the program doesn't work even with original(white) images. Tell me please what to do?

problems with using Haar Cascade

I have problems with using Haar Cascade. I'd like to train каскад to find certain birds(Toucan) on the photos.. Cascade works if I just cut out Toucan with frame and background, but with bird it finds part of the background. If I cut out only the bird with grabcut ( and fill background with white, the program doesn't work even with original(white) images. Tell me please what to do?

Added: visualization problems The pictures with a simple background works well (though I must devote toucan fully, not in part) image description

In all complex background it is terribly: image description

Haar cascade is formed from good and bad images. Solving the problem in the background of good pictures, I decided to clean the background. Leaving only a bird, and all colored background cut and flooded white. After that, the search program has ceased to find any birds.

Haar cascade Standard code opencv (opencv_createsamples.exe) Finding birds on the basis of the cascade:

int main() { cv::Mat gray = cv::imread("7.jpg", 1); cv::CascadeClassifier cascadeSymbol; bool cascadeSymbolLoad = cascadeSymbol.load("cascade.xml");

if (!cascadeSymbolLoad)
{
    std::cerr << "Cascade not load. Check your directory \"haarcascade_russian_plate_number_symbol.xml\"" << std::endl;
    return false;
}

std::vector<cv::Rect> symbols;
cascadeSymbol.detectMultiScale(gray, symbols); 
for (auto& p : symbols)
{
    cv::Point symbolBegin = cv::Point(p.x, p.y);
    cv::Point symbolEnd = cv::Point(p.x + p.width, p.y + p.height);

    std::cout << "X: " << p.x << " Y: " << p.y << " Width: " << p.width << " Height: " << p.height << std::endl;
    rectangle(gray, symbolBegin, symbolEnd, cv::Scalar(0, 255, 0), 2);
}

cv::imshow("Test", gray);
cv::waitKey(0);
return 0;

}