I'm trying to capture images with a Raspberry Pi Camera V2.1 on a Raspberry Pi 4B using .NET 7. I've set up my code to capture an image with the following code:
using Iot.Device.Media;
VideoConnectionSettings settings = new VideoConnectionSettings(busId: 0, captureSize: (640, 480), pixelFormat: PixelFormat.JPEG);
using VideoDevice device = VideoDevice.Create(settings);
device.Capture("image.jpg");
However, when I run this code, the images I get are green-tinted. I've confirmed that the camera itself works properly by testing it with Python's PiCamera library.
I was expecting the captured images to look similar to the ones captured using Python's PiCamera library, which had accurate color representation. To troubleshoot the issue, I tried adjusting the PixelFormat parameter to other values, such as YUYV, but I couldn't get it to work. I also checked the connection between the camera and the Raspberry Pi, and it seems to be fine.
Here's an example of one of the green-tinted images I captured. As you can see, the image has a strong green color cast. I'm not sure what could be causing this, as I followed this tutorial exactly and it worked for the author. Is there something I'm missing or doing wrong? Are there any additional settings I need to adjust, or is there a different library or approach I should be using? Any help would be appreciated."
Edit: A commenter pointed out that the tutorial I followed was for .NET 6, not .NET 7. I tried using .NET 6 and published a self-contained app to test the code again, but the problem persists.