从原始位置请求Google Street View全景图块 [英] Requesting Google Street View panorama tiles from an origin location

查看:167
本文介绍了从原始位置请求Google Street View全景图块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试请求Google街景图像,以便可以将完整全景图以3D渲染到球体上.

I am trying to request Google Street View images so that I can render the full panorama onto a sphere in 3D.

很遗憾,此API 仅允许请求最高120°FoV的请求.理想情况下,我需要可以投影到该球体上的等矩形图像.

Unfortunately, this API only allows requesting up to 120° FoV. Ideally I need an equirectangular image that I can project onto this sphere.

然后我检查了请求全景图像以获取洞察力时Google Maps发出的请求,发现它发出的请求与此类似:

I then checked what requests Google Maps made when requesting panorama images for insight, and found that it makes requests similar to this:

https://geo0.ggpht.com/cbk?cb_client=maps_sv.tactile&panoid=${panorama_id}&output=tile&x=${tile_x}&y=${tile_y}&zoom=${zoom_level}&nbt&fover=2 其中每个缩放级别将图像分成更多的图块,从而提供更高的分辨率. (在此处进行直观说明)

https://geo0.ggpht.com/cbk?cb_client=maps_sv.tactile&panoid=${panorama_id}&output=tile&x=${tile_x}&y=${tile_y}&zoom=${zoom_level}&nbt&fover=2 where each zoom level splits the image up into more tiles, giving higher resolution. (Explained visually here)

这对我所做的事情来说是完美的-但是我发现它并没有返回我通过

This was perfect for what I was doing -- however I discovered that it did not return a response from every panorama id I got through the Metadata API.

仔细研究一下,我发现Google Maps有时会使用不同的参数向不同的端点发出请求,有些甚至会以完全不同的文件格式返回图像.

Looking into it more, I found that Google Maps sometimes makes requests to different endpoints with different parameters, some even returning images in completely different file formats.

我现在对如何从这里解决这个问题一无所知.我无法嵌入街景Javascript API,因为我需要在一个已经3D的世界中渲染该图片,请使用静态全景图API,因为我无法从中获取完整的全景图.

I've now been left quite unsure as to how to approach this issue from here. I cannot embed the Street View Javascript API, because I need to render this in an already 3D world, and I cannot use the static panorama API as I cannot get a full panoramic image from that.

感谢任何想法,谢谢. :)

Any ideas appreciated, thanks. :)

推荐答案

您可以下载每个图像并将其保存在多维图像数组中.然后,您可以将每个单独的图块绘制到空白位图上. 本文解释了如何下载所有磁贴.

You can download every image and save it in a multidimensional image array. You can then draw each individual tile on to a blank bitmap. This article explains how to download all the tiles.

这是我的c#代码,带有全景图ID,并返回可以以任何图像格式保存的等矩形13312x6656位图:

Here is my c# code that takes a panorama ID and returns a equirectangular 13312x6656 bitmap which can be saved in any image format:

public static Bitmap Panorama(string panoID)
    {
        ServicePointManager.DefaultConnectionLimit = Environment.ProcessorCount * 12;
        Image[,] images = new Image[26, 13];
        Parallel.For(0, 26, x =>
        {
            Parallel.For(0, 13, y =>
            {
                using (WebClient client = new WebClient())
                    images[x, y] = Image.FromStream(new MemoryStream(client.DownloadData(Get.TileURL(panoID, x, y)))); //converts downloaded byte array to image
            });
        });

        Bitmap result = new Bitmap(26 * 512, 13 * 512);
        for (int x = 0; x < 26; x++)
             for (int y = 0; y < 13; y++)
                 using (Graphics g = Graphics.FromImage(result))
                     g.DrawImage(images[x, y], x * 512, y * 512);
        return result;
    }

要获取网址,您还可以使用cbk0.google.com. Get.TileURL:

To get the url you can also use cbk0.google.com. Get.TileURL:

public static string TileURL(string panoID, int x, int y, int zoomLevel = 5)
    {
        return "http://cbk0.google.com/cbk?output=tile&panoid=" + panoID + "&zoom=" + zoomLevel + "&x=" + x + "&y=" + y;
    }

Parallel.For循环只是为了加快速度,可以代替常规的循环.

The Parallel.For loops are just to speed things up and can be substituted for normal for loops.

此方法的唯一问题是它不适用于以CAoSLEFGMVFpcE开头的全景图.我目前正在尝试为此解决问题,如果找到解决方案,则会更新此答案.

The only issue with this method is that it doesn't work with panos that start with CAoSLEFGMVFpcE. I'm currently trying to find a fix for that and will update this answer if I find a solution.

注意:这样做将违反Google的服务条款

这篇关于从原始位置请求Google Street View全景图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆