1

I have one image stored in my bundle or in the application. Now I want to scan images in camera and want to compare that images with my locally stored image. When image is matched I want to play one video and if user move camera from that particular image to somewhere else then I want to stop that video.

For that I have tried Wikitude sdk for iOS but it is not working properly as it is crashing anytime because of memory issues or some other reasons.

Other things came in mind that Core ML and ARKit but Core ML detect the image's properties like name, type, colors etc and I want to match the image. ARKit will not support all devices and ios and also image matching as per requirement is possible or not that I don't have idea.

If anybody have any idea to achieve this requirement they can share. every help will be appreciated. Thanks:)

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • ARKit definitely seems like the way to go. Yes, limited on devices, however, the iPhone 6S and up can run them. More than not, the majority of people will be iPhone 6S and up. I'd definitely be running ARKit – impression7vx Jan 25 '19 at 05:32
  • What about vuforia ? – Prashant Tukadiya Jan 25 '19 at 05:41
  • @impression7vx : Any link or example related to the requirement based on arkit? – Ketan Parmar Jan 25 '19 at 05:46
  • Like you want that `UIImage` matches with given part when rotating camera or you are searching to compare exact looing two `UIImage`'s? – Sohil R. Memon Jan 25 '19 at 05:53
  • @SohilR.Memon : yes something like exact looking image! – Ketan Parmar Jan 25 '19 at 05:56
  • @Lion I don't think so, this will help or not, but here is nice answer provided by Vlad (https://stackoverflow.com/questions/11342897/how-to-compare-two-uiimage-objects) and proposed by Facebook. – Sohil R. Memon Jan 25 '19 at 05:58
  • Just look up Swift ARKit Image Detection. This is what ARKit is for – impression7vx Jan 25 '19 at 05:59
  • @Lion I think you need to scan the image and check whether the certain object in the frame is similar to the object which you have in the asset. CoreML produce something like a confidence score for how well image A matches image B, where image A and image B are two arbitrary photos. So You can use confidence interval to check the image is correct or not. For Better output You can train your own CoreML model – Ruban4Axis Jan 25 '19 at 06:05
  • @Ruban4Axis `CoreML` need `mlmodel` for comparing but he only has one `UIImage` in Bundle and based on that he wants to compare. – Sohil R. Memon Jan 25 '19 at 06:06
  • @SohilR.Memon He knows what is the image he have in the asset right ? He can put the Labels for each image what is in the asset. Using mlmodel he can detect and check – Ruban4Axis Jan 25 '19 at 06:10

3 Answers3

3

Easiest way is ARKit's imageDetection. You know the limitation of devices it support. But the result it gives is wide and really easy to implement. Here is an example

Next is CoreML, which is the hardest way. You need to understand machine learning even if in brief. Then the tough part - training with your dataset. Biggest drawback is you have single image. I would discard this method.

Finally mid way solution is to use OpenCV. It might be hard but suit your need. You can find different methods of feature matching to find your image in camera feed. example here. You can use objective-c++ to code in c++ for ios.

Alok Subedi
  • 1,601
  • 14
  • 26
2

Your task is image similarity you can do it simply and with more reliable output results using machine learning. Since your task is using camera scanning. Better option is CoreML.You can refer this link by apple for Image Similarity.You can optimize your results by training with your own datasets. Any more clarifications needed comment.

Ruban4Axis
  • 821
  • 6
  • 27
1

Another approach is to use a so-called "siamese network". Which really means that you use a model such as Inception-v3 or MobileNet and both images and you compare their outputs.

However, these models usually give a classification output, i.e. "this is a cat". But if you remove that classification layer from the model, it gives an output that is just a bunch of numbers that describe what sort of things are in the image but in a very abstract sense.

If these numbers for two images are very similar -- if the "distance" between them is very small -- then the two images are very similar too.

So you can take an existing Core ML model, remove the classification layer, run it twice (once on each image), which gives you two sets of numbers, and then compute the distance between these numbers. If this distance is lower than some kind of threshold, then the images are similar enough.

Matthijs Hollemans
  • 7,706
  • 2
  • 16
  • 23