setSensorMode of camera to output 1080p

Hi Guys,

I am trying to set the mode of the camera so as to get the desired resolution outputted directly without using scaler. If I understand it right, the setResolution API sets the final desired resolution and setSensorMode API sets the camera mode. However, I am unable to verify whether the camera mode set for a particular resolution using this API actually works or not. Please find the code snippet below :

bool  execute()

    using namespace Argus;
    // Initialize the preview window and EGL display.    
    Window &window = Window::getInstance(); 

    // Initialize the Argus camera provider.
    UniqueObj<CameraProvider> cameraProvider(CameraProvider::create());

    // Get the ICameraProvider interface from the global CameraProvider.
    ICameraProvider *iCameraProvider = interface_cast<ICameraProvider>(cameraProvider);
    if (!iCameraProvider)
        ORIGINATE_ERROR("Failed to get ICameraProvider interface");

    // Get the camera devices.
    std::vector<CameraDevice*> cameraDevices;

    if (cameraDevices.size() < 2)
        ORIGINATE_ERROR("Must have at least 2 sensors available");

    CameraDevice *cameraDevice = cameraDevices[0];
    ICameraProperties *iCameraProperties = interface_cast<ICameraProperties>(cameraDevice);
    if (!iCameraProperties)
        ORIGINATE_ERROR("Failed to get ICameraProperties interface");

    // Create the capture session, AutoControl will be based on what the 1st device sees.
    UniqueObj<CaptureSession> captureSessionCamera0(iCameraProvider->createCaptureSession(cameraDevices[0]));
    ICaptureSession *iCaptureSessionCamera0 = interface_cast<ICaptureSession>(captureSessionCamera0);
    if (!iCaptureSessionCamera0)
        ORIGINATE_ERROR("Failed to get capture session interface");

    std::vector<Argus::SensorMode*> sensorModes;

    // Get the sensor mode to determine the video output stream resolution.   


    if (sensorModes.size() == 0)
	ORIGINATE_ERROR("Failed to get sensor modes");

    ISensorMode *iSensorMode = interface_cast<ISensorMode>(sensorModes[0]);
    if (!iSensorMode)
	ORIGINATE_ERROR("Failed to get sensor mode interface");

    // Create stream settings object and set settings common to both streams.
    UniqueObj<OutputStreamSettings> streamSettingsCamera0(iCaptureSessionCamera0->createOutputStreamSettings());
    IOutputStreamSettings *iStreamSettingsCamera0 = interface_cast<IOutputStreamSettings>(streamSettingsCamera0);
    if (!iStreamSettingsCamera0)
        ORIGINATE_ERROR("Failed to create OutputStreamSettings");

    // Create egl streams
    UniqueObj<OutputStream> streamLeft(iCaptureSessionCamera0->createOutputStream(streamSettingsCamera0.get()));
    IStream *iStreamLeft = interface_cast<IStream>(streamLeft);
    if (!iStreamLeft)
        ORIGINATE_ERROR("Failed to create left stream");

    UniqueObj<OutputStream> videoStreamCamera0(iCaptureSessionCamera0->createOutputStream(streamSettingsCamera0.get()));
    IStream *iVideoStreamCamera0 = interface_cast<IStream>(videoStreamCamera0);
    if (!iVideoStreamCamera0)
        ORIGINATE_ERROR("Failed to create video stream");

    // Create a request

    UniqueObj<Request> requestCamera0(iCaptureSessionCamera0->createRequest());	

   IRequest *iRequestCamera0 = interface_cast<IRequest>(requestCamera0);
    if (!iRequestCamera0)
        ORIGINATE_ERROR("Failed to create Request");

    // Enable both streams in the request.    
    ISourceSettings *iSourceSettingsCamera0 = interface_cast<ISourceSettings>(iRequestCamera0->getSourceSettings());
    if (!iSourceSettingsCamera0)
        ORIGINATE_ERROR("Failed to get ISourceSettings interface");

    // Submit capture for the specified time.
    if (iCaptureSessionCamera0->repeat(requestCamera0.get()) != STATUS_OK)
        ORIGINATE_ERROR("Failed to start repeat capture request for preview");

    // Stop the capture requests and wait until they are complete.

    // Disconnect Argus producer from the EGLStreams (and unblock consumer acquire).

   // Shut down Argus.

   // Cleanup the EGL display

    return true;

}; // namespace ends here

int main(int argc, char** argv )
   if (!ArgusSamples::execute())
      return EXIT_FAILURE;
   return EXIT_SUCCESS;

Kindly let me know if this is the way to go about setting the camera mode to output 1080p directly. Is there a way to verify whether the change has reflected ?


Hi lamegeorge,

This setResolution is for EGLStreamProducer but not camera directly.

What kind of camera are you using? CSI or a usb camera?

Hi WayneWWW,

We are using Sony IMX274 CSI camera. Kindly let me know what ‘setSensorMode’ API does ? Is it sufficient to achieve what is intended using this API. If not then what can be done?


Hi lamegeorge,

Your guess is correct. RequestImpl::setSensorMode would set a mode which is supported by your camera.

If it is IMX274, 1080p should be supported.

There is a sample for setSensorMode, please refer to /argus/samples/bayerAverageMap/main.cpp