|
|
|
@ -413,10 +413,11 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_imagesCaptured = 0;
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(128));
|
|
|
|
|
// capture request
|
|
|
|
|
{
|
|
|
|
|
ACameraDevice_request_template templateId = (afSupported && m_params.autoFocus) ? TEMPLATE_PREVIEW : TEMPLATE_STILL_CAPTURE;
|
|
|
|
|
ACameraDevice_request_template templateId = ((afSupported && m_params.autoFocus) || m_params.autoExposure) ? TEMPLATE_PREVIEW : TEMPLATE_STILL_CAPTURE;
|
|
|
|
|
status = ACameraDevice_createCaptureRequest(camera_device, templateId, &capture_request);
|
|
|
|
|
|
|
|
|
|
int32_t fpsRange[2] = {1,1};
|
|
|
|
@ -429,6 +430,10 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
|
|
|
|
|
uint8_t aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_START;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER, 1, &aePrecatureTrigger);
|
|
|
|
|
if (status == ACAMERA_OK)
|
|
|
|
|
{
|
|
|
|
|
m_imagesCaptured = ~0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t aeLockOff = ACAMERA_CONTROL_AE_LOCK_OFF;
|
|
|
|
|
// ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AE_LOCK, 1, &aeLockOff);
|
|
|
|
@ -454,13 +459,16 @@ int NdkCamera::open(const std::string& cameraId) {
|
|
|
|
|
|
|
|
|
|
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig);
|
|
|
|
|
m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0;
|
|
|
|
|
if (status == ACAMERA_OK)
|
|
|
|
|
{
|
|
|
|
|
m_imagesCaptured = ~0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START;
|
|
|
|
|
// status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig);
|
|
|
|
|
m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0;
|
|
|
|
|
// m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
@ -881,7 +889,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
{
|
|
|
|
|
val = { 0 };
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val);
|
|
|
|
|
mResult.afState = *(val.data.u8);
|
|
|
|
|
mResult.afState = (status == ACAMERA_OK) ? *(val.data.u8) : ACAMERA_CONTROL_AF_STATE_INACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_imagesCaptured == ~0)
|
|
|
|
@ -896,7 +904,13 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
{
|
|
|
|
|
if (m_params.autoExposure != 0)
|
|
|
|
|
{
|
|
|
|
|
if (mResult.aeState == ACAMERA_CONTROL_AE_STATE_SEARCHING || mResult.aeState == ACAMERA_CONTROL_AE_STATE_PRECAPTURE)
|
|
|
|
|
if (mResult.aeState == ACAMERA_CONTROL_AE_STATE_SEARCHING)
|
|
|
|
|
{
|
|
|
|
|
// Waiting
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mResult.aeState == ACAMERA_CONTROL_AE_STATE_PRECAPTURE)
|
|
|
|
|
{
|
|
|
|
|
uint8_t aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_START;
|
|
|
|
|
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER, 1, &aePrecatureTrigger);
|
|
|
|
@ -906,7 +920,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
|
|
|
|
|
if (afSupported && (m_params.autoFocus != 0))
|
|
|
|
|
{
|
|
|
|
|
ALOGD("onCaptureCompleted AF_STATE=%u", (unsigned int)mResult.afState);
|
|
|
|
|
ALOGD("onCaptureCompleted AFS=%u AES=%u", (unsigned int)mResult.afState, (unsigned int)mResult.aeState);
|
|
|
|
|
if (mResult.afState == ACAMERA_CONTROL_AF_STATE_PASSIVE_FOCUSED || mResult.afState == ACAMERA_CONTROL_AF_STATE_FOCUSED_LOCKED)
|
|
|
|
|
// if (afState != ACAMERA_CONTROL_AF_STATE_INACTIVE)
|
|
|
|
|
{
|
|
|
|
@ -952,7 +966,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val);
|
|
|
|
|
mResult.afState = *(val.data.u8);
|
|
|
|
|
|
|
|
|
|
ALOGD("onCaptureCompleted AFS=%u", (unsigned int)mResult.afState);
|
|
|
|
|
ALOGD("onCaptureCompleted AFS=%u AES=%u", (unsigned int)mResult.afState, (unsigned int)mResult.aeState);
|
|
|
|
|
|
|
|
|
|
val = {0};
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_SENSOR_SENSITIVITY, &val);
|
|
|
|
@ -966,7 +980,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
|
|
|
|
|
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_MODE, &val);
|
|
|
|
|
mResult.autoFocus = *(val.data.u8);
|
|
|
|
|
|
|
|
|
|
ALOGD("onCaptureCompleted EXPOSURE_TIME=%lld, FocusDis=%f camera id=%s, AE=%s AF_STATE=%u", exTime, focusDistance, mCameraId.c_str(), ((aeMode == 1) ? "ON" : "OFF"), mResult.afState);
|
|
|
|
|
ALOGD("onCaptureCompleted EXPO=%lld, FD=%f camera id=%s, AE=%s AFS=%u AES=%u", exTime, focusDistance, mCameraId.c_str(), ((aeMode == 1) ? "ON" : "OFF"), mResult.afState, mResult.aeState);
|
|
|
|
|
|
|
|
|
|
// __android_log_print(ANDROID_LOG_WARN, "NdkCamera", "onCaptureCompleted %p %p %p", session, request, result);
|
|
|
|
|
}
|
|
|
|
|