Giter VIP home page Giter VIP logo

ios-sdk's Introduction

#VisionIQ iOS SDK

Introduction

IQ Engines provides VisionIQ, an image recognition platform that makes it possible to add visual search to your mobile application. Before diving into the details of how you can integrate the SDK into your iOS application, we give a brief overview of the two engines at the core of VisionIQ: (1) visual search in the cloud, and (2) visual search on mobile devices. You can find more information about VisionIQ on the system overview page.

Vision IQ server : Visual search in the cloud

Visit our developer portal and sign up for an API key. Once you have obtained your API key, you will be able to (1) send images to the VisionIQ cloud for image recognition via the Query API and (2) train the VisionIQ cloud with your own set of images via the Training API. In the iOS SDK search in the cloud is referred to as remote search, as the image processing algorithms are running on VisionIQ's remote servers.

When you send an image to VisionIQ server, it is first analyzed by VisionIQ's computer vision algorithms. The image is matched against IQ Engines' public image dataset, as well as your private image dataset if you have trained the system.

When the computer vision algorithms are not able to recognize your image, then it is sent to VisionIQ's crowdsourcing engine, where a person will manually tag your image. By combining computer vision and crowdsourcing, we are able to provide accurate labels for 100% of images.

Vision IQ mobile : Visual search on mobile devices

The VisionIQ cloud can scale to recognize millions of images. However, if your dataset is small (~100 objects), then the recognition can happen entirely on the mobile device. There is no need for an internet connection as the image isn't sent to the VisionIQ cloud. This makes for a really snappy experience, and quasi-instant results. If you turn on the continuous mode, then frames are continuously grabbed from the camera and matched against the local image dataset, which means that objects can be recognized without the user having to take an action such as pressing a shutter button.

The local dataset is hosted directly on the mobile device. It is not possible at the moment for you to directly generate the image signatures that are necessary for recognition (this "local training" feature is coming soon). To receive the iqedata folder that corresponds to your own set of images, first train VisionIQ server, and then contact us at [email protected].

Contents

The VisionIQ iOS SDK is comprised of:

  • IQEnginesSDK: The VisionIQ SDK. It contains all the necessary functions to include VisionIQ functionality in your app. The two main classes are:
    • The IQE class: it contains all the functions for local and remote image recognition. You will use this class when integrating VisionIQ into your app.
    • The IQEViewController class: it is a UIViewController subclass, and provides an example of a user interface for visual search. It uses the IQE class.
  • ExampleApp: The VisionIQ example application. It provides a good example of how the VisionIQ SDK can be included in a mobile app using the IQEViewController class.

Building the Example App.

Before including the SDK in your existing app, we recommend that you first try building the example app, as this is the best way to get familiar with both the SDK and VisionIQ's capabilities.

Configure the example app by editing the settings defined in the ExampleApp/Example/Config.h file:

  • IQE_APIKEY and IQE_SECRET: your API key and secret obtained after you've signed up for VisionIQ.
  • remote search
    • SEARCH_OBJECT_REMOTE: if set to YES, remote search is enabled.
  • local search
    • SEARCH_OBJECT_LOCAL: if set to YES, local search is enabled if the iqedata folder is present and populated.
    • SEARCH_OBJECT_LOCAL_CONTINUOUS: if set to YES, local continuous search is enabled.
    • SEARCH_BARCODE: detect barcode and QR codes if set to YES.

Note that the example app does not work with the simulator as it is using the AVFoundation framework. However, you can run the example app on your iOS device.

Include the VisionIQ SDK in your own project

Install the VisionIQ SDK

  • Add the IQEnginesSDK folder to your project.

center

  • Add additional frameworks and libraries:
    • AVFoundation.framework
    • CoreLocation.framework
    • CoreMedia.framework
    • CoreVideo.framework
    • QuartzCore.framework
    • libiconv.dylib

center

  • Local search uses the standard c++ library. If the project does not contain c++ source files (.mm or .cpp), link to the standard c++ library by adding -lstdc++ to "Other Linker Flags" in Build Settings, or link with libstdc++.dylib.

center

  • When using local object detection, add the data files to the folder named: iqedata at the root of the project. Be sure to create folder references, not groups when adding this folder.

center center

Configure the VisionIQ SDK

The IQEngines VisionIQ SDK may be configured by setting the following variables in IQEnginesSDK/IQEConfig.h:

  • IQENGINES_LOCAL_LIB: If local search is not used, set to FALSE. IQEnginesSDK/Local/libIQEnginesLocal.a can then be removed from the project.
  • IQE_IMAGE_CAPTURE: Designates if the IQEImageCapture class is used by IQE to provide the image capture functionality. Set to FALSE if a custom image acquisition scheme will be used.

Using the IQEViewController class

The steps to use the IQEViewController class are as follows:

  • Import IQEViewController.h and adopt the IQEViewControllerDelegate protocol in your view controller header:

        #import "IQEViewController.h"
	
        @interface ViewController : UIViewController <IQEViewControllerDelegate>
        {
            
        }

  • Allocate and initialize an IQEViewController object. Set the search type depending on what search is required. Use your IQ Engines API Key and secret if doing remote search:

        IQEViewController* vc = [[IQEViewController alloc] initWithParameters:IQESearchTypeRemoteSearch |
                                                                              IQESearchTypeBarCode
                                                                       apiKey:@""
                                                                    apiSecret:@""];
    
        vc.delegate = self;

  • Present the view controller via presentModalViewController:animated:

        [self presentModalViewController:vc animated:YES];

  • Implement the IQEViewControllerDelegate delegate methods as necessary. Specifically, the iqeViewControllerDidCancel method:

        - (void) iqeViewControllerDidCancel:(IQEViewController*)controller
        {
            controller.delegate = nil;
            [controller dismissModalViewControllerAnimated:YES];
        }

Using the IQE class

The steps to use the IQE class are as follows:

  • Add an IQE class to your view controller and adopt the IQEDelegate protocol:

        #import "IQE.h"
	
        @interface ViewController : UIViewController <IQEDelegate>
        {
            IQE* iqengines;
        }

  • Allocate and initialize an IQE object in the view controller init method. Set the search type depending on what search is required. Use your IQ Engines API Key and secret if doing remote search:

        iqengines = [[IQE alloc] initWithParameters:IQESearchTypeRemoteSearch |
                                                    IQESearchTypeBarCode
                                             apiKey:@""
                                          apiSecret:@""];
	
        iqengines.delegate = self;

  • Set up the camera preview layer in the view controller viewDidLoad method.

        CGRect rect = self.view.layer.bounds;
        iqengines.previewLayer.bounds = rect;
        iqengines.previewLayer.position = CGPointMake(CGRectGetMidX(rect),
        CGRectGetMidY(rect));
	
        [self.view.layer insertSublayer:iqengines.previewLayer atIndex:0];

  • Start and stop camera processing in viewWillAppear: and viewDidDisappear: respectively:

        - (void)viewWillAppear:(BOOL)animated
        {
            [super viewWillAppear:animated];
            
            [iqengines startCamera];
        }

        - (void)viewDidDisappear:(BOOL)animated
        {
            [super viewDidDisappear:animated];

            [iqengines stopCamera];
        }

  • Capture a still image from the camera by calling the captureStillFrame method. Process the image in the didCaptureStillFrame IQEDelegate method:

        - (IBAction)onCameraButton:(id)sender
        {
            [iqengines captureStillFrame];
        }

        - (void)iqEngines:(IQE*)iqe didCaptureStillFrame:(UIImage*)image
        {
            NSString* qid = [iqengines searchWithImage:image];
        }

  • Handle the image search result in the didCompleteSearch IQEDelegate method:

        - (void)iqEngines:(IQE*)iqe didCompleteSearch:(IQESearchType)type
                                          withResults:(NSDictionary*)results
                                               forQID:(NSString*)qid
        {
            NSLog(@"results:%@", results);
        }

  • Implement other IQEDelegate delegate methods as necessary.
  • Clean up by adding the following in dealloc:

        iqengines.delegate = nil;
        [iqengines stopCamera];
        [iqengines release];

Using the IQE class on iOS 3.0 - 3.2

The image capture features are unavailable on iOS versions before 4.0. However, it is still possible to use the IQE class with a UIImage.

  • AVFoundation framework must be weak linked to the project. Change the framework from "Required" to "Optional" in the Link Binary with Libraries section of the target Build Phases.

  • Get an image (with UIImagePickerController or other method) and call searchWithImage: on the IQE instance.


        - (void)imagePickerController:(UIImagePickerController *)picker
        didFinishPickingMediaWithInfo:(NSDictionary *)info
        {    
            UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];

            [iqengines searchWithImage:image];
        }

Questions

ios-sdk's People

Watchers

James Cloos avatar Hiren avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.