Hi all,
I am trying to use the cv::saliency::ObjectnessBING class to detect object in a frame, but I am not able to do it properly. There is an example of code here but with the BING algorithm, it does not display any result.
This is my code:
String saliency_algorithm = "BING";
String training_path = "../ObjectnessTrainedModel";
vector<Vec4i> saliencyMap;
Ptr<Saliency> saliencyAlgorithm = Saliency::create( saliency_algorithm );
saliencyAlgorithm.dynamicCast<cv::saliency::ObjectnessBING>()->setTrainingPath( training_path );
//saliencyAlgorithm.dynamicCast<cv::saliency::ObjectnessBING>()->setBBResDir( training_path + "/Results" );
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{
std::cout << "Objectness done" << std::endl;
}
std::vector<float> values = saliencyAlgorithm.dynamicCast<cv::saliency::ObjectnessBING>()->getobjectnessValues();
for (int i = 0; i < saliencyMap.size(); ++i)
{
cv::rectangle(image, Point (saliencyMap[i][0],saliencyMap[i][1]), Point(saliencyMap[i][2],saliencyMap[i][3]) , Scalar(255,0,0),1,8, 0);
}
cv::namedWindow( "Saliency Map", WINDOW_AUTOSIZE );// Create a window for display.
cv::imshow( "Saliency Map", image ); // Show our image inside it.
cv::waitKey(0);
So, saliencyMap
is the vector containing all the rectangle, and my vector values
contains the score of each reactangle. How can I use that information for drawing the result? I Tried to draw the rectangle with the highest score but the resutls made no sense. Have I to use some more options? There are more methods to use in the class but I don't understand what they are useful for, also reading the original paper of the algorithm.