@ -2713,76 +2713,62 @@ bool CPhoneDevice::onOneCapture(std::shared_ptr<ACameraMetadata> characteristics
CPhoneDevice * pThis = this ;
CPhoneDevice * pThis = this ;
std : : thread th ( [ pThis , characteristics , result , photoInfo , osds , path , rgb , facing , sensorOrientation , ldr , duration , takingTime ] ( )
std : : thread th ( [ pThis , characteristics , result , photoInfo , osds , path , rgb , facing , sensorOrientation , ldr , duration , takingTime ] ( )
{
{
std : : string cameraInfo ;
std : : string cameraInfo ;
if ( photoInfo . outputDbgInfo ! = 0 )
if ( photoInfo . outputDbgInfo ! = 0 )
{
{
NdkCamera : : CAPTURE_RESULT captureResult = { 0 } ;
cameraInfo = BuildCaptureResultInfo ( result . get ( ) , ldr , duration , false ) ;
NdkCamera : : EnumCameraResult ( result . get ( ) , captureResult ) ;
}
char extimeunit [ 4 ] = { 0 } ;
unsigned int extime = ( captureResult . exposureTime > = 1000000 ) ? ( ( unsigned int ) ( captureResult . exposureTime / 1000000 ) ) : ( ( unsigned int ) ( captureResult . exposureTime / 1000 ) ) ;
strcpy ( extimeunit , ( captureResult . exposureTime > = 1000000 ) ? " ms " : " μs " ) ;
char str [ 128 ] = { 0 } ;
snprintf ( str , sizeof ( str ) , " AE=%u AF=%u EXPS=%u%s(%d) ISO=%d AFS=%u AES=%u AWBS=%u SCENE=%d LDR=%d(%u) %0.1fx T=%u FD=%lld " ,
captureResult . autoExposure , captureResult . autoFocus ,
extime , extimeunit , captureResult . compensation , captureResult . sensitivity ,
// isnan(captureResult.FocusDistance) ? 0 : captureResult.FocusDistance,
( unsigned int ) captureResult . afState , ( unsigned int ) captureResult . aeState , captureResult . awbState ,
captureResult . sceneMode , GpioControl : : getLightAdc ( ) , ldr , captureResult . zoomRatio ,
duration , captureResult . frameDuration ) ;
cameraInfo = str ;
}
# ifdef OUTPUT_DBG_INFO
# ifdef OUTPUT_DBG_INFO
#if 0
#if 0
bool shouldRetry = false ;
bool shouldRetry = false ;
if ( ldr ! = ~ 0 )
if ( ldr ! = ~ 0 )
{
{
if ( ldr < MIN_LIGHT_Y )
if ( ldr < MIN_LIGHT_Y )
{
{
if ( photoInfo . retries < ( DEFAULT_TAKE_PHOTO_RETRIES - 1 ) )
if ( photoInfo . retries < ( DEFAULT_TAKE_PHOTO_RETRIES - 1 ) )
{
{
shouldRetry = true ;
shouldRetry = true ;
char presetBuf [ 16 ] = { 0 } ;
char presetBuf [ 16 ] = { 0 } ;
snprintf ( presetBuf , sizeof ( presetBuf ) , " %02X " , photoInfo . retries ) ;
snprintf ( presetBuf , sizeof ( presetBuf ) , " %02X " , photoInfo . retries ) ;
// replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(photoInfo.retries) + ".jpg");
// replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(photoInfo.retries) + ".jpg");
replaceAll ( fullPath , " _FF_ " , std : : string ( " _ " ) + presetBuf + std : : string ( " _ " ) ) ;
replaceAll ( fullPath , " _FF_ " , std : : string ( " _ " ) + presetBuf + std : : string ( " _ " ) ) ;
XYLOG ( XYLOG_SEVERITY_ERROR , " Photo is TOO dark or light(LDR=%u), will RETRY it " ,
XYLOG ( XYLOG_SEVERITY_ERROR , " Photo is TOO dark or light(LDR=%u), will RETRY it " ,
( uint32_t ) captureResult . avgY ) ;
( uint32_t ) captureResult . avgY ) ;
// photoInfo.usingRawFormat = 1;
// photoInfo.usingRawFormat = 1;
}
}
}
}
else if ( ldr > MAX_LIGHT_Y )
else if ( ldr > MAX_LIGHT_Y )
{
{
if ( photoInfo . retries < ( DEFAULT_TAKE_PHOTO_RETRIES - 1 ) )
if ( photoInfo . retries < ( DEFAULT_TAKE_PHOTO_RETRIES - 1 ) )
{
{
shouldRetry = true ;
shouldRetry = true ;
char presetBuf [ 16 ] = { 0 } ;
char presetBuf [ 16 ] = { 0 } ;
snprintf ( presetBuf , sizeof ( presetBuf ) , " %02X " , photoInfo . retries ) ;
snprintf ( presetBuf , sizeof ( presetBuf ) , " %02X " , photoInfo . retries ) ;
// replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(photoInfo.retries) + ".jpg");
// replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(photoInfo.retries) + ".jpg");
replaceAll ( fullPath , " _FF_ " , std : : string ( " _ " ) + presetBuf + std : : string ( " _ " ) ) ;
replaceAll ( fullPath , " _FF_ " , std : : string ( " _ " ) + presetBuf + std : : string ( " _ " ) ) ;
XYLOG ( XYLOG_SEVERITY_ERROR , " Photo is TOO dark or light(LDR=%u), will RETRY it " ,
XYLOG ( XYLOG_SEVERITY_ERROR , " Photo is TOO dark or light(LDR=%u), will RETRY it " ,
( uint32_t ) captureResult . avgY ) ;
( uint32_t ) captureResult . avgY ) ;
}
}
photoInfo . compensation = - 2 * ( ( int16_t ) ( ( uint16_t ) captureResult . avgY ) ) ;
photoInfo . compensation = - 2 * ( ( int16_t ) ( ( uint16_t ) captureResult . avgY ) ) ;
}
}
}
}
# endif // 0
# endif // 0
# endif // OUTPUT_DBG_INFO
# endif // OUTPUT_DBG_INFO
// Notify to take next photo
// Notify to take next photo
XYLOG ( XYLOG_SEVERITY_INFO , " TP: Notofy to Take Next CUR Info: CH=%u PR=%u PHOTOID=%u " , ( uint32_t ) photoInfo . channel , ( uint32_t ) photoInfo . preset , ( uint32_t ) photoInfo . photoId ) ;
XYLOG ( XYLOG_SEVERITY_INFO , " TP: Notofy to Take Next CUR Info: CH=%u PR=%u PHOTOID=%u " , ( uint32_t ) photoInfo . channel , ( uint32_t ) photoInfo . preset , ( uint32_t ) photoInfo . photoId ) ;
pThis - > TakePhotoCb ( 1 , photoInfo , " " , takingTime ) ;
pThis - > TakePhotoCb ( 1 , photoInfo , " " , takingTime ) ;
bool res = pThis - > PostProcessPhoto ( photoInfo , osds , path , cameraInfo , rgb ) ;
bool res = pThis - > PostProcessPhoto ( photoInfo , osds , path , cameraInfo , rgb ) ;
if ( res )
if ( res )
{
{
// TakePhotoCb(2, photoInfo, path, takingTime);
// TakePhotoCb(2, photoInfo, path, takingTime);
}
}
} ) ;
} ) ;
th . detach ( ) ;
th . detach ( ) ;
@ -2858,21 +2844,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristi
{
{
if ( ! results . empty ( ) )
if ( ! results . empty ( ) )
{
{
NdkCamera : : CAPTURE_RESULT captureResult = { 0 } ;
cameraInfo = BuildCaptureResultInfo ( results [ 0 ] . get ( ) , ldr , duration , true ) ;
NdkCamera : : EnumCameraResult ( results [ 0 ] . get ( ) , captureResult ) ;
char extimeunit [ 4 ] = { 0 } ;
unsigned int extime = ( captureResult . exposureTime > = 1000000 ) ? ( ( unsigned int ) ( captureResult . exposureTime / 1000000 ) ) : ( ( unsigned int ) ( captureResult . exposureTime / 1000 ) ) ;
strcpy ( extimeunit , ( captureResult . exposureTime > = 1000000 ) ? " ms " : " μs " ) ;
char str [ 128 ] = { 0 } ;
snprintf ( str , sizeof ( str ) , " AE=%u AF=%u EXPS=%u%s(%d) ISO=%d AFS=%u AES=%u AWBS=%u SCENE=%d LDR=%d(%u) %0.1fx T=%u FD=%lld BURST " ,
captureResult . autoExposure , captureResult . autoFocus ,
extime , extimeunit , captureResult . compensation , captureResult . sensitivity ,
// isnan(captureResult.FocusDistance) ? 0 : captureResult.FocusDistance,
( unsigned int ) captureResult . afState , ( unsigned int ) captureResult . aeState , captureResult . awbState ,
captureResult . sceneMode , GpioControl : : getLightAdc ( ) , ldr , captureResult . zoomRatio ,
duration , captureResult . frameDuration ) ;
cameraInfo = str ;
}
}
}
}
@ -3176,6 +3148,25 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristi
return true ;
return true ;
}
}
std : : string CPhoneDevice : : BuildCaptureResultInfo ( ACameraMetadata * result , uint32_t ldr , uint32_t duration , bool burst )
{
NdkCamera : : CAPTURE_RESULT captureResult = { 0 } ;
NdkCamera : : EnumCameraResult ( result , captureResult ) ;
char extimeunit [ 4 ] = { 0 } ;
unsigned int extime = ( captureResult . exposureTime > = 1000000 ) ? ( ( unsigned int ) ( captureResult . exposureTime / 1000000 ) ) : ( ( captureResult . exposureTime > = 1000 ) ? ( ( unsigned int ) ( captureResult . exposureTime / 1000 ) ) : captureResult . exposureTime ) ;
strcpy ( extimeunit , ( captureResult . exposureTime > = 1000000 ) ? " ms " : ( ( captureResult . exposureTime > 1000 ) ? " μs " : " ns " ) ) ;
char str [ 128 ] = { 0 } ;
snprintf ( str , sizeof ( str ) , " AE=%u AF=%u EXPS=%u%s(%d) ISO=%d AFS=%u AES=%u AWBS=%u SCENE=%d LDR=%d(%u) %0.1fx T=%u FD=%lld %s " ,
captureResult . autoExposure , captureResult . autoFocus ,
extime , extimeunit , captureResult . compensation , captureResult . sensitivity ,
// isnan(captureResult.FocusDistance) ? 0 : captureResult.FocusDistance,
( unsigned int ) captureResult . afState , ( unsigned int ) captureResult . aeState , captureResult . awbState ,
captureResult . sceneMode , GpioControl : : getLightAdc ( ) , ldr , captureResult . zoomRatio ,
duration , captureResult . frameDuration , burst ? " BURST " : " " ) ;
return std : : string ( str ) ;
}
bool CPhoneDevice : : onBurstCapture ( std : : shared_ptr < ACameraMetadata > characteristics ,
bool CPhoneDevice : : onBurstCapture ( std : : shared_ptr < ACameraMetadata > characteristics ,
std : : vector < std : : shared_ptr < ACameraMetadata > > & results ,
std : : vector < std : : shared_ptr < ACameraMetadata > > & results ,
uint32_t ldr , uint32_t duration , std : : vector < std : : shared_ptr < AImage > > & frames )
uint32_t ldr , uint32_t duration , std : : vector < std : : shared_ptr < AImage > > & frames )
@ -3365,21 +3356,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr<ACameraMetadata> characteristi
{
{
if ( ! results . empty ( ) )
if ( ! results . empty ( ) )
{
{
NdkCamera : : CAPTURE_RESULT captureResult = { 0 } ;
cameraInfo = BuildCaptureResultInfo ( results [ 0 ] . get ( ) , ldr , duration , false ) ;
NdkCamera : : EnumCameraResult ( results [ 0 ] . get ( ) , captureResult ) ;
char extimeunit [ 4 ] = { 0 } ;
unsigned int extime = ( captureResult . exposureTime > = 1000000 ) ? ( ( unsigned int ) ( captureResult . exposureTime / 1000000 ) ) : ( ( unsigned int ) ( captureResult . exposureTime / 1000 ) ) ;
strcpy ( extimeunit , ( captureResult . exposureTime > = 1000000 ) ? " ms " : " μs " ) ;
char str [ 128 ] = { 0 } ;
snprintf ( str , sizeof ( str ) , " AE=%u AF=%u EXPS=%u%s(%d) ISO=%d AFS=%u AES=%u AWBS=%u SCENE=%d LDR=%d(%u) %0.1fx T=%u FD=%lld " ,
captureResult . autoExposure , captureResult . autoFocus ,
extime , extimeunit , captureResult . compensation , captureResult . sensitivity ,
// isnan(captureResult.FocusDistance) ? 0 : captureResult.FocusDistance,
( unsigned int ) captureResult . afState , ( unsigned int ) captureResult . aeState , captureResult . awbState ,
captureResult . sceneMode , GpioControl : : getLightAdc ( ) , ldr , captureResult . zoomRatio ,
duration , captureResult . frameDuration ) ;
cameraInfo = str ;
}
}
}
}