User Tools

Site Tools


built_in:cameraview

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

built_in:cameraview [2015/03/07 16:56]
octazid [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:app|app]] object: 
-<code>cam = app.CreateCameraView( width, height, options );</code> 
-This control allows your program to show a live feed of what is currently being seen by the phone/tablet's camera. If your device has a front facing camera and is at least version 2.3 of Android you can use the **"Front"** option to show the front camera's preview. 
  
-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). 
-<code>cam.StartPreview();</code> 
- 
-Use the **TakePicture** function to take a picture and save it to a given location. 
-<code>cam.TakePicture( filename );</code> 
- 
-Use the **SetPictureSize** function to set the dimensions in pixels of the pictures taken (eg. 1024 x 768). 
-<code>cam.SetPictureSize( width, height );</code> 
- 
-For more sophisticated examples including motion detection and video streaming, check out the **'Camera Stream'**, **'Camera Snap'** and **'Camera Motion'** sample programs in the DroidScript samples section. 
- 
----- 
-===== Methods ===== 
-Some controls use the same methods.\\ 
-For examples of the **[[same methods]]** look here. 
-^Method ^Description ^ 
-|CameraView.AutoCapture( folder, fileName, maxCount ) | | 
-|CameraView.Destroy() | | 
-|CameraView.FindFaces( max )| | 
-|CameraView.Focus() | | 
-|CameraView.GetAbsHeight() | | 
-|CameraView.GetAbsWidth() | | 
-|CameraView.GetCameraCount() | | 
-|CameraView.GetColorEffects()| use in SetOnReady| 
-|CameraView.GetHeight() | | 
-|CameraView.GetImageHeight() | | 
-|CameraView.GetImageWidth() | | 
-|CameraView.GetPictureSizes() | | 
-|CameraView.GetPixelData( format,left,top,width,height ) | | 
-|CameraView.GetPosition() | | 
-|CameraView.GetType() | | 
-|CameraView.GetVisibility() | | 
-|CameraView.GetWidth() | | 
-|CameraView.MotionMosaic( xtiles, ytiles, sensitivity, minPeriod, imageObj ) | | 
-|CameraView.Release() | | 
-|CameraView.ReportColors( list,callback,sampSize,maxRate ) | | 
-|CameraView.SetBackColor( color ) | | 
-|CameraView.SetBackGradient( color1,color2,color3,p4,p5,p6,p7 ) | | 
-|CameraView.SetBackGradientRadial( x,y,r,color1,color2,color3,p7 ) | | 
-|CameraView.SetBackground( imagefile,options ) | | 
-|CameraView.SetColorEffect( effect )| use in SetOnReady| 
-|CameraView.SetFlash( onoff ) |set to true or false| 
-|CameraView.SetFocusMode( mode ) | | 
-|CameraView.SetMargins( left,top,right,bottom ) | | 
-|CameraView.SetOnMotion( callback ) | | 
-|CameraView.SetOnPicture( callback ) | | 
-|CameraView.SetOnReady( callback ) | | 
-|CameraView.SetPadding( left,top,right,bottom  ) | | 
-|CameraView.SetPictureSize( width,height ) |Set size in pixel| 
-|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.StopPreview() | | 
-|CameraView.Stream( ip,p2,quality,fps,p5 ) | | 
-|CameraView.TakePicture( fileName ) | | 
- 
----- 
- 
-====Example - Show camera preview==== 
- 
-<code javascript> 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  cam = app.CreateCameraView( 0.8, 0.4 ); 
-  lay.AddChild( cam ); 
-  setTimeout( "cam.StartPreview()", 1000 ); 
- 
-  app.AddLayout( lay ); 
-} 
-</code> 
- 
-====Example - Take pictures==== 
- 
-<code javascript> 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  cam = app.CreateCameraView( 0.8, 0.4 ); 
-  lay.AddChild( cam ); 
-  cam.SetPictureSize( 1024, 768 ); 
-  setTimeout( "cam.StartPreview()", 1000 ); 
- 
-  btn = app.CreateButton( "Snap", 0.3, -1 ); 
-  btn.SetOnTouch( Snap ); 
-  lay.AddChild( btn ); 
- 
-  app.AddLayout( lay ); 
-} 
- 
-function Snap() 
-{ 
-  cam.TakePicture( "/sdcard/MyPic.jpg" ); 
-  app.ShowPopup("Picture saved"); 
-} 
-</code> 
built_in/cameraview.txt ยท Last modified: 2016/06/24 21:13 (external edit)