@ -334,6 +334,71 @@ bool camera_start(camera_t *cam) {
@@ -334,6 +334,71 @@ bool camera_start(camera_t *cam) {
int64_t frame_time = 1000000 / camp - > params - > fps ;
ctrls . set ( controls : : FrameDurationLimits , Span < const int64_t , 2 > ( { frame_time , frame_time } ) ) ;
int af_mode ;
if ( strcmp ( camp - > params - > af_mode , " manual " ) = = 0 ) {
af_mode = controls : : AfModeManual ;
} else if ( strcmp ( camp - > params - > af_mode , " auto " ) = = 0 ) {
af_mode = controls : : AfModeAuto ;
} else if ( strcmp ( camp - > params - > af_mode , " continuous " ) = = 0 ) {
af_mode = controls : : AfModeContinuous ;
} else {
af_mode = controls : : AfModeManual ;
}
ctrls . set ( controls : : AfMode , af_mode ) ;
int af_range ;
if ( strcmp ( camp - > params - > af_range , " normal " ) = = 0 ) {
af_range = controls : : AfRangeNormal ;
} else if ( strcmp ( camp - > params - > af_range , " macro " ) = = 0 ) {
af_range = controls : : AfRangeMacro ;
} else if ( strcmp ( camp - > params - > af_range , " full " ) = = 0 ) {
af_range = controls : : AfRangeFull ;
} else {
af_range = controls : : AfRangeNormal ;
}
ctrls . set ( controls : : AfRange , af_range ) ;
int af_speed ;
if ( strcmp ( camp - > params - > af_range , " normal " ) = = 0 ) {
af_speed = controls : : AfSpeedNormal ;
} else if ( strcmp ( camp - > params - > af_range , " fast " ) = = 0 ) {
af_speed = controls : : AfSpeedFast ;
} else {
af_speed = controls : : AfSpeedNormal ;
}
ctrls . set ( controls : : AfSpeed , af_speed ) ;
// Lens Position
ctrls . set ( controls : : LensPosition , camp - > params - > lens_position ) ;
// Af Window
if ( camp - > params - > af_window ! = NULL ) {
std : : optional < Rectangle > opt = camp - > camera - > properties ( ) . get ( properties : : ScalerCropMaximum ) ;
Rectangle sensor_area ;
try {
sensor_area = opt . value ( ) ;
} catch ( const std : : bad_optional_access & exc ) {
set_error ( " get(ScalerCropMaximum) failed " ) ;
return false ;
}
Rectangle afwindows_rectangle [ 1 ] ;
afwindows_rectangle [ 0 ] = Rectangle (
camp - > params - > af_window - > x * sensor_area . width ,
camp - > params - > af_window - > y * sensor_area . height ,
camp - > params - > af_window - > width * sensor_area . width ,
camp - > params - > af_window - > height * sensor_area . height ) ;
afwindows_rectangle [ 0 ] . translateBy ( sensor_area . topLeft ( ) ) ;
//activate the AfMeteringWindows
ctrls . set ( controls : : AfMetering , controls : : AfMeteringWindows ) ;
//set window
ctrls . set ( controls : : AfWindows , afwindows_rectangle ) ;
}
int res = camp - > camera - > start ( & ctrls ) ;
if ( res ! = 0 ) {
set_error ( " Camera.start() failed " ) ;