This shows you the differences between two versions of the page.
built_in:cameraview [2015/07/08 10:28] octazid add new methods |
built_in:cameraview [2016/06/24 21:13] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== CameraView control ====== | ||
- | // | ||
- | |||
- | ===== Description ===== | ||
- | Create a camera preview control using the **CreateCameraView** function of the **[[built_in: | ||
- | < | ||
- | This control allows your program to show a live feed of what is currently being seen by the phone/ | ||
- | |||
- | You will need to call the **StartPreview** function of the CameraView control to start the preview\\ (Note: On some phones it is neccessary to wait at least one second before calling the StartPreview function). | ||
- | < | ||
- | |||
- | Use the **TakePicture** function to take a picture and save it to a given location. | ||
- | < | ||
- | |||
- | Use the **SetPictureSize** function to set the dimensions in pixels of the pictures taken (eg. 1024 x 768). | ||
- | < | ||
- | |||
- | For more sophisticated examples including motion detection and video streaming, check out the **' | ||
- | |||
- | ---- | ||
- | ===== Methods ===== | ||
- | Some controls use the same methods.\\ | ||
- | For examples of the **[[same methods]]** look here. | ||
- | ^ Method | ||
- | | CameraView.AutoCapture( folder, fileName, maxCount ) | ||
- | | CameraView.Destroy() | ||
- | | CameraView.FindFaces( max ) | | | ||
- | | CameraView.Focus() | ||
- | | CameraView.GetAbsHeight() | ||
- | | CameraView.GetAbsWidth() | ||
- | | CameraView.GetCameraCount() | ||
- | | CameraView.GetColorEffects() | ||
- | | CameraView.GetHeight() | ||
- | | CameraView.GetImageHeight() | ||
- | | CameraView.GetImageWidth() | ||
- | | CameraView.GetParameters() | ||
- | | CameraView.GetPictureSizes() | ||
- | | CameraView.GetPixelData( format, | ||
- | | CameraView.GetPosition() | ||
- | | CameraView.GetType() | ||
- | | CameraView.GetVisibility() | ||
- | | CameraView.GetWidth() | ||
- | | Cameraview.IsRecording() | ||
- | | CameraView.MotionMosaic( xtiles, ytiles, sensitivity, | ||
- | | CameraView.Record(file, | ||
- | | CameraView.Release() | ||
- | | CameraView.ReportColors( list, | ||
- | | CameraView.SetBackColor( color ) | ||
- | | CameraView.SetBackGradient( color1, | ||
- | | CameraView.SetBackGradientRadial( x, | ||
- | | CameraView.SetBackground( imagefile, | ||
- | | CameraView.SetColorEffect( effect ) | use in SetOnReady | ||
- | | CameraView.SetDuplicateImage( img1,img2 ) | | | ||
- | | CameraView.SetFlash( onoff ) | set to true or false | | ||
- | | CameraView.SetFocusMode( mode ) | | | ||
- | | CameraView.SetMargins( left, | ||
- | | CameraView.SetOnMotion( callback ) | ||
- | | CameraView.SetOnPicture( callback ) | | | ||
- | | CameraView.SetOnReady( callback ) | | | ||
- | | CameraView.SetPadding( left, | ||
- | | CameraView.SetParameter( name,value ) | | | ||
- | | CameraView.SetPictureSize( width, | ||
- | | CameraView.SetPosition( left, top, width, height ) | ||
- | | CameraView.SetPreviewImage( imageObj ) | ||
- | | CameraView.SetScale( x,y ) | ||
- | | CameraView.SetSize( width, height ) | | | ||
- | | CameraView.SetSound( onoff ) | ||
- | | CameraView.SetVisibility( HideShow ) | ||
- | | CameraView.StartPreview() | ||
- | | CameraView.Stop() | ||
- | | CameraView.StopPreview() | ||
- | | CameraView.Stream( ip, | ||
- | | CameraView.TakePicture( fileName ) | ||
- | |||
- | ---- | ||
- | |||
- | ====Example - Show camera preview==== | ||
- | |||
- | <code javascript> | ||
- | function OnStart() | ||
- | { | ||
- | lay = app.CreateLayout( " | ||
- | |||
- | cam = app.CreateCameraView( 0.8, 0.4 ); | ||
- | lay.AddChild( cam ); | ||
- | setTimeout( " | ||
- | |||
- | app.AddLayout( lay ); | ||
- | } | ||
- | </ | ||
- | |||
- | ====Example - Take pictures==== | ||
- | |||
- | <code javascript> | ||
- | function OnStart() | ||
- | { | ||
- | lay = app.CreateLayout( " | ||
- | |||
- | cam = app.CreateCameraView( 0.8, 0.4 ); | ||
- | lay.AddChild( cam ); | ||
- | cam.SetPictureSize( 1024, 768 ); | ||
- | setTimeout( " | ||
- | |||
- | btn = app.CreateButton( " | ||
- | btn.SetOnTouch( Snap ); | ||
- | lay.AddChild( btn ); | ||
- | |||
- | app.AddLayout( lay ); | ||
- | } | ||
- | |||
- | function Snap() | ||
- | { | ||
- | cam.TakePicture( "/ | ||
- | app.ShowPopup(" | ||
- | } | ||
- | </ | ||
- | |||
- | ====Example - Record Video==== | ||
- | |||
- | <code javascript> | ||
- | |||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | // | ||
- | // | ||
- | app.SetOrientation( " | ||
- | |||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | lay.SetBackground( "/ | ||
- | |||
- | // | ||
- | cam = app.CreateCameraView( 0.6, | ||
- | cam.SetOnReady( cam_OnReady ); | ||
- | cam.SetMargins( 0, | ||
- | lay.AddChild( cam ); | ||
- | |||
- | // | ||
- | layRight = app.CreateLayout( " | ||
- | lay.AddChild( layRight ); | ||
- | |||
- | // | ||
- | btn = app.CreateButton( " | ||
- | btn.SetMargins( 0, | ||
- | btn.SetOnTouch( btn_OnTouch ); | ||
- | layRight.AddChild( btn ); | ||
- | |||
- | // | ||
- | app.AddLayout( lay ); | ||
- | |||
- | // | ||
- | recFolder = "/ | ||
- | app.MakeFolder( recFolder ); | ||
- | } | ||
- | |||
- | // | ||
- | function cam_OnReady() | ||
- | { | ||
- | // | ||
- | cam.SetFocusMode( " | ||
- | cam.StartPreview(); | ||
- | } | ||
- | |||
- | // | ||
- | function btn_OnTouch() | ||
- | { | ||
- | if( cam.IsRecording() ) | ||
- | { | ||
- | // | ||
- | cam.Stop(); | ||
- | btn.SetText( " | ||
- | } | ||
- | else | ||
- | { | ||
- | // | ||
- | cam.Record( recFolder+"/ | ||
- | btn.SetText( " | ||
- | } | ||
- | } | ||
- | |||
- | </ |