增加曝光补偿的配置

serial
Matthew 1 year ago
parent a54aaccc22
commit 8aa40fec60

@ -912,6 +912,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
params.focusTimeout = mPhotoInfo.focusTimeout * 1000;
params.exposureTime = mPhotoInfo.exposureTime;
params.sensibility = mPhotoInfo.sensibility;
params.compensation = mPhotoInfo.compensation;
params.orientation = mPhotoInfo.orientation;
params.zoom = mPhotoInfo.zoom;
params.zoomRatio = mPhotoInfo.zoomRatio;

@ -282,9 +282,21 @@ int NdkCamera::open(const std::string& cameraId) {
ACameraMetadata_const_entry e = {0};
status = ACameraMetadata_getConstEntry(camera_metadata,ACAMERA_CONTROL_AF_AVAILABLE_MODES, &e);
// AASSERT(status == ACAMERA_OK, "ACameraMetadata_getConstEntry::ACAMERA_CONTROL_AF_AVAILABLE_MODES return error, %d", status);
#ifdef _DEBUG
for (int idx = 0; idx < e.count; idx++)
{
unsigned int m = e.data.u8[idx];
XYLOG(XYLOG_SEVERITY_DEBUG, "Available AF Mode %u", m);
}
#endif
afSupported = (status == ACAMERA_OK) && !(e.count == 0 || (e.count == 1 && e.data.u8[0] == ACAMERA_CONTROL_AF_MODE_OFF));
}
if (!afSupported)
{
XYLOG(XYLOG_SEVERITY_ERROR, "AF not Supported");
}
{
ACameraMetadata_const_entry val = {0};
status = ACameraMetadata_getConstEntry(camera_metadata,ACAMERA_SENSOR_INFO_EXPOSURE_TIME_RANGE, &val);
@ -343,6 +355,8 @@ int NdkCamera::open(const std::string& cameraId) {
{
aeCompensationRange.min_ = val.data.i32[0];
aeCompensationRange.max_ = val.data.i32[1];
XYLOG(XYLOG_SEVERITY_DEBUG, "AE_COMPENSATION_RANGE %d-%d", aeCompensationRange.min_, aeCompensationRange.max_);
}
else
{
@ -351,6 +365,17 @@ int NdkCamera::open(const std::string& cameraId) {
}
}
{
ACameraMetadata_const_entry val = {0};
status = ACameraMetadata_getConstEntry(camera_metadata, ACAMERA_CONTROL_AE_COMPENSATION_STEP, &val);
if (status == ACAMERA_OK)
{
aeCompensationStep = val.data.r[0];
XYLOG(XYLOG_SEVERITY_DEBUG, "AE_COMPENSATION_RANGE num=%d den=%d", aeCompensationStep.numerator, aeCompensationStep.denominator);
}
}
{
ACameraMetadata_const_entry val = {0};
status = ACameraMetadata_getConstEntry(camera_metadata,ACAMERA_SENSOR_INFO_SENSITIVITY_RANGE, &val);
@ -421,7 +446,6 @@ int NdkCamera::open(const std::string& cameraId) {
m_imagesCaptured = 0;
if (afSupported && m_params.autoFocus) {
// uint8_t afMode = ACAMERA_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
uint8_t afMode = ACAMERA_CONTROL_AF_MODE_CONTINUOUS_PICTURE;
@ -459,6 +483,25 @@ int NdkCamera::open(const std::string& cameraId) {
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AE_MODE, 1, &aeMode);
// ACaptureRequest_setEntry_i32(capture_request, ACAMERA_SENSOR_SENSITIVITY, 1, &sensitivity_);
if ((aeCompensationRange.min_ != 0 || aeCompensationRange.max_ != 0) && m_params.compensation != 0)
{
int32_t compensation = m_params.compensation;
if (compensation < aeCompensationRange.min_)
{
compensation = aeCompensationRange.min_;
}
if (compensation > aeCompensationRange.max_)
{
compensation = aeCompensationRange.max_;
}
// int32_t aeCompensation = aeCompensationRange.max_;
status = ACaptureRequest_setEntry_i32(capture_request, ACAMERA_CONTROL_AE_EXPOSURE_COMPENSATION, 1, &compensation);
if (status != ACAMERA_OK)
{
int aa = 0;
}
}
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)
@ -949,7 +992,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
if (afSupported && (m_params.autoFocus != 0))
{
if (mResult.afState == ACAMERA_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED)
if (mResult.afState == ACAMERA_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED || mResult.afState == ACAMERA_CONTROL_AF_STATE_PASSIVE_UNFOCUSED)
{
uint8_t aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL;
status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER, 1, &aePrecatureTrigger);
@ -960,7 +1003,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
return;
}
ALOGD("onCaptureCompleted AFS=%u AES=%u", (unsigned int)mResult.afState, (unsigned int)mResult.aeState);
ALOGD("onCaptureCompleted 1 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)
{
@ -1014,11 +1057,13 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
mResult.zoomRatio = *val.data.f;
}
/*
val = { 0 };
status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val);
mResult.afState = *(val.data.u8);
*/
ALOGD("onCaptureCompleted AFS=%u AES=%u", (unsigned int)mResult.afState, (unsigned int)mResult.aeState);
ALOGD("onCaptureCompleted 2 AFS=%u AES=%u", (unsigned int)mResult.afState, (unsigned int)mResult.aeState);
val = {0};
status = ACameraMetadata_getConstEntry(result, ACAMERA_SENSOR_SENSITIVITY, &val);

@ -78,6 +78,7 @@ public:
unsigned int reserved : 7;
unsigned int exposureTime; // ms
unsigned int sensibility;
int compensation;
float zoomRatio;
};
@ -91,6 +92,7 @@ public:
int64_t exposureTime;
float FocusDistance;
int32_t sensitibity;
int32_t compensation;
uint8_t sceneMode;
float zoomRatio;
@ -146,6 +148,7 @@ protected:
// int32_t sensitivity_;
RangeValue<int32_t> sensitivityRange;
RangeValue<int32_t> aeCompensationRange;
ACameraMetadata_rational aeCompensationStep;
unsigned int m_imagesCaptured;

Loading…
Cancel
Save