This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
built_in:cameraview [2014/09/17 19:13] stevegarman created |
built_in:cameraview [2016/06/24 21:13] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== CameraView control ====== | ====== CameraView control ====== | ||
- | ===== Create | + | |
- | Create a camera preview control using the CreateCameraView function of the app object: | + | // |
+ | |||
+ | ===== 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/ | + | 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). | + | 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 ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | Some controls use the same methods.\\ |
- | |cam.AutoCapture| | | + | For examples of the **[[same methods]]** look here. |
- | |cam.Focus| | | + | ^ Method |
- | |cam.GetCameraCount| | | + | | CameraView.AutoCapture( folder, fileName, maxCount ) | | |
- | |cam.GetHeight| | | + | | CameraView.Destroy() |
- | |cam.GetImageHeight| | | + | | CameraView.FindFaces( max ) | | |
- | |cam.GetImageWidth| | | + | | CameraView.Focus() | | |
- | |cam.GetPictureSizes| | | + | | CameraView.GetAbsHeight() |
- | |cam.GetVisibility| | | + | | CameraView.GetAbsWidth() |
- | |cam.GetWidth| | | + | | CameraView.GetCameraCount() |
- | |cam.MotionMosaic| | | + | | CameraView.GetColorEffects() |
- | |cam.Release| | | + | | CameraView.GetHeight() | | |
- | |cam.SetBackColor| | | + | | CameraView.GetImageHeight() |
- | |cam.SetBackGradient| | | + | | CameraView.GetImageWidth() | | |
- | |cam.SetBackGradientRadial| | | + | | CameraView.GetMaxZoom() |
- | |cam.SetBackground| | | + | | CameraView.GetParameters() |
- | |cam.SetFlash| | | + | | CameraView.GetPictureSizes() | | |
- | |cam.SetFocusMode| | | + | | CameraView.GetPixelData( format, |
- | |cam.SetMargins| | | + | | CameraView.GetPosition() |
- | |cam.SetOnMotion| | | + | | CameraView.GetType() |
- | |cam.SetOnPicture| | | + | | CameraView.GetVisibility() | | |
- | |cam.SetOnReady| | | + | | CameraView.GetWidth() |
- | |cam.SetPadding| | | + | | CameraView.GetZoom() |
- | |cam.SetPictureSize| | | + | | Cameraview.IsRecording() |
- | |cam.SetPosition| | | + | | CameraView.MotionMosaic( xtiles, ytiles, sensitivity, |
- | |cam.SetPreviewImage| | | + | | CameraView.Record(file, |
- | |cam.SetSize| | | + | | CameraView.Release() | | |
- | |cam.SetSound| | | + | | CameraView.ReportColors( list, |
- | |cam.SetVisibility| | | + | | CameraView.SetBackColor( color ) | | |
- | |cam.StartPreview| | | + | | CameraView.SetBackGradient( color1, |
- | |cam.StopPreview| | | + | | CameraView.SetBackGradientRadial( x, |
- | |cam.Stream| | | + | | CameraView.SetBackground( imagefile, |
- | |cam.TakePicture| | | + | | 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.SetZoom( level ) | | | ||
+ | | CameraView.StartPreview() | ||
+ | | CameraView.Stop() | ||
+ | | CameraView.StopPreview() | | | ||
+ | | CameraView.Stream( ip, | ||
+ | | CameraView.TakePicture( fileName ) | | | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Options ===== | ||
+ | |||
+ | These are the camera resolution options: | ||
+ | |||
+ | * CIF | ||
+ | * QVGA | ||
+ | * SVGA | ||
+ | * VGA | ||
+ | * XGA | ||
+ | * UXGA | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====Example - Show camera preview==== | ||
+ | |||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | cam = app.CreateCameraView( 0.8, 0.4 ); | ||
+ | |||
+ | cam.SetOnReady( cam_OnReady ); | ||
+ | |||
+ | lay.AddChild( cam ); | ||
+ | |||
+ | app.AddLayout( lay ); | ||
+ | } | ||
+ | |||
+ | // Runs after " | ||
+ | function cam_OnReady() { | ||
+ | cam.StartPreview(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ====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( " | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ |