简体   繁体   English

当源类型为UIImagePickerController中的Camera时,获取图像元数据中的位置(一种地理标记)

[英]Get location in metadata of image when source type is Camera in UIImagePickerController ( kind of geotagging )

I am trying to get or capture user location within metadata of image picked by UIImagePickerController having source type set UIImagePickerControllerSourceTypeCamera . 我试图获得或摄取的图像的元数据中获取用户位置UIImagePickerController有源类型设置UIImagePickerControllerSourceTypeCamera

When source type is camera(image clicked by camera), we can get metadata from the info parameter of didFinishPickingMediaWithInfo but it doesn't contain location information. 当源类型为camera(摄像机单击的图像)时,我们可以从didFinishPickingMediaWithInfoinfo参数中获取元数据,但其中不包含位置信息。

If source type is photolibrary (UIImagePickerControllerSourceTypePhotoLibrary) then we can get location in metadata with below code, 如果源类型为图片库photolibrary (UIImagePickerControllerSourceTypePhotoLibrary)则可以使用以下代码获取metadata位置,

 -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{


    NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
    PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
    PHAsset *asset = fetchResult.firstObject;

    NSLog(@"%f,%f",asset.location.coordinate.latitude,asset.location.coordinate.longitude);


[picker dismissViewControllerAnimated:YES completion:nil];

}

Second thing we can also manage location with CLLocationManager , I mean we can capture location in didFinishPickingMediaWithInfo . 第二件事,我们也可以使用CLLocationManager管理位置,这意味着我们可以在didFinishPickingMediaWithInfo捕获位置。 But I just want to know that is it possible to pick location with metadata in didFinishPickingMediaWithInfo when image is picked by camera or source type is camera ? 但是我只想知道,当按摄像机选择图像或源类型为camera时,是否可以使用didFinishPickingMediaWithInfo元数据来选择位置?

Any help will be appreciated. 任何帮助将不胜感激。 Thanks! 谢谢!

我得出的结论是,如果我们使用Camera则无法在元数据中获取位置,因此,如果要在从Camera捕获图像时获取位置,则必须在捕获时使用默认位置服务( CLLocationManager )-I在didFinishPickingMediaWithInfo方法中的平均值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将UIImagePickerController与源类型camera一起使用时,是否必须将捕获的图像保存到Camera Roll? - Must I save the captured image to the Camera Roll when using UIImagePickerController with source type camera? 相机的UIImagePickerController:获取包含位置数据的图像 - UIImagePickerController from camera: Get back image with location data 从 UIImagePickerController 获取图像位置 - Get Image location from UIImagePickerController UIImagePickerController摄像机类型返回黑色图像 - UIImagePickerController camera type returning black image 如何检查UIImagePickerController何时更改相机类型? - How to check when UIImagePickerController changes type of camera? 如何快速从 UIImagePickerController 获取 UIImage 元数据? 像“.location” - How to get UIImage metadata from UIImagePickerController in swift ? like ".location" 从iOS UIImagePickerController获取图像位置 - Get image location from iOS UIImagePickerController 使用源类型摄像头的UIImagePickerController中的控件修剪查找栏 - Control trim seek bar in UIImagePickerController with Source type camera 使用相机作为源类型的标准UIImagePickerController控件上的照片访问 - Photos access on standard UIImagePickerController controls with camera as a source type iOS 7 UIImagePickerController相机无图像 - iOS 7 UIImagePickerController Camera No Image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM