# detect object from images

Hi after detecting an object from video using a spefic color, i want to recognize this object from images, so i use compare histogram but it gives me double d = 1.0 for all images ? then i try to use detect feature (ORB,FAST,SIFT) then i count the good matching and retrieve the image who had the biggest length of good_matching but it return me the false image.

for compare hisogram i do like this : i travel all elements image : images

List<Mat> imagesList=new ArrayList<Mat>();
List<Mat> imagesList1=new ArrayList<Mat>();

MatOfInt channels=new MatOfInt(0);
Mat hist=new Mat();
Mat hist1=new Mat();
MatOfInt histSize=new MatOfInt(50);

float hrangesArray[]={0.0f,255.0f};
MatOfFloat ranges=new MatOfFloat(hrangesArray);

double i=  Imgproc.compareHist(hist1, hist, Imgproc.CV_COMP_BHATTACHARYYA);


and for the detecting feature i proced like in the tutorial.

but i don't know where is the problem ? thanks for help me

edit retag close merge delete

2

everything looks reasonable, have you tried to use a different histSize?

( 2013-04-20 13:35:04 -0600 )edit

Sort by » oldest newest most voted

But to answer your questions: I don't know about your histogram, maybe use every bin, i.e. histSize = 255, it depends on your images, how do you actually want to identify an object by taking the histogram of the image? Do you have a rigid object? Then maybe just templateMatching would be easier (however may be too time consuming).

On the other hand, your approach with matching descriptors is valid (if you don't have an object with no structure at all)! However you may need a different validation strategy than what you use currently. Try the cross-check, see e.g. http://answers.opencv.org/question/15/how-to-get-good-matches-from-the-orb-feature/ratio-test, or probably better, the ratio-test, see this post: http://answers.opencv.org/question/4829/how-to-filter-freakbruteforcematcher-result/.

more

@Guanta, ok I'll try it, what you suppose like histSize ? about recognize object have you any idea how to find DIST_LIMIT factor, I want to extract exactly the same picture, but I can not, or you have another solution (efficace condition) to find the base image.

my solution is to compare the descriptors of each image in the database and return the image to the greater length of good matches but it is not efficace !! here the code :

    matcher.match(descriptor2,descriptor1, matches);
int DIST_LIMIT = 80;
List<DMatch> matchesList = matches.toList();
List<DMatch> matches_final= new ArrayList<DMatch>();
for(int i=0; i<matchesList.size(); i++)
if(matchesList .get(i).distance <= DIST_LIMIT){

}
Log.w("good matches", matches_final.size()+"");
return matches_final.size();
}

more

Official site

GitHub

Wiki

Documentation