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)
In all complex background it is terribly:
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;
}
imho, you need to train 2 cascades, one for the left side view, and another for the right side view.
(in your 1st image, that's not "parts", that's false detections)
Thank you very much for your answer! The problem is that the bird can be depicted below, above or in flight. To make each separate stage?
the general problem is that it won't work with too much variation in pose.
you can get arounf the left/right problem by e.g. only training for the left side, and then flipping the image for the right side test, but for above/below you probably need more cascades.
i'm not sure, if cascades are a good idea here in the 1st place (they're more for rigid things)