Google Cardboard

384 views
Skip to first unread message

Dave Smart

unread,
Jun 14, 2015, 5:42:21 AM6/14/15
to androi...@googlegroups.com
Hi Guys,

We've started to experiment with Google Cardboard recently and will hopefully have some augmented reality demos very soon.  If you want to join the fun, then order yourself and google cardboard kit from Amazon and join the party!

I've attached a little demo SPK to give you a taster but it's still very much a work in progress :)

Please note, you will need a fairly fast phone which is equivalent to a Galaxy S4 or greater in order to get decent performance.

Also you may need to tweek the line that hides the camera preview: cam = app.CreateCameraView( 0.001, 0.001, "VGA" )  with slightly larger values to make it work on your phone.

Regard
David
Cardboard.spk

sankarshan dudhate

unread,
Jul 13, 2015, 10:02:37 PM7/13/15
to androi...@googlegroups.com
Hi Dave,
will it work with unofficial cardboard kits ?

Dave Smart

unread,
Jul 16, 2015, 4:28:26 AM7/16/15
to androi...@googlegroups.com
Yes, it should work fine.

Alex F

unread,
Aug 10, 2016, 2:28:45 AM8/10/16
to DroidScript
Doesn't work on my device :(
Android 4.4.2

Steve Garman

unread,
Aug 10, 2016, 3:09:25 AM8/10/16
to androi...@googlegroups.com
The cardboard spk doesn't work for me either, though it's hardly a fair test as I don't have a cardboard.

Let's just separate out the bit that creates the duplicate images.

This works for me.


//Called when application is started.
function OnStart()
{  
        app
.SetOrientation( "Landscape" );
         
       
//Create horizontal layout that fills the screen.
        lay
= app.CreateLayout( "Linear", "Horizontal,FillXY,VCenter" );
        lay
.SetBackground( "/res/drawable/pattern_carbon", "repeat" );
 
       
//Create camera view control.
        cam
= app.CreateCameraView( 0.6, 0.8 );        
        cam
.SetOnReady( OnReady );
        cam
.SetMargins( 0, 0, 0.04, 0 );
        lay
.AddChild( cam );  
               
       
//Add main layout to app.
        app
.AddLayout( lay );
       
}



function OnReady()
{
 
var w = cam.GetImageWidth();
       
var h = cam.GetImageHeight();
       
//Create vertical layout on right for other stuff.
        layRight
= app.CreateLayout( "Linear", "Vertical" );
        lay
.AddChild( layRight );

       
//Create image control for previewing pictures.
        img
= app.CreateImage( null, 0.18, 0.22,"fix",w,h );  
        img
.SetBackColor( "#ff000000" );
        layRight
.AddChild( img );      
        img
.SetMargins( 0,0,0,0.05 );

        img2
= app.CreateImage( null, 0.18, 0.22,"fix",w,h );  
        img2
.SetBackColor( "#ff000000" );
        layRight
.AddChild( img2 );  
        cam
.SetDuplicateImage( img,img2 );  
        cam
.StartPreview();
}


Alex F

unread,
Aug 10, 2016, 4:04:28 AM8/10/16
to DroidScript
Thanks works now :)

Alan Hendry

unread,
Jan 18, 2021, 8:31:37 AM1/18/21
to DroidScript
Hi,
Doesn't seem to work for me
DS 2.02, Android 8.1.0 (screen is blank)
Regards, ah

On Wednesday, 10 August 2016 at 09:04:28 UTC+1 Alex F wrote:
Thanks works now :)

Alan Hendry

unread,
Jan 26, 2021, 6:57:28 AM1/26/21
to DroidScript
Hi,
I've got it working (main change was to make camera view 0.01x0.01, which technically shows a tiny view in the top left)
And improved it slightly (now each eye gets images of 50% screen width, text is white and nearer vcenter of image).
Images could do with moving down a bit.
Technically the images will appear a little distorted in a VR Viewer, 
but you'd need a plugin to use the Google VR API to get the distortion mesh for the specific device and apply it.   
(With original Cardboard viewer you need to cut a hole for your camera to see thru).
Regards, ah

Cardboard.spk

Alan Hendry

unread,
May 1, 2021, 12:29:44 PM5/1/21
to DroidScript
Hi,
If I run the cardboard SPK it works, but if I build and install the APK then it doesn't show the camera images at all.
(It doesn't seem to ask for permission to access the camera when installing, so I suspect it's not asking for the permission).
The show camera preview example builds and installs and runs correctly.
Regards, ah

Steve Garman

unread,
May 1, 2021, 12:48:16 PM5/1/21
to DroidScript
It works for me as an APK if I add this line at the beginning
_AddPermissions( "Camera" )

But to be honest I didn't try it without

Steve Garman

unread,
May 1, 2021, 1:58:38 PM5/1/21
to DroidScript
This turns out to be part of a fairly significant problem (unless I'm being very silly) that affect many app.Add methods

app.Create versions that need to request dangerous permissions do so
their app.Add equivalents do not

Steve Garman

unread,
May 1, 2021, 2:40:09 PM5/1/21
to DroidScript
Looking st this in more detail I can see why it got missed

When implementing the app.Add versions, it probably seemed unlikely that there were any visual controls that trigger a dangerous permission
There are vanishingly few of them

So it's much less of a problem than my simplistic text search of DroidScript.js suggested but obviously it does need fixing

Dave

unread,
May 1, 2021, 3:19:52 PM5/1/21
to DroidScript
app.AddCameraView needs to be scanned for I presume Steve :)

Steve Garman

unread,
May 1, 2021, 3:44:37 PM5/1/21
to DroidScript
Yep that'll be the one Dave

Obviously I thought we hadn't had enough drama lately

Reply all
Reply to author
Forward
0 new messages