English 中文(简体)
探测“我们没有图像”角图
原标题:detecting "we have no imagery" of google maps street view static images
最佳回答

this situation is already build in in the 3.0 version due the boolean test status === streetviewStatus.Ok, here is a snippet from my situation solving

if (status === google.maps.StreetViewStatus.OK) {
            var img = document.createElement("IMG");
            img.src =  http://maps.googleapis.com/maps/api/streetview?size=160x205&location= + lat + , + lng  + &sensor=false&key=AIzaSyC_OXsfB8-03ZXcslwOiN9EXSLZgwRy94s ;
            var oldImg = document.getElementById( streetViewImage );
            document.getElementById( streetViewContainerShow ).replaceChild(img, streetViewImage);
        } else {
            var img = document.createElement("IMG");
            img.src =  ../../images/ProfilnoProfilPicture.jpg ;
            img.height = 205;
            img.width = 160;
            var oldImg = document.getElementById( streetViewImage );
            document.getElementById( streetViewContainerShow ).replaceChild(img, streetViewImage);
        }
问题回答

One quick solution would be to load the image file using xmlrpc and check that its md5sum is 30234b543d5438e0a0614bf07f1ebd25, or that its size is 1717 bytes (it s unlikely that another image can have exactly the same size), but that s not very robust since I have seen Google change the position of the text in the image. Though it s a very good start for a prototype.

You could go for image processing instead. Note that it s still not perfectly robust since Google could decide to change the looks of the image anytime. You ll have to decide whether it s worth it.

不管怎么说,我如何利用 j子这样做:

  • load the image and open a 2D context for direct pxiel access (see this question for how to do it)
  • analyse the image:
    • sample groups of 2×2 pixels at random locations; I recommend at least 30 groups
    • a group of 2×2 pixels is good if all the pixels have the same value and their R/G/B values do not differ by more than 10% (ie. they re grey)
    • count the ratio of good pixel groups in the image
  • if there are more than 70% good pixel groups, then we are pretty sure this is the “no imagery” version: replace it with another image of your choice.

我不建议直接测试罗姆学生的价值的原因是,青年促进平等论坛抑制不同浏览器的行为可能略有不同。

到2016年,您可使用新的

现在需要status。 实地了解是否发现了帕那马。

www.un.org/Depts/DGACM/index_spanish.htm Example requests:

{
   "status" : "ZERO_RESULTS"
}

www.un.org/Depts/DGACM/index_spanish.htm

{
   ...
   "status" : "OK"
}

要求有一条眼光的街道观像,如果它有具体的档案规模,那就不是街头观。 我是这样说的:

var url =  google street view url ;

var xhr = new XMLHttpRequest();
xhr.open( GET , url, true);
xhr.responseType =  blob ;

xhr.onload = function (e) {
  if (this.status == 200) {
    try {
      var image = new Blob([this.response], {type:  image/jpeg });

      if (image.size) {
        if (url.indexOf( 640x640 ) > -1 && image.size === 8410) {
          // Not street view
        }

        if (url.indexOf( 400x300 ) > -1 && image.size === 3946) {
           // Not street view
        }
      }
    } catch (err) {
      // IE 9 doesn t support blob
    }
  }
};

xhr.send(); 

另一种办法是装上图像,然后比较一些颜色。 go角的“无街道观”形象总是一样的。 这里,你将如何比较2个图象:

var url = STREETVIEWURL
var img = new Image();
// Add some info to prevent cross origin tainting
img.src = url +  ?  + new Date().getTime();
img.setAttribute( crossOrigin ,   );
img.crossOrigin = "Anonymous";
img.onload = function() {
    var context = document.createElement( CANVAS ).getContext( 2d );
    context.drawImage(img, 0, 0);
    //load 2 pixels.  I chose the first one and the 5th row
    var data1 = context.getImageData(0, 0, 1, 1).data;
    var data2 = context.getImageData(0, 5, 1, 1).data;
    console.log(data1);
    // google unknown image is this pixel color [228,227,223,255]
    if(data1[0]==228 && data1[1]==227 && data1[2]==223 && data1[3]==255 && 
                     data2[0]==228 && data2[1]==227 && data2[2]==223 && data2[3]==255){
        console.log("NO StreetView Available");
    }else{
         console.log("StreetView is Available");
    }
};

Some potential issues: I ve seen some errors with CrossOrigin tainting. Also, if google changes the image returned this code will break.





相关问题
Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView) Everything displays fine The button simply takes a snapshot using the following simple ...

Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Transform rectangular image into trapezoid

In .NET how can I transform an image into a trapezoid. The Matrix class supports rotation, shear, etc, but I can t see a trapezoidal transformation. I m using the usual System.Drawing.* API, but I m ...

Rotate image through Y-axis on web page

What are my options for rotating an image on a web page through the Y-axis? I m not sure if I even have the terminology right. Is this called a rotate or a transform. Most of the searches that I ve ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it s colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it s "...

热门标签