Hi Guys,
I am trying to set the pixel format for the output camera stream using the method setPixelFormat. When I set the pixel format to PIXEL_FMT_YCbCr_420_888 I do not face any issue. However, when I try to set it to PIXEL_FMT_YCbCr_444_888 I get the following error :
execute:353 Failed to create left stream
Please find the code snippet which gives me error below:
bool execute()
{
using namespace Argus;
// Initialize the preview window and EGL display.
Window &window = Window::getInstance();
PROPAGATE_ERROR(g_display.initialize(window.getEGLNativeDisplay()));
// 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;
iCameraProvider->getCameraDevices(&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.
iCameraProperties->getSensorModes(&sensorModes);
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");
// iStreamSettingsCamera0->setPixelFormat(PIXEL_FMT_YCbCr_420_888);
iStreamSettingsCamera0->setPixelFormat(PIXEL_FMT_YCbCr_444_888);
iStreamSettingsCamera0->setResolution(Argus::Size(1920,1080));
// Create egl streams
iStreamSettingsCamera0->setCameraDevice(cameraDevices[0]);
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.
iRequestCamera0->enableOutputStream(streamLeft.get());
ISourceSettings *iSourceSettingsCamera0 = interface_cast<ISourceSettings>(iRequestCamera0->getSourceSettings());
if (!iSourceSettingsCamera0)
ORIGINATE_ERROR("Failed to get ISourceSettings interface");
iSourceSettingsCamera0->setFrameDurationRange(Argus::Range<uint64_t>(1e9/DEFAULT_FPS));
// 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.
iCaptureSessionCamera0->stopRepeat();
iCaptureSessionCamera0->waitForIdle();
iStreamLeft->disconnect();
// Shut down Argus.
cameraProvider.reset();
// Cleanup the EGL display
PROPAGATE_ERROR(g_display.cleanup());
return true;
}
}; // namespace ends here
int main(int argc, char** argv )
{
if (!ArgusSamples::execute())
return EXIT_FAILURE;
return EXIT_SUCCESS;
}