Reading the GPS data from the image returned by the camera in iOS iphone

后端 未结 9 1268
余生分开走
余生分开走 2020-11-29 21:36

I need to get the GPS coordinates of an image taken with the iOS device\'s camera. I do not care about the Camera Roll images, just the image taken with UIImagePickerControl

相关标签:
9条回答
  • 2020-11-29 22:19

    One possibility is to leaving CoreLocation running when the camera is visible. Record each CCLocation into an array along with the time of the sample. When the photo comes back, find its time, then match the closest CClocation from the array.

    Sounds kludgy but it will work.

    0 讨论(0)
  • 2020-11-29 22:26

    This is tested on iOS 8 and works for videos so it should work similarly for photos with a few tweaks.

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    
        NSURL *videoUrl = (NSURL *)[info objectForKey:UIImagePickerControllerMediaURL];
        NSString *moviePath = [videoUrl path];
    
        if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) ) {
    
            ALAssetsLibrary *assetLibrary = [[ALAssetsLibrary alloc] init];
    
            [assetLibrary assetForURL:[info objectForKey:UIImagePickerControllerReferenceURL] resultBlock:^(ALAsset *asset) {
    
                CLLocation *location = [asset valueForProperty:ALAssetPropertyLocation];
                NSLog(@"Location Meta: %@", location);
    
            } failureBlock:^(NSError *error) {
                NSLog(@"Video Date Error: %@", error);
            }];
    
        }
    
    }
    
    0 讨论(0)
  • 2020-11-29 22:29

    You're not using the image data from the camera in the code you've posted, you've generated a JPEG representation of it, which would essentially discard all the metadata. Use image.CGImage like Caleb suggested.

    Also:

    This is also for a commercial product so I cannot use http://code.google.com/p/iphone-exif/.

    The author quite clearly states that commercial licensing is available.

    0 讨论(0)
提交回复
热议问题