Street View pictures in less than 30 lines

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Street View pictures in less than 30 lines

Post by angros47 »

I guess everyone is familiar with the pictures of Google Street View: they are called 360 degrees pictures, or also panoramic pictures, or VR photos. They can be taken using a dedicated 360 camera, or a modern smartphone (it has to include a gyroscope sensor), or also a regular camera and a tripod, using a photo stitcher program like hugin. Nowadays, the easiest way is with a smartphone and the app Street View (that would basically do on the fly the stitching job, combining multiple pictures in one). Picture can be published immediately on Street View, but it is also possible to download it from the phone on PC: the picture is a regular image in jpeg format, just distorted, since it is in equirectangular projection.

Since OpenB3D handles equirectangular projections to apply textures to spheres, it is very easy to build a simple viewer in FreeBasic:

Code: Select all

#include "openb3d.bi"

screenres 800,600, , , &h10002 

	
Graphics3d 800,600,32,1,1

dim as single pitch, yaw
dim as single zoom=1

var camera=createcamera(0)


var sphere=createsphere(20)
'flipmesh sphere
scalemesh sphere,-30,30,30

AmbientLight 255,255,255



entitytexture sphere, loadtexture(command)


do


	if MultiKey(&h48) then pitch+=1
	if MultiKey(&h50) then pitch-=1
	if MultiKey(&h4b) then yaw+=1
	if MultiKey(&h4d) then yaw-=1

	if MultiKey(&h51) then zoom-=.01: CameraZoom camera, zoom
	if MultiKey(&h49) then zoom+=.01: CameraZoom camera, zoom


	RotateEntity camera, pitch, yaw, 0
	
	renderworld
	sleep 1
	flip
loop until MultiKey(1)
You need OpenB3D to compile and use it. Once compiled, use as argument the panorama file you want. Arrow keys turn the view around, PgUp and PgDown set the zoom
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Street View pictures in less than 30 lines

Post by badidea »

It works, I found an example image here: https://www.flickr.com/photos/rueike/8234526270/ (close rotating view and use download button at bottom-right).
See bottom of http://hugin.sourceforge.net/ for more examples.

I would however add

Code: Select all

if command = "" then print "no input" : end
at the start of the program to clarify its use a bit (and not let it crash if empty).
Post Reply