Skip to content

Add & Remove Images

aumentia edited this page Jan 25, 2015 · 1 revision

The library matches the camera output frames with the images stored in its database. The search process takes few ms, this means it is real time. The processing time depends on the device and on the amount of images you add to the system. Typically you can add around 50 images up to 100 in the most powerful devices. You can both add images from URL or from your local resources. You can also set up your unique Id or let the library do it for you.

To add images you can use these functions:

- (NSInteger) insertImage:(UIImage*)image;
 
- (NSInteger) insertImageFromURL:(NSURL*)imageUrl;
 
- (BOOL) insertImage:(UIImage*)image withId:(NSInteger)uId;
 
- (BOOL) insertImageFromURL:(NSURL*)imageUrl withId:(NSInteger)uId;

You can also delete a single image providing its unique id:

- (BOOL) deleteImage:(NSInteger)uId;

Or delete all the images in the db.

- (BOOL) deleteAllImages;

How to create a “good pool”

A good pool is a group of images that have good features, are different between them and can be easily matched without getting any false positive. In order to assure that you create good pools we provide several functions:

  • setMatchingThreshold: The images added to the system receive a punctuation between 0 and 10 indicating how “rich” is the image (amounf of good features for matching). The more close to 10, easier is to match the image and more difficult is to get a false positive. Setting this param, the user decides the minimum quality of his pool of images.

  • Before adding an image to your pool you can get its punctuation with the getImageScore function.

  • You can also adjust the MinFeatures and MaxFeatures params:

    MinFeatures: Minimum amount of features accepted to insert an image in the system.

    • The higher it is the most feature-rich images will be required to be inserted.
    • This value is related with the threshold: the higher the most restrictive the threshold will be.
    • Default value is 50.

    MaxFeatures: Maximum amount of features accepted to match an image.

    • When an image / frame is going to be matched against the images already inserted in the system, the engine
    • extract the best features and compares them with the ones of the images in the system.
    • The higher it is the most features will be accepted in the matching process.
    • The higher it is the better will be the matching quality but the matching speed will be reduced.
    • Default value is 50.
  • It is recommended to use the motion filter. This filter checks if the device is moving and if so, it does not look for matches avoiding false positive with undefined frames while moving:

- (void)initMotionDetection;
 
- (void)removeMotionDetection;

Detection callbacks

First you need to implement the CaptureSessionManger class callbacks. Remember that those callbacks will provide you the video feed frames, frames that you will send to be analysed by the library.

- (void)processNewCameraFrameRGB:(CVImageBufferRef)cameraFrame
{
    [_myVs processRGBFrame:cameraFrame saveImageToPhotoAlbum:NO ];
}
- (void)processNewCameraFrameYUV:(CVImageBufferRef)cameraFrame
{
    [_myVs processYUVFrame:cameraFrame saveImageToPhotoAlbum:NO];
}

Then the engine will give you back the matching results: -1 if no image is recognised, != -1 if an image has been matched, being that result its unique id.

- (void)imageMatchedResult:(NSInteger)uId
{
    if (uId != -1)
    {
        VSLog(@"Image detected --> %d", uId);
    }
}