Besides high-resolution images, Google Street View also provides a depth map for each panorama, containing the distance from the camera to the nearest surface at each pixel. As far as I know, there is no official documentation of the format, but there are some open source projects which contain code showing how to interpret the data. The depth information is stored in a slightly complicated way, probably to save bandwidth. Each pixel in a grid of 512×256 pixels references one of several planes. A plane is given by its normal vector and its distance to the camera. Therefore, in order to calculate the depth at a pixel, one has to determine the intersection point of a ray starting at the center of the camera and the plane corresponding to the pixel.
The geometry of the planes and the map containing the index of the plane at each pixel can be retrieved as Base64-encoded and zlib-compressed data by requesting the following URL:
http://maps.google.com/cbk?output=json&cb_client=maps_sv&v=4&dm=1&pm=1&ph=1&hl=en&panoid=1234
I have written a small JavaScript library that fetches the data, decompresses it and computes a depth map from the planes. Here is an example:
As usual, you can find the code on my github page.
Hi 0xef
Thanks for this highly interesting entry! However, when I try to execute the example script from github, only the textured panorama appears and no depth-panorama is shown below as illustrated above. Did Google make any changes to the API or am I doing something wrong?
Cheers
The example script is still working, at least for me… I have tried it in recent versions of Firefox and Chrome. Did you download all files from the github repository? example.html references the files in ./js and in ../src
Thx for this, so cool!
Question: I’ve seen that you input latitude and longitude to the code, but how do i select the angle of the camera pointing in a given directon?
PanoDepthLoader.load() loads the depth map of the full panorama (360°) at the given point.
Hi Tobias,
I am curious if you can extract the same information for “height”.
I am looking at StreetView data as a way to get elevation data to tell people if there is a risk of flooding with their home.
We had Sandy in New York. You also had some flooding in Germany, I think.
regards,
Arnaud
(from New York City)
Hi,
there is the Google Elevation API that can be used to find the height at a point or on a path. However, you can’t get a height map with this API. This thread in the Ogre Forum has a few more links. Maybe you could use a combination of coarse height data extracted from relief maps of OpenStreetMap with Google’s elevation data as a starting point? NASA also provides some height data.
Nice! I have tried before to extract the depth data but without luck. Would it be possible to generate a normal-map based on the data as well?
I think that’s possible, you just have to compute derivatives of the depth in both directions on the sphere and use that to calculate the normal.
Hi Oxef, why can’t I download the compressed data by the upper URL?
I believe that panoid has to be something valid rather than 1234 on the url
Hi Oxef,
what should I do if I want to extract the depth map other than the example ?
Hi Oxef, How do I get valid panoid?
hi Oxef,
Thanks for your great contribution. I am wondering whether there are some SPI to get the longitude and latitude of each pixel?
thanks
Hi 0xef,
I wonder if one can get the non-paranoma photo and its depth map from the data.
Thank you so much
Hi, on occasion I see a 503 site error when I arrive at your webpage. I thought you may wish to know, cheers