gpt4 book ai didi

ios - 从图像Objective c中提取纬度和经度

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:32 28 4
gpt4 key购买 nike

我在从图像(具有地理位置详细信息)获取纬度和经度数据时遇到问题。我已经导入了 EXIF 框架,并使用以下代码来实现:

 NSData *jpegData = [UIImageJPEGRepresentation(image, 0.5) base64String];
EXFJpeg* jpegScanner = [[EXFJpeg alloc] init];
[jpegScanner scanImageData: jpegData];
EXFMetaData* exifData = jpegScanner.exifMetaData;
id latitudeValue = [exifData tagValue:[NSNumber numberWithInt:EXIF_GPSLatitude]];
id longitudeValue = [exifData tagValue:[NSNumber numberWithInt:EXIF_GPSLongitude]];
NSLog(@"Longitude: %@ Longitude: %@", latitudeValue, longitudeValue);

但是它返回纬度和经度的 NULL 值,任何人都可以告诉我我在上面的代码中做错了什么吗?请帮帮我。提前致谢!!

最佳答案

您可以使用 来做到这一点框架。

ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc]init];
[assetsLibrary assetForURL:photoUrl resultBlock:resultBlock failureBlock:nil];
ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset *photoAsset) {
CLLocation *location = [photoAsset valueForProperty:ALAssetPropertyLocation];

NSMutableDictionary *exifDataDict = [[NSMutableDictionary alloc] init];
if (location != nil) {
[exifDataDict setObject:[NSNumber numberWithDouble:location.coordinate.latitude] forKey:@"latitude"];
[exifDataDict setObject:[NSNumber numberWithDouble:location.coordinate.longitude] forKey:@"longitude"];
}
}

关于ios - 从图像Objective c中提取纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18018244/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com