Processing multiple camera images with SoftISP

I’m trying to process and display output from two cameras after tonemapping for human vision.
When displaying, the output from the first camera is fine, but the second is simply black. See the attached screenshot.

I’m using SF3324-100 cameras on the DRIVE AGX Xavier dev kit.
No errors are returned.

What am I doing wrong? Do I need to run the SoftISP multiple times for multiple camera images?

Output:

nvmedia isc: GetCameraPowerControlLevel: 936: Camera power control library: NVCCP
Max96712 Rev 2 detected!
MAX96712: Enable periodic AEQ on Link 0
MAX96712: Enable periodic AEQ on Link 1
MAX96705: Pre-emphasis set to 0xaa
Sensor AR0231 RCCB Rev7 detected!
Sensor AR0231 RCCB Rev7 detected!

My code simplified and with error checking ommitted:

dwContextHandle_t sdk;
dwSALHandle_t sal;
dwSoftISPHandle_t isp;

dwSensorHandle_t sensor;
cudaStream_t stream;
dwImageProperties properties{};

dwImageHandle_t rcb_image;
dwImageCUDA* rcb_cuda;

dwImageHandle_t rgba_image;
dwImageCUDA* rgba_cuda;

dwImageStreamerHandle_t streamer;

void render(void* out)
{
	dwCameraFrameHandle_t frame;
	dwSensorCamera_readFrame(&frame, 0, DW_TIMEOUT_INFINITE, sensor);

	dwImageHandle_t image;
	dwSensorCamera_getImageAsync(&image, DW_CAMERA_OUTPUT_CUDA_RAW_UINT16, frame);
	cudaStreamSynchronize(stream);

	dwImageCUDA* image_cuda;
	dwImage_getCUDA(&image_cuda, image);

	dwSoftISP_bindInputRaw(image_cuda, isp);
	dwSoftISP_setProcessType(DW_SOFTISP_PROCESS_TYPE_DEMOSAIC | DW_SOFTISP_PROCESS_TYPE_TONEMAP, isp);
	dwSoftISP_processDeviceAsync(isp);
	dwImageStreamer_producerSend(rgba_image, streamer);

	dwImageHandle_t cpu_frame;
	dwImageStreamer_consumerReceive(&cpu_frame, DW_TIMEOUT_INFINITE, streamer);

	dwImageCPU* cpu_image;
	dwImage_getCPU(&cpu_image, cpu_frame);

	std::memcpy(out, cpu_image->data[0], properties.width * properties.height);

	dwImageStreamer_consumerReturn(&cpu_frame, streamer);
	dwImageStreamer_producerReturn(nullptr, DW_TIMEOUT_INFINITE, streamer);
	dwSensorCamera_returnFrame(&frame);
}

void start()
{
	dwInitialize(&sdk, DW_VERSION, nullptr);
	dwSAL_initialize(&sal, sdk);
	cudaStreamCreate(&stream);

	dwSensorParams params;
	params.protocol = "camera.gmsl";
	params.parameters = "output-format=raw,camera-type=ar0231-rccb-bae-sf3324,camera-group=a,camera-count=2";
	params.auxiliarydata = nullptr;

	dwSAL_createSensor(&sensor, params, sal);

	dwCameraProperties sensor_properties;
	dwSensorCamera_getSensorProperties(&sensor_properties, sensor);

	dwSensorCamera_setCUDAStream(stream, sensor);
	dwSensor_start(sensor);

	// Pass twice the width to ISP for processing 2 camera pictures
	sensor_properties.resolution.x *= 2;

	dwSoftISPParams isp_params;
	dwSoftISP_initParamsFromCamera(&isp_params, &sensor_properties);
	dwSoftISP_initialize(&isp, &isp_params, sdk);

	dwImageProperties demosaic_props;
	dwSoftISP_getDemosaicImageProperties(&demosaic_props, isp);

	dwImage_create(&rcb_image, demosaic_props, sdk);
	dwImage_getCUDA(&rcb_cuda, rcb_image);

	dwSoftISP_bindOutputDemosaic(rcb_cuda, isp);

	// Output image
	properties.format = DW_IMAGE_FORMAT_RGBA_UINT8;
	properties.type = DW_IMAGE_CUDA;
	properties.width = demosaic_props.width;
	properties.height = demosaic_props.height;

	dwImage_create(&rgba_image, properties, sdk);
	dwImage_getCUDA(&rgba_cuda, rgba_image);
	dwSoftISP_bindOutputTonemap(rgba_cuda, isp);
	dwImageStreamer_initialize(&streamer, &properties, DW_IMAGE_CPU, sdk);
}

Screenshot: https://i.vgy.me/pu2uis.png

Dear raul.tambre,

I believe you referred DriveWorks camera_gmsl_raw source code for this topic.
If there are two cameras, need to run the sample twice. Please help to check it.
So as you said, need to run the SoftISP multiple times for multiple camera images.
And please refer to drivenet_ncameras source code for this topic. Thanks.

Thank you for the fast response Steve!
The drivenet_ncameras indeed showcases what I want to do.