Milestone #2: Data Assembly¶
The second step of this project is to access the Google Street View data and organize it in a suitable format. In my project plan my target was to reach this goal by February 21st (last Wednesday). Although I have accomplished a lot, I have not achieved all of the things I wanted to achieve for this milestone. I expect to hit it by next week at the latest.
Here's what I have achieved.
First, I can download all of the relevant data from Google. This includes all of the panorama image data and meta data. I can also access the panorama ids for the neighboring locations. All of the metadata is stored in a database.
from common import db data = db.dump_database() data.head(1).T
|links||[('4ElQmDQdNK49Kc_Mxjp1Tw', 31.38), ('6pXUO87O...|
Below are the database table column names.
['pano_id', 'road_argb', 'road_description', 'description', 'lat', 'lng', 'pano_date', 'elevation_egm96_m', 'elevation_wgs84_m', 'links', 'link_count', 'download_date', 'job_name', 'metadata_complete', 'tiles_complete']
The download code is written in such a way that the download job can be paused and resumed at a later date. This will be essential later if I hit the Google Street View API download limit of 25,000 requests per day.
The raw image files are stored in an image directory. The filenames contain the panorama id and the heading/pitch of the image. There are 6 images for each panorama id.
!ls -l data/images/test/ | head -6
total 18460 -rw-rw-r-- 1 jim jim 73127 Feb 27 23:32 0G-deBj1AdAD4afV_n-ARQ_000_000.jpg -rw-rw-r-- 1 jim jim 72587 Feb 27 23:32 0G-deBj1AdAD4afV_n-ARQ_000_090.jpg -rw-rw-r-- 1 jim jim 46300 Feb 27 23:32 0G-deBj1AdAD4afV_n-ARQ_000n090.jpg -rw-rw-r-- 1 jim jim 66686 Feb 27 23:32 0G-deBj1AdAD4afV_n-ARQ_090_000.jpg -rw-rw-r-- 1 jim jim 69896 Feb 27 23:32 0G-deBj1AdAD4afV_n-ARQ_180_000.jpg ls: write error: Broken pipe
Here's one of those image files. The heading of this file is 0 degrees, meaning the camera is pointing directly north.
from IPython.display import Image with open('data/images/test/0G-deBj1AdAD4afV_n-ARQ_000_000.jpg', 'rb') as f: img = f.read() Image(img)
Observe the image is 640x640 pixels.
I can also look directly east:
from IPython.display import Image with open('data/images/test/0G-deBj1AdAD4afV_n-ARQ_090_000.jpg', 'rb') as f: img = f.read() Image(img)
Or straight up:
from IPython.display import Image with open('data/images/test/0G-deBj1AdAD4afV_n-ARQ_000_090.jpg', 'rb') as f: img = f.read() Image(img)
And so on. The 6 directions are north, east, south, west, up, and down.
Of course I probably don't want to use these same directions for my project. That's why I wrote code that will assemble these 6 images into any image I want. Observe:
from sequencing import assembler planar = assembler.Planar('test', 2000, 1000, 500, 60) planar.generate('0G-deBj1AdAD4afV_n-ARQ')
My code allows me to change the heading to arbitrary values. Here's that same location turned to the left 60 degrees:
import numpy as np planar.generate('0G-deBj1AdAD4afV_n-ARQ', heading=np.deg2rad(-60))