Getting error when trying to instanciate a camera provider with Argus

Hi all,

I am using a custom camera with an imager AR0820 connected with GMSL2 MIPI CSI interface, i am able to capture using nvarguscamerasrc using the CLI

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM), width=(int)3840, height=(int)2160, format=(string)NV12, framerate=(fraction)30/1' ! nvvidconv ! queue ! xvimagesink

And i am able to capture using samples from /home/jetson/jetson_multimedia_api/argus/samples, but know i want create a custom application using LibArgus, so i just try to to instanciate a camera provider with Argus with the following program :

#include <stdio.h>
#include <Argus/Argus.h>

int main() {
    
    Argus::UniqueObj<Argus::CameraProvider> cameraProvider(Argus::CameraProvider::create());


    return 0;
}

The project include :
main.cpp : A program to instanciate the camera provider
Argus : The folder including Argus.h and all sources files of the API

I’ve executed the following CLI :

g++ *.cpp -o prog -I jetson_multimedia_api/argus/include -L /usr/lib/aarch64-linux-gnu/tegra -lnvargus

I could compile without any errors, but when i execute ./prog i had the following output :

OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: No override file found. ----
LSC: LSC surface is not based on full res!

I am wondering if i’m missing anything when i compiled my program ? Why i couldn’t create a camera provider ?

Thanks

Hi,
You can refer to these samples:

/usr/src/jetson_multimedia_api/samples/09_camera_jpeg_capture
/usr/src/jetson_multimedia_api/samples/10_camera_recording

Please try to build/run these samples successfully. So that you can refer to the samples for further development.

Hi @DaneLLL,

I’ve tested those samples, the main.cpp is compiled using too much of dependency and linked with a lot of libraries, in my case i just wanna to make a simple program which instanciate a camera provider and avoiding this output :

OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: No override file found. ----
LSC: LSC surface is not based on full res!

Can you please suggest mee a g++ command line with linker and includes arguments to create a camera provider ?

Thank you

Hi,
We would suggest start with this:

/usr/src/jetson_multimedia_api/samples/09_camera_jpeg_capture

And remove the unnecessary part. It is basic Argus and not much additional code.

Hi all,

i was able to execute the oneShot sample without using any Cmake or Makefile provided in the jetson_multimedia_api, but only with one g++ command line, i want to do this because i’m not very familiar with Cmake and Makefile in C++ project and i wanted only to test the LibArgus API, so there are the steps i did to be able to execute oneShot :

  1. You must have the following projects architecture :
    → jetson_multimedia_api
    → main.cpp

  2. Copy this script in your jetson

/*
 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  * Neither the name of NVIDIA CORPORATION nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdio.h>
#include <stdlib.h>
#include <Argus/Argus.h>
#include <EGLStream/EGLStream.h>

#define PRODUCER_PRINT(...) printf("PRODUCER: " __VA_ARGS__)


#define EXIT_IF_NULL(val,msg)   \
        {if (!val) {printf("%s\n",msg); return EXIT_FAILURE;}}
#define EXIT_IF_NOT_OK(val,msg) \
        {if (val!=Argus::STATUS_OK) {printf("%s\n",msg); return EXIT_FAILURE;}}

#ifdef ANDROID
#define FILE_PREFIX "/sdcard/DCIM/"
#else
#define FILE_PREFIX ""
#endif

/*
 * Program: oneShot
 * Function: Capture a single image from a camera device and write to a JPG file
 * Purpose: To demonstrate the most simplistic approach to getting the Argus Framework
 *          running, submitting a capture request, retrieving the resulting image and
 *          then writing the image as a JPEG formatted file.
 */

int main(int argc, char** argv)
{


    const uint64_t FIVE_SECONDS_IN_NANOSECONDS = 5000000000;

    /*
     * Set up Argus API Framework, identify available camera devices, and create
     * a capture session for the first available device
     */


    // Create the camera provider object
    Argus::UniqueObj<Argus::CameraProvider> cameraProvider(Argus::CameraProvider::create());
    Argus::ICameraProvider *iCameraProvider =
        Argus::interface_cast<Argus::ICameraProvider>(cameraProvider);
    EXIT_IF_NULL(iCameraProvider, "Cannot get core camera provider interface");
    printf("Argus Version: %s\n", iCameraProvider->getVersion().c_str());


    // Get the camera device
    std::vector<Argus::CameraDevice*> cameraDevices;
    iCameraProvider->getCameraDevices(&cameraDevices);
    if (cameraDevices.size() == 0)
        printf("No cameras available");

    // Camera properties of the first camera
    Argus::ICameraProperties *iCameraProperties = Argus::interface_cast<Argus::ICameraProperties>(cameraDevices[0]);
    if (!iCameraProperties)
        printf("Failed to get ICameraProperties interface");


    // Camera sensor
    Argus::ISensorMode *iSensorMode;
    std::vector<Argus::SensorMode*> sensorModes;
    //iCameraProperties->getBasicSensorModes(&sensorModes);
    iCameraProperties->getAllSensorModes(&sensorModes);

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

    PRODUCER_PRINT("Available Sensor modes :\n");
    for (uint32_t i = 0; i < sensorModes.size(); i++) {
        iSensorMode = Argus::interface_cast<Argus::ISensorMode>(sensorModes[i]);
        Argus::Size2D<uint32_t> resolution = iSensorMode->getResolution();
        PRODUCER_PRINT("[%u] W=%u H=%u\n", i, resolution.width(), resolution.height());
    }

    // Create a capture session
    Argus::Status status;
    Argus::UniqueObj<Argus::CaptureSession> captureSession(
        iCameraProvider->createCaptureSession(cameraDevices[0], &status));
    EXIT_IF_NOT_OK(status, "Failed to create capture session");

    // Get ICaptureSession interface
    Argus::ICaptureSession *iCaptureSession = Argus::interface_cast<Argus::ICaptureSession>(captureSession);
    if (!iCaptureSession)
        printf("\nFailed to get ICaptureSession interface \n");

    Argus::ICaptureSession *iSession =
        Argus::interface_cast<Argus::ICaptureSession>(captureSession);
    EXIT_IF_NULL(iSession, "Cannot get Capture Session Interface");


    
    /*
     * Creates the stream between the Argus camera image capturing
     * sub-system (producer) and the image acquisition code (consumer).  A consumer object is
     * created from the stream to be used to request the image frame.  A successfully submitted
     * capture request activates the stream's functionality to eventually make a frame available
     * for acquisition.
     */

    Argus::UniqueObj<Argus::OutputStreamSettings> streamSettings(
        iSession->createOutputStreamSettings(Argus::STREAM_TYPE_EGL));

    Argus::IEGLOutputStreamSettings *iEGLStreamSettings =
        Argus::interface_cast<Argus::IEGLOutputStreamSettings>(streamSettings);
    EXIT_IF_NULL(iEGLStreamSettings, "Cannot get IEGLOutputStreamSettings Interface");
    iEGLStreamSettings->setPixelFormat(Argus::PIXEL_FMT_YCbCr_420_888);
    iEGLStreamSettings->setResolution(iSensorMode->getResolution());
    iEGLStreamSettings->setMetadataEnable(true);

    Argus::UniqueObj<Argus::OutputStream> stream(
        iSession->createOutputStream(streamSettings.get()));
    EXIT_IF_NULL(stream, "Failed to create EGLOutputStream");

    Argus::UniqueObj<EGLStream::FrameConsumer> consumer(
        EGLStream::FrameConsumer::create(stream.get()));

    EGLStream::IFrameConsumer *iFrameConsumer =
        Argus::interface_cast<EGLStream::IFrameConsumer>(consumer);
    EXIT_IF_NULL(iFrameConsumer, "Failed to initialize Consumer");

    Argus::UniqueObj<Argus::Request> request(
        iSession->createRequest(Argus::CAPTURE_INTENT_STILL_CAPTURE));

    Argus::IRequest *iRequest = Argus::interface_cast<Argus::IRequest>(request);
    EXIT_IF_NULL(iRequest, "Failed to get capture request interface");

    status = iRequest->enableOutputStream(stream.get());
    EXIT_IF_NOT_OK(status, "Failed to enable stream in capture request");

    Argus::ISourceSettings *iSourceSettings =
        Argus::interface_cast<Argus::ISourceSettings>(request);
    EXIT_IF_NULL(iSourceSettings, "Failed to get source settings request interface");
    iSourceSettings->setSensorMode(sensorModes[0]);

    uint32_t requestId = iSession->capture(request.get());
    EXIT_IF_NULL(requestId, "Failed to submit capture request");
    

    /*
     * Acquire a frame generated by the capture request, get the image from the frame
     * and create a .JPG file of the captured image
     */
    Argus::UniqueObj<EGLStream::Frame> frame(
        iFrameConsumer->acquireFrame(FIVE_SECONDS_IN_NANOSECONDS, &status));

    EGLStream::IFrame *iFrame = Argus::interface_cast<EGLStream::IFrame>(frame);
    EXIT_IF_NULL(iFrame, "Failed to get IFrame interface");

    EGLStream::Image *image = iFrame->getImage();
    EXIT_IF_NULL(image, "Failed to get Image from iFrame->getImage()");

    EGLStream::IImageJPEG *iImageJPEG = Argus::interface_cast<EGLStream::IImageJPEG>(image);
    EXIT_IF_NULL(iImageJPEG, "Failed to get ImageJPEG Interface");

    status = iImageJPEG->writeJPEG(FILE_PREFIX "argus_oneShot.jpg");
    EXIT_IF_NOT_OK(status, "Failed to write JPEG");

    printf("Wrote file: " FILE_PREFIX "argus_oneShot.jpg\n");

    // Shut down Argus.
    cameraProvider.reset();

    return EXIT_SUCCESS;
}

  1. Run the command :
$ g++ *.cpp -o oneShot -I jetson_multimedia_api/argus/include -L /usr/lib/aarch64-linux-gnu/tegra -lnvargus_socketclient

$ ./oneShot

Output :

Argus Version: 0.97.3 (multi-process)
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=3840 H=2160
Wrote file: argus_oneShot.jpg

Hope this was helpful, i will add this code into my github account :)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.