diff --git a/libraries/AP_HAL_Linux/OpticalFlow_Onboard.cpp b/libraries/AP_HAL_Linux/OpticalFlow_Onboard.cpp index 33ce75b397..1b6500d55c 100644 --- a/libraries/AP_HAL_Linux/OpticalFlow_Onboard.cpp +++ b/libraries/AP_HAL_Linux/OpticalFlow_Onboard.cpp @@ -90,6 +90,10 @@ void OpticalFlow_Onboard::init(AP_HAL::OpticalFlow::Gyro_Cb get_gyro) "video device"); } + if (!_videoin->set_crop(left, top, crop_width, crop_height)) { + AP_HAL::panic("OpticalFlow_Onboard: couldn't set video crop"); + } + if (!_videoin->set_format(&_width, &_height, &_format, &_bytesperline, &_sizeimage)) { AP_HAL::panic("OpticalFlow_Onboard: couldn't set video format"); @@ -100,10 +104,6 @@ void OpticalFlow_Onboard::init(AP_HAL::OpticalFlow::Gyro_Cb get_gyro) AP_HAL::panic("OpticalFlow_Onboard: planar or monochrome format needed"); } - if (!_videoin->set_crop(left, top, crop_width, crop_height)) { - AP_HAL::panic("OpticalFlow_Onboard: couldn't set video crop"); - } - if (!_videoin->allocate_buffers(nbufs)) { AP_HAL::panic("OpticalFlow_Onboard: couldn't allocate video buffers"); }