×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

INDI LibCamera Driver

  • Posts: 3
  • Thank you received: 1
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:
<code>
#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 = new char[splitStr.length() + 1];
strcpy(argv, splitStr.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());
}
</code>

Note: Because of my rusty c++, I used ChatGPT to create functions getArgv() and split(). Is that ok?
The following user(s) said Thank You: Jasem Mutlaq
Last edit: 1 year 4 months ago by Joaquin Barcelo. Reason: Adding note about how functions where created
1 year 4 months ago #89152

Please Log in or Create an account to join the conversation.

  • Posts: 27
  • Thank you received: 4
@ANJO
It seems some Python dependencies are broken. I installed pycamera2 with "sudo apt-get" and not with pip:
sudo apt-get python3-picamera2

The "simplejpeg" library that fails in your system comes from package "python3-simplejpeg" on my Raspberry Pi. Maybe you need to reinstall it too with "sudo apt-get". Maybe you will also need an upgrade/update of the whole system.
1 year 4 months ago #89169

Please Log in or Create an account to join the conversation.

  • Posts: 124
  • Thank you received: 13

Replied by Outta on topic INDI LibCamera Driver

I do not think anyone can mind ChatGPT or other AI, I even use Copilot officially in my work. This is the future, better get used to it before rather than later :)
1 year 4 months ago #89177

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

I got it to work by commenting out a few imports and places. But yeah, it's probably pip vs apt. In particular as I use pip with venv.
1 year 4 months ago #89181

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

OK, the most recent commit does:

- fix dng files
- fix fits processing
- added "gain" control
- added bits per pixel (8) in image info
- should set bounds correctly (can't subframe yet, though, as I'm not sure what should be set to what)
- consolidates setting of options
- replace use of mmap when putting together the image, this fixes a crash that will occur randomly

Issues and TODOs:
- FITS files are still very dark, no idea why.
- gain apparently only works with jpeg (still and stream), not raw files. At least it doesn't show any changes
- for the correct "main" sizes, we should probably have a selection
- for subframes I think we need to use "rio" in the 0...1 range, but I'm not sure on what base
- there should be brightness etc controls, like in v4l2 but the creation there seems to be very dynamic. not sure if this applies here, too.

In general, I found playing with the command line apps pretty inconsistent.

On the bright side, the IMX290 seems to have 7s exposures which is a lot more than the usb imx 290 cam has (156ms or so, the rest with stacking).
The following user(s) said Thank You: Jasem Mutlaq
1 year 4 months ago #89182

Please Log in or Create an account to join the conversation.

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

Awesome progress Anjo! Do you think you can submit a PR now to INDI so that we can perhaps make this available for more users to test?
1 year 4 months ago #89183

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

@Jasem can you give me some pointers on how the new properties are supposed to be used?
1 year 4 months ago #89184

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

Here you go, but I won't be doing cosmetics just yet. There's just too much stuff I'm not sure if it's ok or not.

github.com/indilib/indi-3rdparty/pull/697
1 year 4 months ago #89186

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

Here's some more properties, I guess this can be used to create them dynamically. I think it's "low,high,current":

>>> pprint.pprint(picam2.camera_controls)
{'AeConstraintMode': (0, 3, 0),
'AeEnable': (False, True, None),
'AeExposureMode': (0, 3, 0),
'AeMeteringMode': (0, 3, 0),
'AnalogueGain': (1.0, 16.0, None),
'AwbEnable': (False, True, None),
'AwbMode': (0, 7, 0),
'Brightness': (-1.0, 1.0, 0.0),
'ColourCorrectionMatrix': (-16.0, 16.0, None),
'ColourGains': (0.0, 32.0, None),
'Contrast': (0.0, 32.0, 1.0),
'ExposureTime': (0, 66666, None),
'ExposureValue': (-8.0, 8.0, 0.0),
'FrameDurationLimits': (33333, 120000, None),
'NoiseReductionMode': (0, 4, 0),
'Saturation': (0.0, 32.0, 1.0),
'ScalerCrop': (libcamera.Rectangle(0, 0, 0, 0),
libcamera.Rectangle(65535, 65535, 65535, 65535),
libcamera.Rectangle(0, 0, 0, 0)),
'Sharpness': (0.0, 16.0, 1.0)}
1 year 4 months ago #89187

Please Log in or Create an account to join the conversation.

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

You can create them using XML skeleton file or directly in the source using INDI::PropertyNumber. I you have static number of properties that will be always there then you can declare in the header INDI::PropertyNumber ControlsNP {10} for example for 10 controls and then in initProperties you define them
1 year 4 months ago #89190

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

I'd rather prefer something like the V4L driver does, ie auto create menus and controls, but I guess there's no corresponding API for the creation of visible names.
1 year 4 months ago #89192

Please Log in or Create an account to join the conversation.

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

And finally, controls for about everything (brightness, f-stops, contrast, awb etc).

It just doesn't look like the images get better when you play around with them.
Last edit: 1 year 4 months ago by Anjo.
1 year 4 months ago #89202
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 1.229 seconds