Provides support for the front-facing camera of the Cisco Cius.
The camera API in the Android 2.2 release supports the rear-facing camera only.
To support a front camera in the Cisco Cius implementation, Cisco provides a
Camera class.
You must use the
Camera class to obtain the android.hardware.Camera instance
and then proceed to use the standard Android camera object.
View of the Cius Emulator in Camera Mode
Example Code
For a more in depth look at these methods please refer to the Camera Sample Application included in the add-on.
The example code below will show you the basic way of using the Cisco Camera API.
public class myCameraApplication extends Activity implements SurfaceHolder.Callback
{
// Camera Object
android.hardware.Camera mCamera;
// Determine whether we are in front or back mode
private boolean isFront = false;
... //constructor and other setup code
//Called when the drawing surface is created
public void surfaceCreated(SurfaceHolder holder) {
Log.d(tag,"SURFACE CREATED");
// The Surface has been created, acquire the camera and tell it where to draw.
if(isFront){
mCamera = Camera.open(0);
} else {
mCamera = Camera.open(1);
}
}
}
In addition to importing
com.cisco.hardware.Camera, we need to modify the AndroidManifest.xml so that we use this added library.
Below is what needs to be added to the manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.package.name">
...
<application android:name="myCameraApplication" >
<uses-library android:name="com.cisco.hardware" >
...
</application>
...
</manifest>
Note The rear-facing camera is the default camera.
Android documentation recommends that you release the camera object if your application exits or fails.
If the camera object is released, the Cisco Cius application reverts back to the default rear-facing camera until the Cisco Front Camera API is used again.
The Android 2.2 emulator does not support real camera devices.
The same checkerboard preview image is displayed for both the front and back cameras in the emulator.
Switch between Front and Back Cameras
The same application can use both the front and back camera.
Following is an example code to switch cameras.
Note that the camera object is released and then re-opened.
// Called to switch Cameras
private void switchCameras(){
if(mCamera != null){
Log.d(tag,"Releasing Current Camera");
mCamera.stopPreview();
mCamera.release();
}
mPreviewRunning = false;
if(isFront){
Log.d(tag,"Switching Camera to Back Camera");
mCamera = Camera.open(0); //Open the back camera
isFront = false;
} else {
Log.d(tag,"Switching Camera to Front Camera");
mCamera = Camera.open(1);
isFront = true;
}
try {
Log.d(tag,"Setting Preview Display");
mCamera.setPreviewDisplay(cHolder);
} catch (IOException exception) {
mCamera.release();
mCamera = null;
}
mCamera.startPreview();
mPreviewRunning = true;
}
Cisco Front Facing Camera API Sample Log
The following is a sample of the log generated by the Front Camera API:
D/CAMDEMO ( 241): Releasing Current Camera
D/CAMDEMO ( 241): Switching Camera to Front Camera
D/com.cisco.hardware.FrontCamera( 241): Using Java stub - real devices should not see this message.
D/CameraHardwareStub( 34): initHeapLocked: preview size=320x240
D/CAMDEMO ( 241): Setting Preview Display
D/CAMDEMO ( 241): Releasing Current Camera
D/CAMDEMO ( 241): Switching Camera to Back Camera
D/CameraHardwareStub( 34): initHeapLocked: preview size=320x240
D/CAMDEMO ( 241): Setting Preview Display
Licensee shall be solely responsible for any Product use or application developed using
Cisco's Software Developer Kit that may fall under United States Food and Drug Administration regulation,
or other such similar regulatory jurisdiction, including any and all responsibility for compliance to such regulation
as may be applicable. Licensee acknowledges that Cisco provides the Software Developer Kit as a general purpose development tool
to Licensee.