I'm currently working on live preview integration for ILCE-6000. I want to post my discoveries here with the hope that eventually we can compile a documentation. Some of these are camera specific, but I don't have other Sony camera to test.
It seems the live preview can only be accessed through the com.sony.scalar.hardware.CameraSequence class. Attempts to use Android's Camera.PreviewCallback class did not work as the callback was never called.
The basic structure to use the API is shown below
// Initializing the preview API
CameraEx camEx = CameraEx.open(0, null);
Camera cam = camEx.getNormalCamera(); // Android camera object
// Link up camera to a surfaceHolder and startPreview as per standard Android API usage
CameraSequence camSeq = CameraSequence.open(camEx);
CameraSequence.Options seqOpts = new CameraSequence.Options();
// Set options for the preview, see below
camSeq.startPreviewSequence(seqOpts);
// Getting frames, preferably done in a separate thread
// Unlike Android API, this is not event driven so timing must be handled separately
// Also note that only direct buffer is supported
ByteBuffer previewBuffer = ByteBuffer.allocateDirect(PREVIEW_JPEG_MAX_SIZE_KB * 1024);
DeviceMemory[] memories = cameraSequence.getPreviewSequenceFrames(1);
DeviceBuffer deviceBuffer = (DeviceBuffer) memories[0];
deviceBuffer.read(previewBuffer, deviceBuffer.getSize(), 0);
deviceBuffer.release();
previewBuffer.limit(size); // DeviceBuffer.read() does not update the destination buffer's position and limit
// previewBuffer now contains a frame
Known working CameraSequence.Options
PREVIEW_FRAME_RATE // 30000 is 30fps
PREVIEW_FRAME_WIDTH // 640 works, have not tested other values
PREVIEW_FRAME_HEIGHT // 480 works, can be set to 0 for 'auto'
PREVIEW_FRAME_FORMAT // 256 works, not sure what the unit is, have not tested other values
PREVIEW_FRAME_MAX_NUM // typically 1
JPEG_COMPRESS_MAX_SIZE // so far I am getting less than 100KB jpeg per frame
JPEG_COMPRESS_RATE_DENOM // I have tried 5 and 15 here, but quality need further analysis
I'm currently working on live preview integration for ILCE-6000. I want to post my discoveries here with the hope that eventually we can compile a documentation. Some of these are camera specific, but I don't have other Sony camera to test.
It seems the live preview can only be accessed through the
com.sony.scalar.hardware.CameraSequence
class. Attempts to use Android'sCamera.PreviewCallback
class did not work as the callback was never called.The basic structure to use the API is shown below
Known working
CameraSequence.Options