|
|
|
@ -28,6 +28,16 @@
|
|
|
|
|
#include <LogThread.h>
|
|
|
|
|
#include "DngCreator.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
void Auto_AImage_delete(AImage* image)
|
|
|
|
|
{
|
|
|
|
|
AImage_delete(image);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
#define Auto_AImage_delete AImage_delete
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void onAvailabilityCallback(void* context, const char* cameraId)
|
|
|
|
|
{
|
|
|
|
|
((NdkCamera*)context)->onAvailabilityCallback(cameraId);
|
|
|
|
@ -100,6 +110,48 @@ void onCaptureCompleted(void* context, ACameraCaptureSession* session, ACaptureR
|
|
|
|
|
((NdkCamera*)context)->onCaptureCompleted(session, request, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline uint8_t GetCaptureIntent(ACameraDevice_request_template templateId)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_CUSTOM = 0,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW = 1,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE = 2,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_VIDEO_RECORD = 3,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT = 4,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG = 5,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_MANUAL = 6,
|
|
|
|
|
ACAMERA_CONTROL_CAPTURE_INTENT_MOTION_TRACKING = 7,
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
uint8_t captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
|
|
|
|
switch (templateId)
|
|
|
|
|
{
|
|
|
|
|
case TEMPLATE_PREVIEW: // = 1,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW;
|
|
|
|
|
break;
|
|
|
|
|
case TEMPLATE_STILL_CAPTURE: // = 2,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
|
|
|
|
break;
|
|
|
|
|
case TEMPLATE_RECORD: // = 3,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
|
|
|
|
|
break;
|
|
|
|
|
case TEMPLATE_VIDEO_SNAPSHOT: // = 4,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT;
|
|
|
|
|
break;
|
|
|
|
|
case TEMPLATE_ZERO_SHUTTER_LAG: // = 5,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG;
|
|
|
|
|
break;
|
|
|
|
|
case TEMPLATE_MANUAL: // = 6,
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_MANUAL;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
captureIntent = ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return captureIntent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARAMS& params)
|
|
|
|
|
{
|
|
|
|
|
camera_facing = 0;
|
|
|
|
@ -118,6 +170,7 @@ NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARA
|
|
|
|
|
awbMode = ACAMERA_CONTROL_AWB_MODE_AUTO;
|
|
|
|
|
aeLockAvailable = false;
|
|
|
|
|
awbLockAvailable = false;
|
|
|
|
|
m_fatalError = false;
|
|
|
|
|
|
|
|
|
|
sceneModeSupported = false;
|
|
|
|
|
|
|
|
|
@ -138,10 +191,17 @@ NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARA
|
|
|
|
|
mPreviewImageReader = NULL;
|
|
|
|
|
mPreviewImageWindow = NULL;
|
|
|
|
|
mPreviewOutputTarget = NULL;
|
|
|
|
|
mPreviewSessionOutput = NULL;
|
|
|
|
|
|
|
|
|
|
mImageReader = NULL;
|
|
|
|
|
mImageWindow = NULL;
|
|
|
|
|
mOutputTarget = NULL;
|
|
|
|
|
mSessionOutput = NULL;
|
|
|
|
|
|
|
|
|
|
mImageReader2 = NULL;
|
|
|
|
|
mImageWindow2 = NULL;
|
|
|
|
|
mOutputTarget2 = NULL;
|
|
|
|
|
mSessionOutput2 = NULL;
|
|
|
|
|
|
|
|
|
|
camera_device = 0;
|
|
|
|
|
|
|
|
|
@ -152,6 +212,13 @@ NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARA
|
|
|
|
|
|
|
|
|
|
mResult = { 0 };
|
|
|
|
|
mLdr = ~0;
|
|
|
|
|
mFinalLdr = 0;
|
|
|
|
|
mFinalBurstCaptures = m_params.burstRawCapture == 0 ? 1 : m_params.burstCaptures;
|
|
|
|
|
if (mFinalBurstCaptures == 0)
|
|
|
|
|
{
|
|
|
|
|
mFinalBurstCaptures = 1;
|
|
|
|
|
}
|
|
|
|
|
mFinalOutputFormat = (m_params.burstRawCapture == 0) ? AIMAGE_FORMAT_YUV_420_888 : AIMAGE_FORMAT_RAW16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NdkCamera::~NdkCamera()
|
|
|
|
@ -223,6 +290,8 @@ int NdkCamera::selfTest(const std::string& cameraId, int32_t& maxResolutionX, in
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ACameraMetadata_free(camera_metadata);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -239,6 +308,8 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
DisplayDimension disp(mWidth, mHeight);
|
|
|
|
|
DisplayDimension foundRes = disp;
|
|
|
|
|
camera_status_t status = ACAMERA_OK;
|
|
|
|
|
int32_t previewWidth = 0;
|
|
|
|
|
int32_t previewHeight = 0;
|
|
|
|
|
|
|
|
|
|
ALOGD("Start ACameraManager_getCameraIdList");
|
|
|
|
|
{
|
|
|
|
@ -296,13 +367,40 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
if (input) continue;
|
|
|
|
|
int32_t format = e.data.i32[i + 0];
|
|
|
|
|
|
|
|
|
|
if (format == AIMAGE_FORMAT_YUV_420_888/* || format == AIMAGE_FORMAT_JPEG*/)
|
|
|
|
|
if (format == AIMAGE_FORMAT_RAW16)
|
|
|
|
|
{
|
|
|
|
|
if (mFinalOutputFormat == AIMAGE_FORMAT_RAW16)
|
|
|
|
|
{
|
|
|
|
|
DisplayDimension res(e.data.i32[i + 1], e.data.i32[i + 2]);
|
|
|
|
|
// XYLOG(XYLOG_SEVERITY_DEBUG, "CameraId=%s CX=%d CY=%d", cameraId.c_str(), res.width(), res.height());
|
|
|
|
|
if (!disp.IsSameRatio(res))
|
|
|
|
|
{
|
|
|
|
|
if (res.width() >= mWidth && res.height() >= mHeight)
|
|
|
|
|
{
|
|
|
|
|
temp = res;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (res > disp)
|
|
|
|
|
{
|
|
|
|
|
foundIt = true;
|
|
|
|
|
foundRes = res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (format == AIMAGE_FORMAT_YUV_420_888/* || format == AIMAGE_FORMAT_JPEG*/)
|
|
|
|
|
{
|
|
|
|
|
if (previewWidth == 0 || previewHeight == 0)
|
|
|
|
|
{
|
|
|
|
|
previewWidth = e.data.i32[i + 1];
|
|
|
|
|
previewHeight = e.data.i32[i + 2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mFinalOutputFormat == AIMAGE_FORMAT_YUV_420_888)
|
|
|
|
|
{
|
|
|
|
|
DisplayDimension res(e.data.i32[i + 1], e.data.i32[i + 2]);
|
|
|
|
|
// XYLOG(XYLOG_SEVERITY_DEBUG, "CameraId=%s CX=%d CY=%d", cameraId.c_str(), res.width(), res.height());
|
|
|
|
|
if (!disp.IsSameRatio(res))
|
|
|
|
|
{
|
|
|
|
|
if (res.width() >= mWidth && res.height() >= mHeight)
|
|
|
|
|
{
|
|
|
|
|
temp = res;
|
|
|
|
@ -317,6 +415,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!foundIt)
|
|
|
|
|
{
|
|
|
|
@ -556,6 +655,10 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
status = ACameraManager_openCamera(camera_manager, cameraId.c_str(), &camera_device_state_callbacks, &camera_device);
|
|
|
|
|
if (status != ACAMERA_OK)
|
|
|
|
|
{
|
|
|
|
|
if (status == ACAMERA_ERROR_MAX_CAMERA_IN_USE)
|
|
|
|
|
{
|
|
|
|
|
m_fatalError = true;
|
|
|
|
|
}
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to open camera %s res=%d", cameraId.c_str(), status);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
@ -572,7 +675,8 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setup imagereader and its surface
|
|
|
|
|
media_status_t mstatus = AImageReader_new(foundRes.org_width(), foundRes.org_height(), AIMAGE_FORMAT_YUV_420_888, 5, &mPreviewImageReader);
|
|
|
|
|
media_status_t mstatus = AImageReader_new(previewWidth, previewHeight, AIMAGE_FORMAT_YUV_420_888, 4, &mPreviewImageReader);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call AImageReader_new preview, status=%d", status);
|
|
|
|
|
if (mstatus == AMEDIA_OK)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_ImageListener listener;
|
|
|
|
@ -587,7 +691,8 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
status = ACaptureSessionOutput_create(mPreviewImageWindow, &mPreviewSessionOutput);
|
|
|
|
|
status = ACaptureSessionOutputContainer_add(capture_session_output_container, mPreviewSessionOutput);
|
|
|
|
|
|
|
|
|
|
mstatus = AImageReader_new(foundRes.org_width(), foundRes.org_height(), getOutputFormat(), burstCaptures + 2, &mImageReader);
|
|
|
|
|
mstatus = AImageReader_new(foundRes.org_width(), foundRes.org_height(), getOutputFormat(), burstCaptures + 1, &mImageReader);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call AImageReader_new, status=%d", status);
|
|
|
|
|
if (mstatus == AMEDIA_OK)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_ImageListener listener;
|
|
|
|
@ -598,11 +703,33 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
ANativeWindow_acquire(mImageWindow);
|
|
|
|
|
}
|
|
|
|
|
status = ACameraOutputTarget_create(mImageWindow, &mOutputTarget);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACameraOutputTarget_create, status=%d", status);
|
|
|
|
|
|
|
|
|
|
status = ACaptureSessionOutput_create(mImageWindow, &mSessionOutput);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACaptureSessionOutput_create, status=%d", status);
|
|
|
|
|
|
|
|
|
|
status = ACaptureSessionOutputContainer_add(capture_session_output_container, mSessionOutput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_params.burstRawCapture == 1) // Auto
|
|
|
|
|
{
|
|
|
|
|
mstatus = AImageReader_new(foundRes.org_width(), foundRes.org_height(), AIMAGE_FORMAT_YUV_420_888, burstCaptures, &mImageReader2);
|
|
|
|
|
if (mstatus == AMEDIA_OK)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_ImageListener listener;
|
|
|
|
|
listener.context = this;
|
|
|
|
|
listener.onImageAvailable = ::onImageAvailable;
|
|
|
|
|
mstatus = AImageReader_setImageListener(mImageReader2, &listener);
|
|
|
|
|
mstatus = AImageReader_getWindow(mImageReader2, &mImageWindow2);
|
|
|
|
|
ANativeWindow_acquire(mImageWindow2);
|
|
|
|
|
}
|
|
|
|
|
status = ACameraOutputTarget_create(mImageWindow2, &mOutputTarget2);
|
|
|
|
|
|
|
|
|
|
status = ACaptureSessionOutput_create(mImageWindow2, &mSessionOutput2);
|
|
|
|
|
status = ACaptureSessionOutputContainer_add(capture_session_output_container, mSessionOutput2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CaptureRequest *request = CreateRequest(true);
|
|
|
|
|
mCaptureRequests.push_back(request);
|
|
|
|
|
#if 0
|
|
|
|
@ -627,7 +754,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
uint8_t ctrlMode = ACAMERA_CONTROL_MODE_AUTO;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(request->request, ACAMERA_CONTROL_MODE, 1, &ctrlMode);
|
|
|
|
|
|
|
|
|
|
uint8_t captureIntent = isPreviewRequest ? ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW : ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
|
|
|
|
uint8_t captureIntent = isPreviewRequest ? ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW : GetCaptureIntent(ACameraDevice_request_template)m_params.requestTemplate);
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(request->request, ACAMERA_CONTROL_CAPTURE_INTENT, 1, &captureIntent);
|
|
|
|
|
|
|
|
|
|
uint8_t flashMode = ACAMERA_FLASH_MODE_OFF;
|
|
|
|
@ -808,6 +935,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
camera_capture_session_state_callbacks.onReady = ::onSessionReady;
|
|
|
|
|
camera_capture_session_state_callbacks.onClosed = onSessionClosed;
|
|
|
|
|
status = ACameraDevice_createCaptureSession(camera_device, capture_session_output_container, &camera_capture_session_state_callbacks, &capture_session);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACameraDevice_createCaptureSession, status=%d", status);
|
|
|
|
|
|
|
|
|
|
ACameraCaptureSession_captureCallbacks capture_session_capture_callbacks;
|
|
|
|
|
capture_session_capture_callbacks.context = this;
|
|
|
|
@ -820,7 +948,7 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
capture_session_capture_callbacks.onCaptureBufferLost = 0;
|
|
|
|
|
|
|
|
|
|
status = ACameraCaptureSession_setRepeatingRequest(capture_session, &capture_session_capture_callbacks, 1, &(mCaptureRequests[PREVIEW_REQUEST_IDX]->request), &(mCaptureRequests[PREVIEW_REQUEST_IDX]->sessionSequenceId));
|
|
|
|
|
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACameraCaptureSession_setRepeatingRequest, status=%d", status);
|
|
|
|
|
ALOGW("Preview Request: seqId=%d", mCaptureRequests[PREVIEW_REQUEST_IDX]->sessionSequenceId);
|
|
|
|
|
|
|
|
|
|
m_startTime = GetMicroTimeStamp();
|
|
|
|
@ -837,24 +965,26 @@ NdkCamera::CaptureRequest* NdkCamera::CreateRequest(bool isPreviewRequest)
|
|
|
|
|
CaptureRequest *request = new CaptureRequest();
|
|
|
|
|
std::memset(request, 0, sizeof(CaptureRequest));
|
|
|
|
|
|
|
|
|
|
bool autoSwitchToOneFrame = (m_params.burstRawCapture == 1) && (mFinalOutputFormat == AIMAGE_FORMAT_YUV_420_888);
|
|
|
|
|
request->pThis = this;
|
|
|
|
|
request->imageReader = isPreviewRequest ? mPreviewImageReader : mImageReader;
|
|
|
|
|
request->imageWindow = isPreviewRequest ? mPreviewImageWindow : mImageWindow;
|
|
|
|
|
request->imageTarget = isPreviewRequest ? mPreviewOutputTarget : mOutputTarget;
|
|
|
|
|
request->sessionOutput = isPreviewRequest ? mPreviewSessionOutput : mSessionOutput;
|
|
|
|
|
request->imageReader = isPreviewRequest ? mPreviewImageReader : (autoSwitchToOneFrame ? mImageReader2 : mImageReader);
|
|
|
|
|
request->imageWindow = isPreviewRequest ? mPreviewImageWindow : (autoSwitchToOneFrame ? mImageWindow2 : mImageWindow);
|
|
|
|
|
request->imageTarget = isPreviewRequest ? mPreviewOutputTarget : (autoSwitchToOneFrame ? mOutputTarget2 : mOutputTarget);
|
|
|
|
|
request->sessionOutput = isPreviewRequest ? mPreviewSessionOutput : (autoSwitchToOneFrame ? mSessionOutput2 : mSessionOutput);
|
|
|
|
|
request->templateId = isPreviewRequest ? TEMPLATE_PREVIEW : (ACameraDevice_request_template)m_params.requestTemplate;
|
|
|
|
|
|
|
|
|
|
// mCaptureRequests.push_back(request);
|
|
|
|
|
|
|
|
|
|
// capture request
|
|
|
|
|
status = ACameraDevice_createCaptureRequest(camera_device, request->templateId, &request->request);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACameraDevice_createCaptureRequest, status=%d", status);
|
|
|
|
|
ACaptureRequest_setUserContext(request->request, request);
|
|
|
|
|
|
|
|
|
|
// uint8_t ctrlMode = sceneModeSupported ? ACAMERA_CONTROL_MODE_USE_SCENE_MODE : ACAMERA_CONTROL_MODE_AUTO;
|
|
|
|
|
uint8_t ctrlMode = ACAMERA_CONTROL_MODE_AUTO;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(request->request, ACAMERA_CONTROL_MODE, 1, &ctrlMode);
|
|
|
|
|
|
|
|
|
|
uint8_t captureIntent = isPreviewRequest ? ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW : ACAMERA_CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
|
|
|
|
|
uint8_t captureIntent = isPreviewRequest ? ACAMERA_CONTROL_CAPTURE_INTENT_PREVIEW : GetCaptureIntent((ACameraDevice_request_template)m_params.requestTemplate);
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(request->request, ACAMERA_CONTROL_CAPTURE_INTENT, 1, &captureIntent);
|
|
|
|
|
|
|
|
|
|
uint8_t flashMode = ACAMERA_FLASH_MODE_OFF;
|
|
|
|
@ -1022,6 +1152,7 @@ NdkCamera::CaptureRequest* NdkCamera::CreateRequest(bool isPreviewRequest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status = ACaptureRequest_addTarget(request->request, request->imageTarget);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACaptureRequest_addTarget, status=%d", status);
|
|
|
|
|
|
|
|
|
|
// status = ACaptureSessionOutput_create(request->imageWindow, &request->sessionOutput);
|
|
|
|
|
// status = ACaptureSessionOutputContainer_add(capture_session_output_container, request->sessionOutput);
|
|
|
|
@ -1034,6 +1165,21 @@ void NdkCamera::close()
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::try close %s", mCameraId.c_str());
|
|
|
|
|
camera_status_t res = ACAMERA_OK;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (mPreviewImageReader != NULL)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_setImageListener(mPreviewImageReader, NULL);
|
|
|
|
|
}
|
|
|
|
|
if (mImageReader != NULL)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_setImageListener(mImageReader, NULL);
|
|
|
|
|
}
|
|
|
|
|
if (mImageReader2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_setImageListener(mImageReader2, NULL);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
mCaptureFrames.clear();
|
|
|
|
|
|
|
|
|
|
if ((ACameraManager *)camera_manager != NULL)
|
|
|
|
@ -1085,7 +1231,7 @@ void NdkCamera::close()
|
|
|
|
|
|
|
|
|
|
if (mPreviewImageReader != NULL)
|
|
|
|
|
{
|
|
|
|
|
// AImageReader_setImageListener(image_reader, NULL);
|
|
|
|
|
AImageReader_setImageListener(mPreviewImageReader, NULL);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
|
AImageReader_delete(mPreviewImageReader);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::End AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
@ -1107,7 +1253,7 @@ void NdkCamera::close()
|
|
|
|
|
|
|
|
|
|
if (mImageReader != NULL)
|
|
|
|
|
{
|
|
|
|
|
// AImageReader_setImageListener(image_reader, NULL);
|
|
|
|
|
AImageReader_setImageListener(mImageReader, NULL);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
|
AImageReader_delete(mImageReader);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::End AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
@ -1115,6 +1261,28 @@ void NdkCamera::close()
|
|
|
|
|
mImageReader = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mOutputTarget2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
ACameraOutputTarget_free(mOutputTarget2);
|
|
|
|
|
mOutputTarget2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mImageWindow2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
ANativeWindow_release(mImageWindow2);
|
|
|
|
|
mImageWindow2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mImageReader2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
AImageReader_setImageListener(mImageReader2, NULL);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
|
AImageReader_delete(mImageReader2);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "CameraStatus::End AImageReader_delete %s", mCameraId.c_str());
|
|
|
|
|
|
|
|
|
|
mImageReader2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mPreviewSessionOutput != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (capture_session_output_container)
|
|
|
|
@ -1134,6 +1302,15 @@ void NdkCamera::close()
|
|
|
|
|
ACaptureSessionOutput_free(mSessionOutput);
|
|
|
|
|
mSessionOutput = 0;
|
|
|
|
|
}
|
|
|
|
|
if (mSessionOutput2 != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (capture_session_output_container)
|
|
|
|
|
{
|
|
|
|
|
ACaptureSessionOutputContainer_remove(capture_session_output_container, mSessionOutput2);
|
|
|
|
|
}
|
|
|
|
|
ACaptureSessionOutput_free(mSessionOutput2);
|
|
|
|
|
mSessionOutput2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (capture_session_output_container)
|
|
|
|
|
{
|
|
|
|
@ -1165,12 +1342,12 @@ void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
// https://stackoverflow.com/questions/67063562
|
|
|
|
|
if (mstatus != AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "AImageReader_acquireLatestImage error: %d", mstatus);
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Preview AImageReader_acquireLatestImage error: %d", mstatus);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mLdr == ~0)
|
|
|
|
|
if (!mCaptureTriggered)
|
|
|
|
|
{
|
|
|
|
|
uint8_t* y_data = 0;
|
|
|
|
|
int y_len = 0;
|
|
|
|
@ -1182,13 +1359,140 @@ void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
uint64_t avgY = std::accumulate(y_data, y_data + y_len, 0);
|
|
|
|
|
#endif
|
|
|
|
|
avgY = avgY / (uint64_t)y_len;
|
|
|
|
|
mLdr = avgY;
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
mLdr = (uint8_t)avgY;
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AImage_delete(image);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
uint32_t burstCaptures = getBurstCaptures();
|
|
|
|
|
if (burstCaptures == 0)
|
|
|
|
|
{
|
|
|
|
|
burstCaptures = 1;
|
|
|
|
|
}
|
|
|
|
|
if (burstCaptures == 1)
|
|
|
|
|
{
|
|
|
|
|
mstatus = AImageReader_acquireNextImage(reader, &image);
|
|
|
|
|
if (mstatus != AMEDIA_OK)
|
|
|
|
|
{
|
|
|
|
|
// https://stackoverflow.com/questions/67063562
|
|
|
|
|
if (mstatus != AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE)
|
|
|
|
|
{
|
|
|
|
|
if (mCaptureFrames.size() < burstCaptures)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Capture AImageReader_acquireNextImage error: %d", mstatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long long ts = GetMicroTimeStamp();
|
|
|
|
|
|
|
|
|
|
int32_t format;
|
|
|
|
|
mstatus = AImage_getFormat(image, &format);
|
|
|
|
|
|
|
|
|
|
if (format == AIMAGE_FORMAT_YUV_420_888)
|
|
|
|
|
{
|
|
|
|
|
int32_t width;
|
|
|
|
|
int32_t height;
|
|
|
|
|
mstatus = AImage_getWidth(image, &width);
|
|
|
|
|
mstatus = AImage_getHeight(image, &height);
|
|
|
|
|
|
|
|
|
|
int32_t y_pixelStride = 0;
|
|
|
|
|
int32_t u_pixelStride = 0;
|
|
|
|
|
int32_t v_pixelStride = 0;
|
|
|
|
|
AImage_getPlanePixelStride(image, 0, &y_pixelStride);
|
|
|
|
|
AImage_getPlanePixelStride(image, 1, &u_pixelStride);
|
|
|
|
|
AImage_getPlanePixelStride(image, 2, &v_pixelStride);
|
|
|
|
|
|
|
|
|
|
int32_t y_rowStride = 0;
|
|
|
|
|
int32_t u_rowStride = 0;
|
|
|
|
|
int32_t v_rowStride = 0;
|
|
|
|
|
AImage_getPlaneRowStride(image, 0, &y_rowStride);
|
|
|
|
|
AImage_getPlaneRowStride(image, 1, &u_rowStride);
|
|
|
|
|
AImage_getPlaneRowStride(image, 2, &v_rowStride);
|
|
|
|
|
|
|
|
|
|
uint8_t* y_data = 0;
|
|
|
|
|
uint8_t* u_data = 0;
|
|
|
|
|
uint8_t* v_data = 0;
|
|
|
|
|
int y_len = 0;
|
|
|
|
|
int u_len = 0;
|
|
|
|
|
int v_len = 0;
|
|
|
|
|
AImage_getPlaneData(image, 0, &y_data, &y_len);
|
|
|
|
|
AImage_getPlaneData(image, 1, &u_data, &u_len);
|
|
|
|
|
AImage_getPlaneData(image, 2, &v_data, &v_len);
|
|
|
|
|
|
|
|
|
|
if (u_data == v_data + 1 && v_data == y_data + width * height && y_pixelStride == 1 && u_pixelStride == 2 && v_pixelStride == 2 && y_rowStride == width && u_rowStride == width && v_rowStride == width)
|
|
|
|
|
{
|
|
|
|
|
// already nv21
|
|
|
|
|
ConvertYUV21ToMat(y_data, width, height, mWidth, mHeight, camera_orientation,
|
|
|
|
|
camera_facing == ACAMERA_LENS_FACING_FRONT, m_params.orientation, mOneFrame);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// construct nv21
|
|
|
|
|
uint8_t* nv21 = new uint8_t[width * height + width * height / 2];
|
|
|
|
|
{
|
|
|
|
|
// Y
|
|
|
|
|
uint8_t* yptr = nv21;
|
|
|
|
|
for (int y = 0; y < height; y++)
|
|
|
|
|
{
|
|
|
|
|
const uint8_t* y_data_ptr = y_data + y_rowStride * y;
|
|
|
|
|
for (int x = 0; x < width; x++)
|
|
|
|
|
{
|
|
|
|
|
yptr[0] = y_data_ptr[0];
|
|
|
|
|
yptr++;
|
|
|
|
|
y_data_ptr += y_pixelStride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UV
|
|
|
|
|
uint8_t* uvptr = nv21 + width * height;
|
|
|
|
|
for (int y = 0; y < height / 2; y++)
|
|
|
|
|
{
|
|
|
|
|
const uint8_t* v_data_ptr = v_data + v_rowStride * y;
|
|
|
|
|
const uint8_t* u_data_ptr = u_data + u_rowStride * y;
|
|
|
|
|
for (int x = 0; x < width / 2; x++)
|
|
|
|
|
{
|
|
|
|
|
uvptr[0] = v_data_ptr[0];
|
|
|
|
|
uvptr[1] = u_data_ptr[0];
|
|
|
|
|
uvptr += 2;
|
|
|
|
|
v_data_ptr += v_pixelStride;
|
|
|
|
|
u_data_ptr += u_pixelStride;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConvertYUV21ToMat(nv21, width, height,mWidth, mHeight, camera_orientation,
|
|
|
|
|
camera_facing == ACAMERA_LENS_FACING_FRONT, m_params.orientation, mOneFrame);
|
|
|
|
|
|
|
|
|
|
delete[] nv21;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_photoTaken = true;
|
|
|
|
|
|
|
|
|
|
AImage_delete(image);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ACameraMetadata> result;
|
|
|
|
|
bool captureCompleted = false;
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
if (!mCaptureResults.empty())
|
|
|
|
|
{
|
|
|
|
|
captureCompleted = true;
|
|
|
|
|
result = mCaptureResults[0];
|
|
|
|
|
}
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
if (captureCompleted)
|
|
|
|
|
{
|
|
|
|
|
onOneCapture(mCharacteristics, result, mFinalLdr, ts - m_startTime, mOneFrame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
@ -1198,7 +1502,7 @@ void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
// https://stackoverflow.com/questions/67063562
|
|
|
|
|
if (mstatus != AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE)
|
|
|
|
|
{
|
|
|
|
|
if (mCaptureFrames.size() < m_params.burstCaptures)
|
|
|
|
|
if (mCaptureFrames.size() < burstCaptures)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "AImageReader_acquireNextImage error: %d", mstatus);
|
|
|
|
|
}
|
|
|
|
@ -1208,7 +1512,7 @@ void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
|
|
|
|
|
m_photoTaken = true;
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
mCaptureFrames.push_back(std::shared_ptr<AImage>(image, AImage_delete));
|
|
|
|
|
mCaptureFrames.push_back(std::shared_ptr<AImage>(image, Auto_AImage_delete));
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
ALOGD("Capture Image Received");
|
|
|
|
@ -1222,8 +1526,10 @@ void NdkCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
|
|
|
|
|
|
if (captureCompleted)
|
|
|
|
|
{
|
|
|
|
|
onBurstCapture(mCharacteristics, mCaptureResults, mLdr, mCaptureFrames);
|
|
|
|
|
FireBurstCapture();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1240,7 +1546,17 @@ bool NdkCamera::on_image(cv::Mat& rgb)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NdkCamera::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, std::vector<std::shared_ptr<AImage> >& frames)
|
|
|
|
|
bool NdkCamera::onOneCapture(std::shared_ptr<ACameraMetadata> characteristics, std::shared_ptr<ACameraMetadata> result, uint32_t ldr, uint32_t duration, cv::Mat rgb)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NdkCamera::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, uint32_t duration, std::vector<std::vector<uint8_t> >& frames)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NdkCamera::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristics, std::vector<std::shared_ptr<ACameraMetadata> >& results, uint32_t ldr, uint32_t duration, std::vector<std::shared_ptr<AImage> >& frames)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -1449,6 +1765,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_START;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(request, ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER, 1, &aePrecatureTrigger);
|
|
|
|
|
//XYLOG(XYLOG_SEVERITY_DEBUG, "Trigger PRECAPTURE status=%d AES=%u", (int)status, (unsigned int)mResult.aeState);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call PRECAPTURE_TRIGGER, status=%d", status);
|
|
|
|
|
|
|
|
|
|
readyForCapture = false;
|
|
|
|
|
numberOfPrecaptures = 0;
|
|
|
|
@ -1522,8 +1839,23 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
|
|
|
|
|
if (readyForCapture/* && mCaptureRequests.size() > 1*/)
|
|
|
|
|
{
|
|
|
|
|
ALOGW("Ready for Capture AFS=%u AES=%u AWBS=%u Time=%u",
|
|
|
|
|
(unsigned int)afState, (unsigned int)aeState, (unsigned int)awbState, (unsigned int)(ts - m_startTime));
|
|
|
|
|
// Must update mFinalLdr As getBurstCaptures getOutputFormat depends mFinalLdr
|
|
|
|
|
if (mLdr != ~0)
|
|
|
|
|
{
|
|
|
|
|
mFinalLdr = mLdr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Ready for Capture AFS=%u AES=%u AWBS=%u LDR=%u Time=%u",
|
|
|
|
|
(unsigned int)afState, (unsigned int)aeState, (unsigned int)awbState, mFinalLdr, (unsigned int)(ts - m_startTime));
|
|
|
|
|
if (m_params.burstRawCapture == 1)
|
|
|
|
|
{
|
|
|
|
|
if (mFinalLdr > 50)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_WARNING, "Switch to OneFrame Capture(YUV) As LDR=%u", mFinalLdr);
|
|
|
|
|
mFinalOutputFormat = AIMAGE_FORMAT_YUV_420_888;
|
|
|
|
|
mFinalBurstCaptures = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t burstCaptures = getBurstCaptures();
|
|
|
|
|
if (burstCaptures == 0)
|
|
|
|
@ -1544,7 +1876,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ALOGW("Will Stop Repeating Request");
|
|
|
|
|
status = ACameraCaptureSession_stopRepeating(capture_session);
|
|
|
|
|
// status = ACameraCaptureSession_stopRepeating(capture_session);
|
|
|
|
|
// ALOGW("Finished Repeating Request");
|
|
|
|
|
|
|
|
|
|
ACameraCaptureSession_captureCallbacks capture_session_capture_cb;
|
|
|
|
@ -1560,6 +1892,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
int numberOfRequests = requests.size();
|
|
|
|
|
status = ACameraCaptureSession_capture(capture_session, &capture_session_capture_cb,
|
|
|
|
|
numberOfRequests, &requests[0], &sequenceId);
|
|
|
|
|
AASSERT(status == ACAMERA_OK, "Failed to call ACameraCaptureSession_capture, status=%d", status);
|
|
|
|
|
|
|
|
|
|
ALOGW("Capture num = %d sequenceId=%d", numberOfRequests, sequenceId);
|
|
|
|
|
for (int idx = 1; idx < mCaptureRequests.size(); idx++)
|
|
|
|
@ -1572,22 +1905,99 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
uint64_t tid = getThreadIdOfULL();
|
|
|
|
|
ALOGW("Capture Result sequenceId=%d TID=%lld", pCaptureRequest->sessionSequenceId, (long long)tid);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
unsigned long long ts = GetMicroTimeStamp();
|
|
|
|
|
|
|
|
|
|
ACameraMetadata* pCopy = ACameraMetadata_copy(result);
|
|
|
|
|
bool captureCompleted = false;
|
|
|
|
|
size_t expectedTimes = mCaptureRequests.size() - 1;
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<ACameraMetadata> captureResult(pCopy, ACameraMetadata_free);
|
|
|
|
|
if (expectedTimes == 1)
|
|
|
|
|
{
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
mCaptureResults.push_back(std::shared_ptr<ACameraMetadata>(pCopy, ACameraMetadata_free));
|
|
|
|
|
captureCompleted = mCaptureResults.size() >= expectedTimes && mCaptureFrames.size() >= expectedTimes;
|
|
|
|
|
mCaptureResults.push_back(captureResult);
|
|
|
|
|
captureCompleted = !mOneFrame.empty();
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
if (captureCompleted)
|
|
|
|
|
{
|
|
|
|
|
onBurstCapture(mCharacteristics, mCaptureResults, mLdr, mCaptureFrames);
|
|
|
|
|
onOneCapture(mCharacteristics, captureResult, mFinalLdr, ts - m_startTime, mOneFrame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
mCaptureResults.push_back(captureResult);
|
|
|
|
|
captureCompleted = mCaptureFrames.size() >= expectedTimes && mCaptureResults.size() >= expectedTimes;
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
if (captureCompleted)
|
|
|
|
|
{
|
|
|
|
|
FireBurstCapture();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NdkCamera::FireBurstCapture()
|
|
|
|
|
{
|
|
|
|
|
unsigned long long ts = GetMicroTimeStamp();
|
|
|
|
|
|
|
|
|
|
size_t expectedTimes = mCaptureRequests.size() - 1;
|
|
|
|
|
std::vector<std::shared_ptr<ACameraMetadata> > captureResults;
|
|
|
|
|
uint32_t ldr;
|
|
|
|
|
std::vector<std::shared_ptr<AImage> > captureFrames;
|
|
|
|
|
|
|
|
|
|
m_locker.lock();
|
|
|
|
|
ldr = mFinalLdr;
|
|
|
|
|
if (ldr == 0 && mLdr != ~0)
|
|
|
|
|
{
|
|
|
|
|
ldr = mLdr;
|
|
|
|
|
}
|
|
|
|
|
captureResults.swap(mCaptureResults);
|
|
|
|
|
captureFrames.swap(mCaptureFrames);
|
|
|
|
|
m_locker.unlock();
|
|
|
|
|
|
|
|
|
|
media_status_t mstatus;
|
|
|
|
|
std::vector<std::vector<uint8_t> > frames;
|
|
|
|
|
for (int idx = 0; idx < expectedTimes; idx++)
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<AImage> spImage = captureFrames[idx];
|
|
|
|
|
std::shared_ptr<ACameraMetadata> spResult = captureResults[idx];
|
|
|
|
|
|
|
|
|
|
auto it = frames.insert(frames.end(), std::vector<uint8_t>());
|
|
|
|
|
|
|
|
|
|
int32_t width = 0;
|
|
|
|
|
int32_t height = 0;
|
|
|
|
|
mstatus = AImage_getWidth(spImage.get(), &width);
|
|
|
|
|
mstatus = AImage_getHeight(spImage.get(), &height);
|
|
|
|
|
|
|
|
|
|
int32_t planeCount = 0;
|
|
|
|
|
mstatus = AImage_getNumberOfPlanes(spImage.get(), &planeCount);
|
|
|
|
|
AASSERT(mstatus == AMEDIA_OK && planeCount == 1, "Error: getNumberOfPlanes() planeCount = %d", planeCount);
|
|
|
|
|
|
|
|
|
|
uint8_t *planeData = NULL;
|
|
|
|
|
int planeDataLen = 0;
|
|
|
|
|
mstatus = AImage_getPlaneData(spImage.get(), 0, &planeData, &planeDataLen);
|
|
|
|
|
ALOGD("Start Converting Dng");
|
|
|
|
|
DngCreator dngCreator(mCharacteristics.get(), spResult.get());
|
|
|
|
|
dngCreator.writeInputBuffer(*it, planeData, planeDataLen, width, height, 0);
|
|
|
|
|
ALOGD("End Converting Dng");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
captureFrames.clear();
|
|
|
|
|
|
|
|
|
|
onBurstCapture(mCharacteristics, captureResults, ldr, ts - m_startTime, frames);
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
ALOGD("Frames Size: %u", (uint32_t)frames.size());
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NdkCamera::CopyPreviewRequest(ACaptureRequest* request, const ACameraMetadata* previewResult)
|
|
|
|
@ -1622,9 +2032,13 @@ void NdkCamera::CopyPreviewRequest(ACaptureRequest* request, const ACameraMetada
|
|
|
|
|
|
|
|
|
|
void NdkCamera::onCaptureFailed(ACameraCaptureSession* session, ACaptureRequest* request, ACameraCaptureFailure* failure)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_WARNING, "onCaptureFailed session=%p request=%p reason=%d", session, request, failure->reason);
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_WARNING, "onCaptureFailed session=%p request=%p reason=%d PhotoTaken=%d", session, request, failure->reason, m_photoTaken ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
char msg[32] = { 0 };
|
|
|
|
|
if (failure->sequenceId == mCaptureRequests[PREVIEW_REQUEST_IDX]->sessionSequenceId)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
char msg[64] = { 0 };
|
|
|
|
|
snprintf(msg, sizeof(msg), "CaptureFailed reason=%d PhotoTaken=%d", failure->reason, m_photoTaken ? 1 : 0);
|
|
|
|
|
if (!m_photoTaken)
|
|
|
|
|
{
|
|
|
|
@ -1674,12 +2088,13 @@ bool NdkCamera::IsCameraAvailable(const std::string& cameraId)
|
|
|
|
|
|
|
|
|
|
int32_t NdkCamera::getOutputFormat() const
|
|
|
|
|
{
|
|
|
|
|
return m_params.burstRawCapture ? AIMAGE_FORMAT_RAW16 : AIMAGE_FORMAT_YUV_420_888;
|
|
|
|
|
return mFinalOutputFormat;
|
|
|
|
|
// return m_params.burstRawCapture ? AIMAGE_FORMAT_RAW16 : AIMAGE_FORMAT_YUV_420_888;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t NdkCamera::getBurstCaptures() const
|
|
|
|
|
{
|
|
|
|
|
return m_params.burstRawCapture ? m_params.burstCaptures : 1;
|
|
|
|
|
return mFinalBurstCaptures;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NdkCamera::CreateSession(ANativeWindow* previewWindow,
|
|
|
|
@ -1912,7 +2327,6 @@ bool NdkCamera::convertAImageToNv21(AImage* image, uint8_t** nv21, int32_t& widt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// on_image((unsigned ch
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|