Create iOS application with image recognition in 10 minutes

So, you have an iPhone or an iPad. You heard that image recognition is trending and almost everyone is wondering how to incorporate this technology into their apps? We, at Recognize.im, have a ready solution.

We have ready-to-use code for iOS, which you can download and use straight away as a template for you application. Here are the steps you need to follow:

Prerequisites:
- You need a computer running MacOS.
- You need to have Xcode installed, which you can download for free from the Mac App Store on your Mac.
- You need to have provisioning certificates installed on your computer and the hardware running iOS.

Are you ready?

Let’s start:
1. Go to our GitHub page with sample applications.
2. Download the code with git or zip file.
3. When downloading is finished, go to the iPhone folder.
4. Click testapi.xcodeproj in Finder – Xcode should start and the testapi project should open.

5. Now in the left pane of Xcode, browse the project files. The most important ones are:

MainViewController.h and MainViewController.m – these contain the application logic – how to show the camera, handling the inputs controllers, etc.
MainViewController.xib – holds the definition of user interface for your application (double clicking on this file will open a UI designer editor).
ItraffApi.h and ItraffApi.m – these contain code for communicating with the recognize.im API.

Let’s have a quick look at the last two files, which hold details of how to communicate with our API. There are two methods:

- (id)initWithKey :(NSString *) clientId:(NSString *) apiKey;

To initialize objects of the Itraffapi class you need to pass clientId and apiKey to the initializer. You can find this data on your Account page at Recognize.im:

This sample app takes the client id and API key from the user interface controllers; however, you can handle this as necessary.

(void) send :(UIImage *)jpgImage :(id<NSURLConnectionDataDelegate>) delegate;

This method sends the image (UIImage) to our server. The NSURLConnectionDataDelegate delegate is to inform about the communication (check Apple’s documentation for details). This method creates and sends a request.

6. Change the UI and the main logic of your app.
The code responsible for sending a request to the recognize.im server is called when the image picker returns with an image (ready for recognition). This is done in this method of the MainViewController class:

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo

You can customize the UI and all the other code so that it suits your needs.

7. Plug in your iPhone (where you have your provisioning profiles installed) and press the Run button (upper left corner):

8. The app should be up and running on your iPhone:

9. If you have any questions or concerns contact our support team.

10. Enjoy!

 

Author:
Jakub Jurkiewicz,
Recognize.im Developer

  • Jack

    Where is all the ios documentation?

WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera