What causes

With many years of experience, spend Gie feel very wrong, decisive let two dogs wait for me for a moment.

Spluttered pa… Two hours later

A code knocking, emergency writing of 20 lines of code, a photo analysis.

public static void main(String[] args) throws JpegProcessingException, IOException { PicAnalysis("C:\\Users\\86157\\Desktop\\123.jpg"); } public static void PicAnalysis(String path) throws JpegProcessingException, IoException {system.out. println(" Powerful language is recognizing the image address..." ); File picFile = new File(path); Metadata metadata = JpegMetadataReader.readMetadata(picFile); Iterator<Directory> it = metadata.getDirectories().iterator(); while (it.hasNext()) { Directory exif = it.next(); Iterator<Tag> tags = exif.getTags().iterator(); while (tags.hasNext()) { Tag tag = tags.next(); System.out.println(tag); }} System.out.println(" The image is finished! ") ); }

The results are as follows:

Location: Qizongtian Hotel, Bund Street, Huangpu District, Shanghai {"city": [], "province": "Shanghai ", "adcode": "310101", "district":" 3101013000 ", "towncode": "3101013000"; {" number ":" 406-1 ", "location" : "121.485570, 31.240797," "direction" : "the northeast", "short" : "2.35113", "street" : "Location ": "121.480979,31.245711", "name": [{"location": "121.480979,31.245711", "name": "Qipu road", "id" : "310106"}, {" location ":" 121.503076, 31.252427, "" name" : "north bund", "id" : "310109"}, {" location ": "121.502898, 31.252714," "name" : "the bridge that promote goal", "id" : "310109"}], "building" : {" name ":" the Shanghai logistics association (road) in jiangxi province ", "type" : "science and education culture and service; Scientific research institutions; Research institutions "}, "neighborhood" : {" name ": []," type ": []}," citycode ":" 021 "}, "formatted_address" : "Info ": "OK", "infocode": "10000"}, "info": "10000"}

This is… , good guy, the result is ok, people are okay, the location is quite regular, this two dogs should not worry about safety issues, can go to drink together.

Real knowledge comes from practice

See here, usually suspicious small partners are not eager to try it, I will break up a few steps.

  • Analysis of images

First, introduce a JAR package

< the dependency > < groupId > com. Drewnoakes < / groupId > < artifactId > metadata - extractor < / artifactId > < version > 2.16.0 < / version > </dependency>

Then write a method to get the detailed information in the picture, including the shooting time, location information, mobile phone model, etc. Do you think the information age is also quite scary, personal privacy leakage at the moment…

Public static Map<String,String> PicAnalysis(String Path) throws JPEGProcessingException, IOException { Map<String,String> map = new HashMap(); System.out.println(" Powerful language is recognizing image addresses...") ); File picFile = new File(path); Metadata metadata = JpegMetadataReader.readMetadata(picFile); Iterator<Directory> it = metadata.getDirectories().iterator(); while (it.hasNext()) { Directory exif = it.next(); Iterator<Tag> tags = exif.getTags().iterator(); while (tags.hasNext()) { Tag tag = tags.next(); map.put(tag.getTagName(),tag.getDescription()); System.out.println(tag.getTagName() + ":" +tag.getDescription()); }} System.out.println(" The image is finished! ") ); return map; }

This method returns the following information, quite a bit, sorted here into a table:

parameter instructions
Make Product Manufacturer
Model Equipment model
Orientation The direction of
X Resolution/Y Resolution X/Y direction resolution
ResolutionUnit Resolution unit
DateTime Date and time
Software Software version
ISO speed ratings iso
Date/Time Original Creation time
Date/Time Digitized Digitization time
Components Configuration Image construction (multi-color combination scheme)
Compressed Bits Per Pixel The degree to which the color bits per pixel are compressed
Exposure Bias Value Exposure compensation
Max Aperture Value The largest aperture
Metering Mode Metering mode, average metering, central key metering, point metering, etc
Flash Whether to use flash
Focal Length Focal length, usually displays the physical focal length of the lens
Makernote Author marks, notes, and records
Color Space Gamut, color space
Exif Image Width Image width, refers to the number of horizontal pixels
Exif Image Height Image height, refers to the number of longitudinal pixels
  • Convert to coordinates

The information taken out from the picture is in degree minute second format: 30° 14′ 32.52″, we need to convert it to latitude and longitude: such as 121.485559,31.240778, the code is as follows:

Public static String translate(String GPS) {String a = GPS.split ("°")[0].replace(" ", ""); String b = Gps. The split (" ° ") [1]. The split (" '") [0]. Replace (" ", ""); String c = Gps. The split (" ° ") [1]. The split (" '") [1]. The replace (" ", ""). The replace (" \" ", ""); double gps = Double.parseDouble(a)+Double.parseDouble(b)/60 + Double.parseDouble(c)/60/60; return String.valueOf(gps); }
  • Revealing the Final Veil

Once you have the exact coordinates, which are only half a step away from success, you call the Amap API to get the exact address.

public static void getAddress( Map<String,String> param){ String str = RequestUtils.sendGet("https://restapi.amap.com/v3/geocode/regeo", "key=5a3c45fd68d04bbc&location="+translate(param.get("GPS Longitude"))+","+translate(param.get("GPS Latitude"))); JSONObject result = JSON.parseObject(str); Println (" Time taken: "+param.get("Date/Time")); Println (" location: "+ result.getJsonObject ("regeocode").getString("formatted_address")); Println (" phone: "+param.get("Make") +" +param.get(" Model")); System.out.println(str); }

However, we need to enter the Amap developer platform first. There is no need to apply for individual developer status. The application steps are relatively simple, and there will be a specified number of free calls every day after the application, enough for personal use.

Lazy people play

If you feel too troublesome, do not want to apply for developers, ah, is to play, is not to apply, that flower Gie also has manual version of the practice.

  • Manually convert latitude and longitude

Can open the web site, http://www.minigps.net/fc.html, will be online degrees minutes format conversion to latitude and longitude.

  • Manual positioning coordinates

Open the pick up coordinate system, input the latitude and longitude obtained in the previous step, you can view the specific address

Git address

Project meeting to git, interested friends can pull down a try, the address is: https://github.com/zsh5775317…

The last

Finally clarify once, 2 dogs up to now single, which have what bad idea, how can have girlfriend again, this story is purely fictitious, if have the same, emmm….. See you later.

Keep your eyes on the ground

The above is the whole content of this issue, if there is a mistake, please comment, thank you very much. I’m Hua Ji, if you have any questions, please feel free to leave a message and discuss. See you at 🦮 next time.

The article is constantly updated, you can search WeChat
Java development zero to oneFirst time to read, and access
Interview materials learning videoAnd so on, interested partners welcome attention, learning together, together ha 🐮.

If you think this article is useful to you, thank brother for liking, commenting or forwarding this article, because this will be the motivation for me to produce more good articles. Thank you!