0

I am using ORB feature matching algorithm to detect the object . I have followed this Sample . I am able to detect the object which is used as template Mat.

enter image description here

So i have the Rect of the object in the current Frame Mat . How can i make a decision whether object is detected or not ?

If you need to see the algorithm you can check the link above . The code is quite big to post here. But i am posting the final drawing of points below .

        Imgproc.line(rgb, new Point(sceneCorners.get(0, 0)), new Point(sceneCorners.get(1, 0)), new Scalar(0, 255, 0), 4);
        Imgproc.line(rgb, new Point(sceneCorners.get(1, 0)), new Point(sceneCorners.get(2, 0)), new Scalar(0, 255, 0), 4);
        Imgproc.line(rgb, new Point(sceneCorners.get(2, 0)), new Point(sceneCorners.get(3, 0)), new Scalar(0, 255, 0), 4);
        Imgproc.line(rgb, new Point(sceneCorners.get(3, 0)), new Point(sceneCorners.get(0, 0)), new Scalar(0, 255, 0), 4);

i.e what i have is a Rect of the object in the Mat Frame. How can i decide if object was found or not . My question is quite similar to This one.

Diaz diaz
  • 284
  • 1
  • 7
  • 21
  • 1
    Have a look at [this answer](https://stackoverflow.com/questions/42505299/finding-if-two-images-are-similar/42515173#42515173). You can basically check the similarity between the two images. – Rick M. May 30 '18 at 09:26
  • Thx for the link. Too much to grab for me cause i am very new to OpenCV. Can't i make an accurate assumption on basis of Points , inlier and outliers? – Diaz diaz May 30 '18 at 10:01
  • Also do i have to perform all four checks to get accurate result? Although I do not understand check 2 and check 4. In my case i have a single template as png in assets . And i need to detect this from camera frame . Thats it only one template . Which check should i prefer ? – Diaz diaz May 30 '18 at 10:05
  • please post the exact requirement. Do you want to detect only one image or they are of different type? Will the original image and the test image vary in terms of orientation, scale, intensity etc? – janu777 May 30 '18 at 10:09
  • Template image will be a single image lets say (300X300) png it will be same for whole app. It contains an object (lets say a mobile phone) And i need to find this template object in the camera frame . if object not found -> Camera will keep looking for it. If found i need to proceed to next screen . This is the requirement @janu777 – Diaz diaz May 30 '18 at 10:21
  • @Diazdiaz You just need to perform one of the four checks. If the image isn't rotated in the captured image, then I would still suggest using template matching because this seems to be a bit too much work – Rick M. May 30 '18 at 10:44
  • I have tried template matching samples too but they did not work . This is a the only sample i found working in my case. For your suggested code in link i do not understand `homography_mat`. There should be two argument first object from camera frame and second is template mat . What is `homography_mat`? – Diaz diaz May 30 '18 at 11:10
  • Well Bundle of Thx @RickM. . You have been a great help . Will get back if i face any other issues . – Diaz diaz May 30 '18 at 11:54
  • 1
    Glad I could help! – Rick M. May 30 '18 at 12:16

0 Answers0