Ask Your Question
0

detect object from images

asked 2013-04-16 04:27:33 -0600

Marwen Z gravatar image

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>();
            imagesList.add(object);
            List<Mat> imagesList1=new ArrayList<Mat>();
            imagesList1.add(image);

            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);


            Mat mask=new Mat();
            Imgproc.calcHist(imagesList, channels,mask, hist, histSize, ranges);
            Imgproc.calcHist(imagesList1, channels,mask, hist1, histSize, ranges);


          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 flag offensive close merge delete

Comments

2

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

Guanta gravatar imageGuanta ( 2013-04-20 13:35:04 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-04-20 14:49:57 -0600

Guanta gravatar image

Please, don't answer yourself with not a real answer (since it's actually a comment on my post) - please delete your answer and edit your original post with what you just wrote.

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/.

edit flag offensive delete link more
1

answered 2013-04-20 14:02:35 -0600

Marwen Z gravatar image

updated 2013-04-20 14:03:14 -0600

@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){
           matches_final.add(matches.toList().get(i));

       }
     Log.w("good matches", matches_final.size()+"");
     return matches_final.size();
    }
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-16 04:27:33 -0600

Seen: 878 times

Last updated: Apr 20 '13