It sounds like your camera uses a Bayer filter to produce color images. This means that in front of each pixel on the sensor, there's a color filter—either red (R), green (G), or blue (B). For example, if your camera's Bayer pattern is RGGB, in the first row, you'd have pixels arranged as RGRGRG..., and in the second row as GBGBGB... and so on. When you perform 2x2 binning, you're essentially averaging the values of pixels with different colors, which results in a monochrome (grey) image.

To capture color images, you should avoid using binning. After capturing the image without binning, you'll need to debayer the image to reconstruct the full color. Debayering is the process of interpolating the Bayer matrix to produce a color image. This should give you color images similar to those you obtain when using libcamera directly on the Raspberry Pi.

Read More...

Joaquin Barcelo replied to the topic 'INDI LibCamera Driver' in the forum. 1 year ago

@Anjo you did an impressive work. Thanks.

If I understand correctly your code, libcamera driver resolution is not updated with resolution update messages coming from indi server

Maybe adding/editing the following lines could help:

bool INDILibCamera::Connect()
{
    try
    {

        ...

        // stillOptions->width = 1920;
        // stillOptions->height = 1080;

        // Get resolution from indi:ccd (whatever is settled when we are connecting), and update libcamera driver resolution
        stillOptions->width = PrimaryCCD.getXRes();
        stillOptions->height = PrimaryCCD.getYRes();

       ...

bool INDILibCamera::UpdateCCDFrame(int x, int y, int w, int h)
{
    ...

    // Always set BINNED size
    Streamer->setSize(subW, subH);
    
    // Set libcamera resolution as defined in update message
    auto stillOptions = m_StillApp->GetOptions();   
    stillOptions->width = w;
    stillOptions->height = h;

   ...


Read More...

Joaquin Barcelo replied to the topic 'INDI LibCamera Driver' in the forum. 1 year ago

Hello, I'm very impressed with this thread.

Regarding the options parsing, It seems that option variable has to be created in the context of Libcamera Encoder(). ( I'm learning and my C++ is rusty so I apologize in advance)

The following code snipet works for me:

#include <string>
#include <sstream>
#include <vector>

using namespace std;

vector<string> split(string str, char delimiter) {
    vector<string> out;
    stringstream ss(str);
    string token;
    while(getline(ss, token, delimiter)) {
        out.push_back(token);
    }
    return out;
}

int getArgv(char** argv, string str) {
    vector<string> splitStr = split(str, ' ');
    for (long unsigned int i = 0; i < splitStr.size(); i++) {
        argv[i] = new char[splitStr[i].length() + 1];
        strcpy(argv[i], splitStr[i].c_str());
    }
    return splitStr.size();
}


INDILibCamera::INDILibCamera()
{
    // char str1[] = "-n -t 0 -o -\n --awbgains 1,1 --immediate -v 2";
    char str1[] = "-n -t 0 -o -\n --awbgains 1,1  -v 2 --width 1920 --height 1080";
    char *argv[64] = {};
    int argc = getArgv(argv, str1);
    
    
    setVersion(LIBCAMERA_VERSION_MAJOR, LIBCAMERA_VERSION_MINOR);
    signal(SIGBUS, default_signal_handler);
    //m_StillApp.reset(new LibcameraApp(std::make_unique<StillOptions>()));
    
    LibcameraEncoder *lib_cam_enc = new LibcameraEncoder();
    VideoOptions *options = lib_cam_enc->GetOptions();
    

    if (options->Parse(argc, argv))
    {
        if (options->verbose >= 2)
            options->Print();
    }


    m_StillApp.reset(lib_cam_enc);
    m_VideoApp.reset(m_StillApp.get());
}


Read More...