CameraHardwareStub是Android提供的一个fake camera工具。
其代码主要包含三个部分:init、preview和picture。
1、Init
CameraHardwareStub()()构造函数
|
initDefaultParameters()
|
setParameters(const CameraParameters& params)
|
initHeapLocked()
{
mRawHeap = new MemoryHeapBase(picture_width * 2 * picture_height);
mPreviewHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
mBuffers[i] = new MemoryBase(mPreviewHeap, i * mPreviewFrameSize, mPreviewFrameSize);
mFakeCamera = new FakeCamera(preview_width, preview_height);
}
2、Preview
startPreview()
|
PreviewThread(this)
|
previewThread()
{
mlock
init...
munlock
fakeCamera->getNextFrameAsYuv422(frame);
}
3、Picture
Picture又可以分为autofocus和picture两个部分,autofocus暂时不看,无法实现。
takePicture()
|
beginPictureThread(void *cookie)
|
pictureThread()
{
case CAMERA_MSG_RAW_IMAGE
cam.getNextFrameAsYuv422((uint8_t *)mRawHeap->base());
case CAMERA_MSG_COMPRESSED_IMAGE
memcpy(heap->base(), kCannedJpeg, kCannedJpegSize);
}
4、FakeCamera.cpp中,除了本身的构造函数,只有getNextFrameAsYuv422经常被调用,所以如果从真实摄像头获取一帧数据,应该也可以。
阅读(634) | 评论(0) | 转发(0) |