Choose V4L2 Sensor Mode in Argus

When using gstreamer, nvcamerasrc seems to dynamically select the sensor mode from the device tree based on the input resolution. Is there a way to replicate that in Argus? Right now it seems to always choose mode 0, even if it’s not the default.

Think I found figured it out,

ISourceSettings has a setSensorMode method and ICameraProperties has getSensorModes

Getting the list of sensor modes:

// Create the CameraProvider object and get the core interface.
UniqueObj<CameraProvider> cameraProvider = UniqueObj<CameraProvider>(CameraProvider::create());
ICameraProvider *iCameraProvider = interface_cast<ICameraProvider>(cameraProvider);
if(!iCameraProvider) ORIGINATE_ERROR("Failed to create CameraProvider");

// Get the camera devices.
std::vector<CameraDevice*> cameraDevices;
if(cameraDevices.size() == 0) ORIGINATE_ERROR("No cameras available");

// Get sensor mode
ICameraProperties *iCameraProperties = interface_cast<ICameraProperties>(cameraDevices[0]);
if(!iCameraProperties) ORIGINATE_ERROR("Failed to create ICameraProperties interface");

std::vector<SensorMode*> modes;

printf("Available Sensor modes:\n");
for(size_t i = 0; i < modes.size(); i++)
    ISensorMode *iSensorMode = interface_cast<ISensorMode>(modes[i]);
    if(!iSensorMode) ORIGINATE_ERROR("Failed to create ISensorMode interface");

    Size2D<uint32_t> size = iSensorMode->getResolution();
    Range<uint64_t> framerate = iSensorMode->getFrameDurationRange();
    printf("mode %zu: %u x %u, FR=%.0f\n", i, size.width(), size.height(), 1e9/framerate.min());

Setting the mode:

// Set framerate and sensor mode
ISourceSettings *iSourceSettings = interface_cast<ISourceSettings>(iRequest->getSourceSettings());
if(!iSourceSettings) ORIGINATE_ERROR("Failed to get ISourceSettings interface");