Libargus Invalid BufferType Error

Hello everyone,

I wanted to implement a program that creates request, captures image and wrote onto buffer. Then I will read the buffer and create OpenCV mat. I haven’t done yet this part yet. I use libargus , IMX577 with MIPI connector and Jetson Xavier AGX.
“I can execute nvgstcapture-1.0 without no problem! So there is no problem with my cameras and settings.”

My code is below.

#include <iostream>
#include <vector>
#include "Argus/Argus.h"

using namespace std;
using namespace Argus;

int main(){

	// Create Camera Provider
	UniqueObj<CameraProvider> cameraProvider(CameraProvider::create());
	ICameraProvider* iCameraProvider = interface_cast<ICameraProvider>(cameraProvider);

	vector<CameraDevice *> devices;

	// Get Devices
	iCameraProvider->getCameraDevices(&devices);

	// Create Capture Session
	UniqueObj<CaptureSession> captureSession(iCameraProvider->createCaptureSession(devices[0]));
	ICaptureSession* iCaptureSession = interface_cast<ICaptureSession>(captureSession);
	
	// Create Output Stream Settings
	UniqueObj<OutputStreamSettings> outputStreamSettings(iCaptureSession->createOutputStreamSettings(Argus::STREAM_TYPE_BUFFER));
	IOutputStreamSettings * iOutputStreamSettings = interface_cast<IOutputStreamSettings>(outputStreamSettings);
	iOutputStreamSettings->setCameraDevice(devices[0]);

	// Create Buffer Output Stream Settings
	IBufferOutputStreamSettings * iBufferOutputStreamSettings = interface_cast<IBufferOutputStreamSettings>(outputStreamSettings);
	iBufferOutputStreamSettings->setMetadataEnable(true);

	// Create Output Stream - Buffer Output Stream
	UniqueObj<OutputStream> outputStream(iCaptureSession->createOutputStream(outputStreamSettings.get()));
	IBufferOutputStream * iBufferOutputStream = interface_cast<IBufferOutputStream>(outputStream);
	
	// Create Buffer Settings - Buffer
	UniqueObj<BufferSettings> bufferSettings(iBufferOutputStream->createBufferSettings());
	UniqueObj<Buffer> buffer(iBufferOutputStream->createBuffer(bufferSettings.get()));
	IBuffer * iBuffer = interface_cast<IBuffer>(buffer);

	// Create Request
	UniqueObj<Request> request(iCaptureSession->createRequest());
	IRequest * iRequest = interface_cast<IRequest>(request);

	// Capture
	iCaptureSession->capture(request.get());

	return 0;

}

When I run my program on gdb, I get these results. (I deleted [New Thread 0x…] lines for goodness)

Starting program: /home/nvidia/argus_test/main 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
nvbuf_utils: Could not get EGL display connection
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module0
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module1
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module2
OFParserListModules: module list: /proc/device-tree/tegra-camera-platform/modules/module3
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
NvPclHwGetModuleList: WARNING: Could not map module to ISP config string
NvPclHwGetModuleList: No module data found
[New Thread 0x7f8effd1d0 (LWP 26971)]
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
CAM: serial no file already exists, skips storing again---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
(NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
(NvCamV4l2) Error ModuleNotPresent:  (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
(NvOdmDevice) Error ModuleNotPresent:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclStateControllerOpen: Failed ImagerGUID 4. (error 0xA000E)
NvPclOpen: PCL Open Failed. Error: 0xf
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 582)
SCF: Error BadParameter:  (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 437)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 303)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function getSource(), line 466)
Acquiring SCF Camera device source via index 1 has failed. ---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
(NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
(NvCamV4l2) Error ModuleNotPresent:  (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
(NvOdmDevice) Error ModuleNotPresent:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclStateControllerOpen: Failed ImagerGUID 1. (error 0xA000E)
NvPclOpen: PCL Open Failed. Error: 0xf
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 582)
SCF: Error BadParameter:  (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 437)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 303)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function getSource(), line 466)
Acquiring SCF Camera device source via index 2 has failed. ---- imager: Found override file [/var/nvidia/nvcam/settings/camera_overrides.isp]. ----
(NvCamV4l2) Error ModuleNotPresent: V4L2Device not available (in /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function findDevice(), line 256)
(NvCamV4l2) Error ModuleNotPresent:  (propagating from /dvs/git/dirty/git-master_linux/camera/utils/nvcamv4l2/v4l2_device.cpp, function initialize(), line 60)
(NvOdmDevice) Error ModuleNotPresent:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 107)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclStateControllerOpen: Failed ImagerGUID 2. (error 0xA000E)
NvPclOpen: PCL Open Failed. Error: 0xf
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 582)
SCF: Error BadParameter:  (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 437)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 303)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function getSource(), line 466)
Acquiring SCF Camera device source via index 3 has failed. [New Thread 0x7f8e7fc1d0 (LWP 26972)]
[New Thread 0x7f8dffb1d0 (LWP 26973)]
CAM: serial no file already exists, skips storing againNvIspAfConfigParamsSanityCheck: Error: positionWorkingHigh is not larger than positionWorkingLow positionWorkingHigh = 0, positionWorkingLow = 0

NvIspAfConfigParamsSanityCheck: Error: positionWorkingHigh is not larger than positionWorkingLow positionWorkingHigh = 0, positionWorkingLow = 0


(Argus) Error InvalidState: Invalid BufferType (in src/api/BufferOutputStreamImpl.cpp, function checkTypeCompatibility(), line 97)
(Argus) Error InvalidState:  (propagating from src/api/CaptureSessionImpl.cpp, function createBufferOutputStream(), line 751)
(Argus) Error InvalidState:  (propagating from src/api/CaptureSessionImpl.cpp, function createOutputStreamInternal(), line 650)

Thread 1 "main" received signal SIGSEGV, Segmentation fault.
0x0000005555558b78 in main () at /home/nvidia/argus_test/src/main.cpp:37
37              UniqueObj<BufferSettings> bufferSettings(iBufferOutputStream->createBufferSettings());

I researched and I couldn’t find any similar problems. I read the documents on “Libargus Camera API” and found nothing besides “BUFFER_TYPE_EGL_IMAGE” and “BUFFER_TYPE_NONE”. “BUFFER_TYPE_NONE” is default value of bufferOutputStream class and that is not working. I don’t want to use EGL Streaming. I just want to get my capture data to a buffer and then I will process it.

First, I want to solve BufferType problem. Then I want to understand the part before BufferType error lines in gdb results.

Thank you so much!

Hi,
For mapping the buffer to cv::Mat, please refer to this patch:
NVBuffer (FD) to opencv Mat - #6 by DaneLLL