Hi all,
I am trying to use the [cv::saliency::ObjectnessBING](http://docs.opencv.org/master/db/d63/classcv_1_1saliency_1_1ObjectnessBING.html#ac7baaf45599b3293408c0ebc394a5c35) class to detect object in a frame, but I am not able to do it properly. There is an example of code [here](https://github.com/Itseez/opencv_contrib/blob/master/modules/saliency/samples/computeSaliency.cpp) but with the BING algorithm, it does not display any result.
This is my code:
String saliency_algorithm = "BING";
String training_path = "../ObjectnessTrainedModel";
vector saliencyMap;
Ptr saliencyAlgorithm = Saliency::create( saliency_algorithm );
saliencyAlgorithm.dynamicCast()->setTrainingPath( training_path );
//saliencyAlgorithm.dynamicCast()->setBBResDir( training_path + "/Results" );
if( saliencyAlgorithm->computeSaliency( image, saliencyMap ) )
{
std::cout << "Objectness done" << std::endl;
}
std::vector values = saliencyAlgorithm.dynamicCast()->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](https://www.robots.ox.ac.uk/~vgg/rg/papers/14cvprObjectnessBING.pdf) of the algorithm.
↧