×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

INDI LibCamera Driver

  • Posts: 74
  • Thank you received: 11

Replied by Anjo on topic INDI LibCamera Driver

To get this thing off the ground as fast as possible, I would suggest 2 controls in the INDI ui: STILL_OPTIONS and VIDEO_OPTIONS.

Then let the FooOptions->Parse() them. Since doing a full fledged UI is error prone and tiresome and for the moment not needed.
1 year 3 months ago #88684

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, I managed to get somewhere. Make the manager a static and don't destroy it.

github.com/indilib/indi-3rdparty/compare...i-3rdparty:libcamera

Then connect and expose and you get this. I'm not sure of the whole approach of having two apps will work, as it's assuming you need two camera objects? I guess it would make more sense to somehow get at the preview buffer for the still app.
2022-12-01T07:10:44: Driver indi_libcamera_ccd: [17:15:09.937989200] [30612]  INFO RPI raspberrypi.cpp:1414 Registered camera /base/soc/i2c0mux/i2c@1/imx290@1a to Unicam device /dev/media4 and ISP device /dev/media0
2022-12-01T07:11:11: Client 9: new arrival from 192.168.0.113:57503 - welcome!
2022-12-01T07:11:16: Client 10: new arrival from 192.168.0.113:57540 - welcome!
2022-12-01T07:11:27: Driver indi_libcamera_ccd: Running without preview window
2022-12-01T07:11:27: Driver indi_libcamera_ccd: Opening camera...
2022-12-01T07:11:27: Driver indi_libcamera_ccd: [17:15:52.782629828] [30611] FATAL IPAManager ipa_manager.cpp:109 Multiple IPAManager objects are not allowed
2022-12-01T07:11:27: Driver indi_libcamera_ccd: Backtrace:
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: INDILibCamera::workerExposure(std::atomic<bool> const&, float)+0xe4 (/home/pi/astro/indi-3rdparty/indi-libcamera/indi_libcamera.cpp:190)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: void std::__invoke_impl<void, void (INDILibCamera::*&)(std::atomic<bool> const&, float), INDILibCamera*&, std::atomic<bool> const&, float&>(std::__invoke_memfun_deref, void (INDILibCamera::*&)(std::atomic<bool> const&, float), INDILibCamera*&, std::atomic<bool> const&, float&)+0xd0 (/usr/include/c++/10/bits/invoke.h:73)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: std::__invoke_result<void (INDILibCamera::*&)(std::atomic<bool> const&, float), INDILibCamera*&, std::atomic<bool> const&, float&>::type std::__invoke<void (INDILibCamera::*&)(std::atomic<bool> const&, float), INDILibCamera*&, std::atomic<bool> const&, float&>(void (INDILibCamera::*&)(std::atomic<bool> const&, float), INDILibCamera*&, std::atomic<bool> const&, float&)+0x80 (/usr/include/c++/10/bits/invoke.h:96)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: void std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>::__call<void, std::atomic<bool> const&, 0u, 1u, 2u>(std::tuple<std::atomic<bool> const&>&&, std::_Index_tuple<0u, 1u, 2u>)+0xc0 (/usr/include/c++/10/functional:418)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: void std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>::operator()<std::atomic<bool> const&, void>(std::atomic<bool> const&)+0x60 (/usr/include/c++/10/functional:501)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: void std::__invoke_impl<void, std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>&, std::atomic<bool> const&>(std::__invoke_other, std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>&, std::atomic<bool> const&)+0x58 (/usr/include/c++/10/bits/invoke.h:60)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: std::enable_if<is_invocable_r_v<void, std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>&, std::atomic<bool> const&>, void>::type std::__invoke_r<void, std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>&, std::atomic<bool> const&>(std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)>&, std::atomic<bool> const&)+0x58 (/usr/include/c++/10/bits/invoke.h:116)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: std::_Function_handler<void (std::atomic<bool> const&), std::_Bind<void (INDILibCamera::*(INDILibCamera*, std::_Placeholder<1>, float))(std::atomic<bool> const&, float)> >::_M_invoke(std::_Any_data const&, std::atomic<bool> const&)+0x54 (/usr/include/c++/10/bits/std_function.h:292)
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: 
2022-12-01T07:11:27: Driver indi_libcamera_ccd: read EOF
1 year 3 months ago #88685

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

  • Posts: 4
  • Thank you received: 2

Replied by Tyler Pickett on topic INDI LibCamera Driver

> OK, I managed to get somewhere. Make the manager a static and don't destroy it.
> Then connect and expose and you get this. I'm not sure of the whole approach of having two apps will work, as it's assuming you need two camera objects? I guess it would make more sense to somehow get at the preview buffer for the still app.

Each of those App classes instantiates its own camera and camera manager objects, this is why it keeps crashing. libcamera won't allow either of those classes to have multiple instantiations which is why removing the libcamera-apps dependency is a good idea, possibly necessary.

In other news I put together a little program to extract the parameters available from any attached cameras, here's the output for my HQ camera:
<code>$ LIBCAMERA_LOG_LEVELS=ERROR ./cam_list
Found 1 cameras.1: 'imx477' (/base/soc/i2c0mux/i2c@1/imx477@1a)
ScalerCropMaximum: (0, 0)/0x0
ColorFilterArrangement: 0
PixelArrayActiveAreas: [ (8, 16)/4056x3040 ]
PixelArraySize: 4056x3040
Rotation: 180
Location: 2
UnitCellSize: 1550x1550
Model: imx477
</code>

The code: gist.github.com/tpickett66/7c206bb4f3bdf08f0d3c2df39e1ac817
The following user(s) said Thank You: Simon
Last edit: 1 year 3 months ago by Tyler Pickett. Reason: fixed whitespace
1 year 3 months ago #88687

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

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

Removing libcamera-apps dependency is a good idea for the long term. I started with it since it was the easiest to do given what it offers, but it complicates the driver in the end.
The following user(s) said Thank You: Tyler Pickett
1 year 3 months ago #88689

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

  • Posts: 106
  • Thank you received: 33

Replied by Simon on topic INDI LibCamera Driver

Terry, thats great! What about pixel size and binning information? For imx477 value should be 1.55 if I'm correct?
We should get as much information as we can and set it to EKOS.
1 year 3 months ago #88695

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

  • Posts: 123
  • Thank you received: 13

Replied by Outta on topic INDI LibCamera Driver

That data is there as well, in nanometers:

UnitCellSize: 1550x1550

Convertsto 1.55 um! this is really great, good job Tyler. I was looking for that as well, but i only found other sensor information in other objects.
1 year 3 months ago #88696

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

  • Posts: 106
  • Thank you received: 33

Replied by Simon on topic INDI LibCamera Driver

ANYO that great! Im just wandering if we should put code from Connect() method to Setup() method. It feels like better place for it.
I would also try to put cameraManager->stop(); inside Disconnect() method.

Jasem, what do you think about that?
Last edit: 1 year 3 months ago by Simon.
1 year 3 months ago #88698

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

Actually, I'd just copy the LibCameraApp class over instead and change it to have a public GetManager() and merge the Still and Video. It looks like a lot of work to replicate the whole thing into the indi driver and given not a lot of people interested in this seem to be fluent with c++, it would get results much faster.

In fact, if it was me, I'd have preferred to just have it call out to a new process of libcamera-still/video and plug the result into the indi workflow. It would also be way more helpful for other cam types. You could use the same modus operandi for python based cams, raspicams, webcams and the like.

I found this project:

github.com/MMTObservatory/pyINDI

which seems to work with indi, but doesn't have a working CCD driver. You'd need to know what properties actually make a CCD and how it should behave. The core indi CCD does already know this.
1 year 3 months ago #88699

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

Something like this:

github.com/indilib/indi-3rdparty/compare...i-3rdparty:libcamera

Cloning, patching and accessing the cameraManager via only the LibcameraApp allows you to actually take a pic. It still doesn't work as I get:

2022-12-01T16:13:22: [ERROR] Error saving image: unsupported Bayer format

but other than that, things should more or less work.

Here's the instructions: github.com/indilib/indi-3rdparty/compare...6620ca90189bd9b7df3d
Last edit: 1 year 3 months ago by Anjo.
1 year 3 months ago #88701

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

Is there a std:argv(&argc, char *) or something to parse an argument line like the shell would and give you back the argc and argv?

If so, it would be really easy to set up config strings from kstars (if a bit cumbersome as you'd need to know the options). But it would speed up getting the while thing to work as it'd be the same you'd use in the shell.
Last edit: 1 year 3 months ago by Anjo.
1 year 3 months ago #88702

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

Actually... the LibCameraRaw is a LibCameraEncoder, so one could not use the LibCameraStill in favor of that and get the Video options too? Then there would only be one instance of the app running.
1 year 3 months ago #88703

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

  • Posts: 106
  • Thank you received: 33

Replied by Simon on topic INDI LibCamera Driver

ANJO I see your knowledge of C++ and Linux workflow exedes mine by far.

Yes, I remember that I read somewhere in libcamera docs that libcamera-raw can record video and single images.
libcamera-raw -t 1000 --ev -10 --awbgains 1.0,1.0 --gain 1.0 --analoggain 1.0 --sharpness 2.0 --denoise off --rawfull 1 --flush 1 --shutter 9000 --mode 4056:3040:12:P -o test%05d.raw --segment 1

If you have the knowlwdge of how to operate with those single raw frames, that would be total win.

Here is a little code snippet for getting resolution and pixel size from camera->properties(). You can use it inside Connect() method instead hardcoded values:
const ControlList props = cameraManager->cameras()[0]->properties();
 
auto pas = props.get(properties::PixelArraySize);
PrimaryCCD.setResolution(pas->width, pas->height);
LOGF_INFO("PixelArraySize %i x %i", pas->width, pas->height);
 
auto ucs = props.get(properties::UnitCellSize);
auto ucsWidth = ucs->width / 1000.0;
auto ucsHeight = ucs->height / 1000.0;
PrimaryCCD.setPixelSize(ucsWidth, ucsHeight);
LOGF_INFO("UnitCellSize %f x %f", ucsWidth, ucsHeight);
The following user(s) said Thank You: Anjo
Last edit: 1 year 3 months ago by Simon.
1 year 3 months ago #88704

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

Time to create page: 2.131 seconds