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...