@ -95,19 +95,7 @@ void onCaptureSequenceAborted(void* context, ACameraCaptureSession* session, int
void onCaptureProgressed ( void * context , ACameraCaptureSession * session , ACaptureRequest * request , const ACameraMetadata * result )
{
ACameraMetadata_const_entry val = { 0 } ;
camera_status_t status = ACAMERA_ERROR_BASE ;
val = { 0 } ;
status = ACameraMetadata_getConstEntry ( result , ACAMERA_CONTROL_AF_STATE , & val ) ;
if ( status = = ACAMERA_OK )
{
uint8_t afState = * ( val . data . u8 ) ;
ALOGD ( " onCaptureProgressed AF_STATE=%u " , ( unsigned int ) afState ) ;
// ((NdkCamera*)context)->onCaptureProgressed(session, request, result);
}
( ( NdkCamera * ) context ) - > onCaptureProgressed ( session , request , result ) ;
}
void onCaptureCompleted ( void * context , ACameraCaptureSession * session , ACaptureRequest * request , const ACameraMetadata * result )
@ -128,6 +116,7 @@ NdkCamera::NdkCamera(int32_t width, int32_t height, const NdkCamera::CAMERA_PARA
m_imagesCaptured = ~ 0 ;
afSupported = false ;
lockAvailable = false ;
hdrSupported = false ;
nightModeSupported = false ;
@ -322,6 +311,13 @@ int NdkCamera::open(const std::string& cameraId) {
}
}
{
ACameraMetadata_const_entry e = { 0 } ;
status = ACameraMetadata_getConstEntry ( camera_metadata , ACAMERA_CONTROL_AE_LOCK_AVAILABLE , & e ) ;
// AASSERT(status == ACAMERA_OK, "ACameraMetadata_getConstEntry::ACAMERA_CONTROL_AF_AVAILABLE_MODES return error, %d", status);
lockAvailable = ( status = = ACAMERA_OK ) ? ( * e . data . u8 = = ACAMERA_CONTROL_AE_LOCK_AVAILABLE_TRUE ) : false ;
}
{
ACameraMetadata_const_entry val = { 0 } ;
status = ACameraMetadata_getConstEntry ( camera_metadata , ACAMERA_CONTROL_AE_COMPENSATION_RANGE , & val ) ;
@ -414,6 +410,26 @@ 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 ;
// uint8_t afMode = ACAMERA_CONTROL_AF_MODE_AUTO;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AF_MODE , 1 , & afMode ) ;
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START ;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AF_TRIGGER , 1 , & trig ) ;
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;
}
// std::this_thread::sleep_for(std::chrono::milliseconds(128));
// capture request
{
@ -450,27 +466,6 @@ int NdkCamera::open(const std::string& cameraId) {
status = ACaptureRequest_setEntry_i64 ( capture_request , ACAMERA_SENSOR_EXPOSURE_TIME , 1 , & exposureTime ) ;
}
}
if ( afSupported & & m_params . autoFocus ) {
// uint8_t afMode = ACAMERA_CONTROL_AF_MODE_CONTINUOUS_VIDEO;
uint8_t afMode = ACAMERA_CONTROL_AF_MODE_CONTINUOUS_PICTURE ;
// uint8_t afMode = ACAMERA_CONTROL_AF_MODE_AUTO;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AF_MODE , 1 , & afMode ) ;
uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START ;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AF_TRIGGER , 1 , & trig ) ;
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;
}
// TODO:
// m_imagesCaptured = 0;
@ -871,6 +866,11 @@ void NdkCamera::onSessionReady(ACameraCaptureSession *session)
}
}
void NdkCamera : : onCaptureProgressed ( ACameraCaptureSession * session , ACaptureRequest * request , const ACameraMetadata * result )
{
}
void NdkCamera : : onCaptureCompleted ( ACameraCaptureSession * session , ACaptureRequest * request , const ACameraMetadata * result )
{
// CALL_REQUEST(setEntry_i64(requests_[PREVIEW_REQUEST_IDX].request_,
@ -879,6 +879,9 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
// ACameraMetadata_getConstEntry(result, )
ACameraMetadata_const_entry val = { 0 } ;
camera_status_t status = ACAMERA_ERROR_BASE ;
// ACameraMetadata_const_entry val = { 0 };
// camera_status_t status = ACAMERA_ERROR_BASE;
mResult . afState = ACAMERA_CONTROL_AF_STATE_INACTIVE ;
val = { 0 } ;
@ -895,9 +898,9 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
if ( m_imagesCaptured = = ~ 0 )
{
unsigned long long ts = GetMicroTimeStamp ( ) ;
if ( ts - m_startTime > = m_params . focusTimeout )
if ( ts - m_startTime > = m_params . focusTimeout * 2 )
{
ALOGD( " onCaptureCompleted Timeout for AF/AE And will Capture AFS=%u AES =%u" , ( unsigned int ) mResult . afState , ( unsigned int ) mResult . aeState ) ;
XYLOG( XYLOG_SEVERITY_WARNING , " onCaptureCompleted Timeout for AF/AE And will Capture AFS=%u AES =%u Time =%u" , ( unsigned int ) mResult . afState , ( unsigned int ) mResult . aeState , ( unsigned int ) ( ts - m_startTime ) ) ;
m_imagesCaptured = 0 ;
}
else
@ -909,17 +912,35 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
// Waiting
return ;
}
if ( mResult . aeState = = ACAMERA_CONTROL_AE_STATE_PRECAPTURE )
else 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 ) ;
return ;
}
else if ( mResult . aeState = = ACAMERA_CONTROL_AE_STATE_CONVERGED )
{
if ( lockAvailable )
{
uint8_t aeLock = ACAMERA_CONTROL_AE_LOCK_ON ;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AE_LOCK , 1 , & aeLock ) ;
}
}
}
if ( afSupported & & ( m_params . autoFocus ! = 0 ) )
{
if ( mResult . afState = = ACAMERA_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED )
{
uint8_t aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL ;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER , 1 , & aePrecatureTrigger ) ;
aePrecatureTrigger = ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER_START ;
status = ACaptureRequest_setEntry_u8 ( capture_request , ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER , 1 , & aePrecatureTrigger ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " onCaptureCompleted New Focus Trigger AFS=%u AES=%u Time=%u " , ( unsigned int ) mResult . afState , ( unsigned int ) mResult . aeState ) ;
return ;
}
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)
@ -934,6 +955,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
}
}
if ( m_imagesCaptured ! = 0 | | camera_facing = = 2 )
{
return ;
@ -950,6 +972,10 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque
// ACaptureRequest_setEntry_i32(capture_request, ACAMERA_SENSOR_SENSITIVITY, 1, &sensitivity_);
mResult . autoExposure = aeMode ;
val = { 0 } ;
status = ACameraMetadata_getConstEntry ( result , ACAMERA_CONTROL_AWB_STATE , & val ) ;
mResult . awbState = ( status = = ACAMERA_OK ) ? val . data . u8 [ 0 ] : 0 ;
val = { 0 } ;
float focusDistance = NAN ;
if ( afSupported & & ( m_params . autoFocus ! = 0 ) )