cudaBayerDemosaic sample gives wrong results

When I build and run the argus samples on my nx, for cudaBayerDemosaic, i get this:

release notes say:

Release 0.97 (08/10/2018)

samples installed with sudo apt install nvidia-l4t-jetson-multimedia-api

I have not tested on my Nano, and the camera is fine with nvarguscamerasrc.

Also, unrelated, but I did notice (or rather the compiler did) a fallthrough in printCUDAEGLFrame

        colorFormatString = "RGBA";
        colorFormatString = "S16 Bayer RGGB";

Hi Michael,
Thank you very much for the report!

Is this problem related to CUDA GDB (since it’s reported in the CUDA GDB forum branch)? Neither post nor the screenshot mentions it.

If it’s not CUDA GDB related, please consider different forum branch, e.g.: Jetson & Embedded Systems - NVIDIA Developer Forums

If it’s related to CUDA GDB, please provide more details.

1 Like

Sorry, I posted In the wrong forum. Can you move it to the Jetson NX forum?

Moving this to the Jetson NX forum.

What’s the problem? Does argus_camera get normal image?

Yes. argus_camera looks fine (below is how it should look).

I’ve double checked the sample has not been modified by building from a fresh copy of the samples. Setup is using an NX with JetPack 4.5 and two imx219 cameras.

Interestingly, the example works fine on Nano with imx477, so I would guess it’s NX or imx219 specific?

Sorry, I still not clear the problem with imx219.
Does the color have problem?


Yes. The problem is the image is supposed to look like below with argus_camera, not above. The demosaicing example does not produce a usable image.

So the problem is imx219 have preview problem.
What’s the imx219 from?

Sorry for not being clear, IMX219 is Raspberry Pi Camera v2. I think Waveshare is the manufacturer of this specific one. The camera works fine with nvarguscamerasrc and other apps. Only cudaBayerDemosaic doesn’t work.

Does it sensor specific?

1 Like

I just try on imx274 without problem. I think it could be the sensor configure problem. Maybe the gain/exposure setting cause it.

1 Like


Gain and exposure should be at the defaults. I tried with an IMX477 on Nano and while not perfect, the result isn’t blown out either. Black level is wrong but the rest is fine. Looks like the values returned by IMX219 are wildly not in the same range.

There is a comment in the .cu saying:

    // Signed 16-bit Bayer maps 1<<14 to white.
    const float whitePoint = 1<<14;

This does not appear to be correct for IMX219. I got decent results in OpenCV reinterpreting the data* as unsigned rather than signed. Otherwise I get this “black sun” effect. Likewise black somehow becomes white. It might be worth it testing with imx219 and putting a note in the code, given the popularity of that sensor. Thanks for your help. The sensor I’m working with is IMX477 anyway, so I can work with this!