extracting geographic coordinates from a smartphone photo - python

I want to extract the geopgraphic coordinates from a smartphone picture. All our photos are georeferenced and that info is embedded in headers somewhere. Is there a matlab or python function that can tell me a pictures geographic coordinates?
I want to write a script which can calculate the distance between the two images, so if I can extract geographic coordinates of the two photos then I will be able to calculate the distance.
thanks

If you want to use MATLAB, there is a function called imfinfo that extracts the exif data from an image file and saves it in a struct. You can find the GPS information in the GPSInfo field. Example:
info = imfinfo('filename.png');
info.GPSInfo
Then, to access the individual Latitude and Longitude values (expressed in degrees, minutes, seconds) you can check the fields GPSLatitude and GPSLongitude:
info.GPSInfo.GPSLatitude
info.GPSInfo.GPSLongitude

I would suggest looking into http://python-pillow.org
The following pillow documentation gives you are starting point to get what you are looking for.
https://pillow.readthedocs.io/en/latest/reference/ExifTags.html#exiftags-module

Are you allowed to use external tool?
Use jpegsnoop or exiftools to extract a txt file. I can't remember the exact commands but you can find it easily. Both tools have executables and code available. Personally, I like jpegsnoop better.
system('jpegsnoop.exe image/path ... output_image.txt);
Read the txt file which contains geo-tags. There might be up to 7 tags, different camera brands use different tags. Among those, will choose geolocation (I cant recall the exact name but it contains longitute and lattitude in the name).
You can do this by a simple while loop:
while (line = readline) ~= EOF
if line.startsWith (geo-tags)
print line %or add to cell array etc.
To my experience, python is not as good as jpegsnoop.
As NaN mentioned, make sure the gps is on when you take the picture from the smart phone.

Related

Python:How can I find the coordinates of a symbol with number inside (technical drawing)

I am writing a python tool to find specific symbols (e.g. a circle/square with a number inside) on a drawing pdf/screenshot.png
I know from another data source the specific number(s) that should be inside the circle/square.
Using opencv matchTemplate I can find symbols and its coordinates.
One way would be to created all possible symbols (so circles/squares with number 1 to 1000) and save them. Then use opencv to find it on the drawing since I know the number to be found, and thus the filled symbol.
I am sure that the is a smart way to do this. Can somebody guide me into the right direction.
Note: pdfminer will not work since I will not be able to distinguish between measurement numbers and the text coming from the symbol, but I could be wrong here.
I am also trying to solve a similar problem in a coding assignment. The input is a n low poly art illustration.
Once you find the location of the UFO's, you need to crop that part and pass it through a classifier to find the number that UFO contains. The classifier is trained on 5000 images.
I am now going to try the matchTemplate method suggested by you to find the co-ordinates of the UFOs.

How to generate images with location on map offline?

I have a pair of coordinates (lat, long).
I need to generate an image of displaying these coordinates on the map.
And then generate such images with other coordinates in the future without the Internet.
Please tell me whether there are solutions that allow you to display coordinates offline?
Upd: is there any opportunity to download maps offline , eg: gps tracker maps or something like that?
thank you
This is not possible while offline. To generate an image of the coordinate location you would most likely be using
os.system("open \"\" https://www.google.nl/maps/place/" + location)
and then generating a image of the location that is popped up. This is impossible to do while offline, I am very sorry.
The question is too broad to give a good answer. However:
There are several companies, such as TeleAtlas and NavTeq, that sell map data. I have no idea what buying the world from them at 1:1M resolution would cost, but I'd guess several thousand USD.
You could download data, or pre-rendered rasters, from Natural Earth. However, they don't have quite the resolution required for good 1:1M maps.
You could download data from OpenStreetMap. The data is free (as in beer, and as in speech), but using it is a major undertaking.
There are companies that offer pre-rendered maps in various formats from OpenStreetMap data. OpenMapTiles is the one I happen to have at the top of my head, but here are others.

extract text and labels from PDF document

I am trying to detect and extract the "labels" and "dimensions" of a 2D technical drawing which is being saved as PDF using python. I came across a python library call "pytesseract" which has optical character recognition capability. I tried the demo on my image but it fails to detect most of the label/dimensions. Please suggest if there is other way to do it. Thank you**.
** Attached is a sample of the 2D technical drawing I try to detect
** what I am trying to achieve is to able to obtain the coordinate of every dimensions (the 160,120,10 4x45 etc) on the image, and extract the, as well.
About 16 months ago we asked ourselves the same question.
If you want to implement it yourself, I'd suggest the following process:
Extract the Canvas from the sheet
Separate the Cuts
Detect the Measure Regions on each Cut
Detect the individual attributes of the Measure Regions to understand where the Measure Start & End. In your particular example that's relatively easy.
Run the detected Measure Labels through OCR
Associate the Labels to the Measures
Verify your results
Alternatively you can also run it through our API and get the results as JSON.
Here's a quick visualization of the result:
Drawing Read (GT stands for General Tolerances)

Astronomic plate solving in Python (Astropy)

I'm looking for several days now how to solve my problem.
I want to calibrate my CCD pictures (FITS files) so that I can generate the FITS headertopics to di astrometry ib them.
I have a number of stars of which I know RA and DEC and I want to use this data to calculate the parameters to calibrate my photo. I found a web page that does excact what I need but the source code is not online:
http://www1.phys.vt.edu/~jhs/SIP/astrometrycalc.html
In AstroPy coordinate and WCS I find all the functions that I need to do my job but they all assume a fully completed FITS header and I do not have one. (the photos come from an SLR camera in RAW format)
My question is whether I overlook a function or someone who can put me on the road to calculate the header parameters so that I can complete it with the necessary data?
Who can deliver me from my suffering.
tnx
It sounds like you want to plate-solve your image and write the coordinate information and possibly other details into the FITS header.
Have you considered using Astrometry.net? There is a python client here.
You will need to convert your image from raw. Astrometry can handle fits, jpg, gif, and png formats. You can then use Astropy to update the fits header with the results from the Astrometry API. Details on how to work with FITS headers can be found here.

Finding out if a path is straight line of has some jagged curves from series of latitude longitude data

I have a list of[ {'latitude' : latitude, 'longitude' : longitude}] data and I am looking for a python based library that I can use to analyse this and tell me the percentage of path that is a pure straight line
Example of such a path is here : http://gyazo.com/e65a4ecf43161bdfd126316f39c4d403
Thanks in advance
Update
I have attached a picture of the route on the map I am looking at. basically , it is the path of running of a person that is around 4 kms long. As seen on the map, the path of this "run" is very much a straight line, and that over 4 kms is impossible in the center of a city (which is where this run has occured), leading to the conclusion that this was done using a transport (underground metro).
The algorithm I want to find is to detect such a finding, that is clearly evident to the naked eye - programmatically

Categories

Resources