-
-
Save rajtrivedi2001/29a9060cb69773cd5414 to your computer and use it in GitHub Desktop.
Matlab Google Street View and Direction API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
origin='Madison,Chicago,IL'; | |
destination='N+Michigan+Ave,Chicago,IL'; | |
url1=['https://maps.googleapis.com/maps/api/directions/json?origin=' origin '&destination=' destination '&sensor=false&key= XXXX&departure_time=1343641500&mode=driving']; | |
direction=urlread(url1); | |
d=parse_json(direction); | |
steps=d{1}.routes{1}.legs{1}.steps; | |
[startpoints,endpoints]=cellfun(@parsecoord,steps); | |
for i=1:numel(steps) % For each step, find the midpoint and save the street view image | |
sp=startpoints(i); | |
spLat=sp.lat; | |
spLong=sp.lng; | |
ep=endpoints(i); | |
epLat=ep.lat; | |
epLong=ep.lng; | |
mpLat=(spLat+epLat)/2; | |
mpLong=(spLong+epLong)/2; | |
%directiondegree=azimuth(spLat,spLong,epLat,epLong); % calculate the azimuth,i.e. the direction of car | |
directiondegree=0; | |
roadLat=mpLat; | |
roadLong=mpLong; | |
heading=directiondegree; | |
url=['http://maps.googleapis.com/maps/api/streetview?size=640x640&location=' num2str(roadLat) ',' num2str(roadLong) '&sensor=True&key=XXXX&heading=' num2str(heading)]; | |
filename=[num2str(i) '_test.jpg']; | |
urlwrite(url,filename); | |
%b=imread(filename); | |
%image(b) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please guide me to change this code to use Google Translation API , to translate text using that API during MATLAB?