尝试使用java提取地理标记的图像数据

时间:2016-12-28 06:48:30

标签: java android geotagging

您好我尝试使用java提取geotagged图像数据。但它没有按预期工作。我在下面添加了我的代码。

try {

        File file = new File("/home/xxx/Downloads/accidentImage");

        for (File filelist : file.listFiles()) {

        Metadata metadata = ImageMetadataReader.readMetadata(filelist);
        ExifSubIFDDirectory directory
                    = metadata.getDirectory(ExifSubIFDDirectory.class);
            Date date
                    = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL);
            GpsDirectory gpsDirectory = metadata.getDirectory(GpsDirectory.class);
            GeoLocation geoLocation = gpsDirectory.getGeoLocation();
            double lat = geoLocation.getLatitude();
            double lon = geoLocation.getLongitude();

        }

    } catch (Exception e) {
        e.printStackTrace();
    }

0 个答案:

没有答案