Domanda

I am trying to detect an image of a chocolate wrapper with iPhone/iPad Camera. I already got the image frames from video using avcapture. But i can't figure out how to detect a specific part of the image?

Note:- the specific part i am mentioning is a pink ribbon which will always be the same. can i match the image? if yes how? or should i get bitmap pixel data and match the unique color codes (but they can vary depending on light conditions and angle at which image is taken)?

È stato utile?

Soluzione 2

This Solution is for the scenario where you are trying to detect specific part of the image with a specific colour (This part will be called Reference image). so we are going to match the colour codes of our reference image with the one taken from the camera in real time.

Step 1. Create a media layer which will scan the particular part of the image taken from camera. This will narrow down the search area for colour codes and make the process faster, as there are thousands of colour codes in the image.

Step 2. Get the colour codes from the image we just scanned.Create an array of the colour codes.

Step 3. Now repeat the step 2 for 3 or 4 different light conditions.Because some colour codes change under different types of lights. Match the colour codes array to get the common colour codes.(These will be referred now on as Reference colour codes) These colour codes will be there for most of the cases.

Step 4. Convert the image taken from camera in a pixel buffer.(Basically a collection of pixels). Now convert the pixel buffer into colour codes and compare them with reference colour codes.If all of them or more than 50% are matched. you have potential match.

Note:- i Followed this process and it works like magic. it sounds more complicated than it is and it is enough robust to help you get it working in few hours. In my case the wrapper i was scanning was squeezed and tested under different lights(sun,white CFL lamp, a yellow light from the bulb, and taken from different angles and distances). Still most of the reference colour codes were always there.

Gud luck!

Altri suggerimenti

Try the following two APIs:

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top