com.metaio.sdk
Class CameraView

java.lang.Object
  extended by SurfaceView
      extended by com.metaio.sdk.CameraView

public final class CameraView
extends SurfaceView

This class implements camera view that is displayed.


Constructor Summary
CameraView(Context context, ImageCaptureComponentBase imageCaptureComponent, int cameraIndex, int width, int height)
          
Method Summary
static ECOLOR_FORMAT convertImageFormat(int imageFormat)
          Convert Android image format value to metaio image format
 void doneWithFrame(int index)
           
 void enablePreviewCallback(boolean enable)
          Enable/disable preview callback for optical tracking
 Camera getCamera()
          Get Camera object
 int getCameraIndex()
          Get currently used camera index.
 int getPreviewHeight()
          Get preview image height
 int getPreviewWidth()
          Get preview image width
 void onAutoFocus(boolean success, Camera camera)
           
 void onError(int error, Camera camera)
           
 void onPause()
           
 void onPictureTaken(byte[] data, Camera camera)
           
 void onPreviewFrame(byte[] frameData, Camera camera)
           
 void onResume()
           
 void openCamera()
          
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CameraView

Create camera view by passing application context, dimensions of the preview image, and specifying if emulator or device is running the application.

Parameters:
context - Application context
imageCaptureComponent - ImageCaptureComponent reference
cameraIndex - Camera index to use (only used on SDK > 8), if the index invalid, the nearest possible index is used
width - Camera preview image width
height - Camera preview image height
Method Detail

openCamera


getPreviewWidth

public int getPreviewWidth()
Get preview image width

Returns:
Preview image width in pixels

getPreviewHeight

public int getPreviewHeight()
Get preview image height

Returns:
Preview image height in pixels

getCamera

public Camera getCamera()
Get Camera object

Returns:
Camera object

getCameraIndex

public int getCameraIndex()
Get currently used camera index.

For SDK < 9, it is always 0

Returns:
Camera index

surfaceCreated

public void surfaceCreated(SurfaceHolder holder)

surfaceChanged

public void surfaceChanged(SurfaceHolder holder,
                           int format,
                           int w,
                           int h)

setFocusMode

public void setFocusMode(int mode)
Set camera focus mode

Parameters:
mode - Focus Mode from IImageCaptureComponent
See Also:
IImageCaptureComponent

stopCamera

public void stopCamera()
Stop camera preview and release the camera object


surfaceDestroyed

public void surfaceDestroyed(SurfaceHolder holder)

release

public void release()
Release all the resources that view is using, this view will become invalid after this call.


convertImageFormat

public static ECOLOR_FORMAT convertImageFormat(int imageFormat)
Convert Android image format value to metaio image format

Parameters:
imageFormat - Android image format
Returns:
metaio SDK's internal image format

resetBuffers

public void resetBuffers()
Create preview callback manager, this must be called inside onSurfaceChanged so that correct preview image resolution us used to allocate buffers


enablePreviewCallback

public void enablePreviewCallback(boolean enable)
Enable/disable preview callback for optical tracking

Parameters:
enable - true to enable, false to disable

onPreviewFrame

public void onPreviewFrame(byte[] frameData,
                           Camera camera)

doneWithFrame

public void doneWithFrame(int index)

setPictureCallback

public void setPictureCallback(IMetaioSDKCallback callback,
                               String filepath,
                               int width,
                               int height)
Set picture callback, effective immediately the callback must resume camera preview. The closest supported picture resolution is used.

Parameters:
callback - Callback to receive notification when picture is ready
filepath - File to write
width - Width of the picture
height - Height of the picture

onAutoFocus

public void onAutoFocus(boolean success,
                        Camera camera)

startTorch

public void startTorch()
Start torch mode if supported by the device

See Also:
stopTorch

stopTorch

public void stopTorch()
Stop torch mode

See Also:
startTorch

onPictureTaken

public void onPictureTaken(byte[] data,
                           Camera camera)

onPause

public void onPause()

onResume

public void onResume()

onError

public void onError(int error,
                    Camera camera)