welcome to linkAR technical documentation

next previous

Add Images

In order to start image matching the images must be loaded to the matching pool of the ARmatcher.

The images can be loaded from the local resources or from the internet URL link.

We have to load them in the viewDidLoad of the viewController

3.1.- Adding images from local resources


Add images to the matching pool from local resources .

// 1) Add image:
// add pic1.jpeg to the image pool
// n1 is the returned id of the image
// if n1 is -1 then either the image is invalid or it has a low rating (cannot be matched)
NSNumber * n1 = [_cvView addImage:[UIImage imageNamed:@"pic2.jpeg"]];
 
 
// 2) add image with your own id:        
// the following adds the image pic3.jpg to the pool with the id 112
// retVal is true if image successfully added to the pool, false if the image is invalid or it has a low rating (cannot be matched)
BOOL retVal = [_cvView addImage:[UIImage imageNamed:@"pic3.jpeg"] withUniqeID:[NSNumber numberWithInt:112]];
 

3.2.- Adding images from Internet URL link


// Add image from the Internet resource(URL)
// It is possible to load images into the image pull from the Internet by setting a valid URL   		
// n2 is the returned id of the image
// if n2 is -1 then either the image is invalid or it has a low rating (cannot be matched)        
NSNumber * n2 = [_cvView addImageFromUrl:[NSURL 
    URLWithString:@"http://static.panoramio.com/photos/large/70381416.jpg"]];

3.3.- Adding images data drom the .dat file

The image can be converted or received in processed format and loaded into the library. You can do that in linkAR Community.

You have to add the .dat file in build phases → copy bundle resources.

    NSNumber *res = [_cvView addImageFromData:[NSData dataWithContentsOfFile:
      [[NSBundle mainBundle] pathForResource:@"ARLab@pic5jpegdetector_data" ofType:@"dat"]]];
 
    NSLog(@"*** Image named %@, with id %d %@ ***", @"ARLab@pic5jpegdetector_data.data", 
      [res intValue], [res intValue] != -1 ? @"ADDED":@"NOT ADDED");

next previous