×

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

Bi-monthly release with minor bug fixes and improvements

INDI LibCamera Driver

  • Posts: 64
  • Thank you received: 10

Replied by Axel on topic INDI LibCamera Driver


Hi there,

I am currently in a project of uniting PiFinder (pifinder.io) and Stellarmate. This is not possible at the moment because I wait for the PiFinder to be elevated to Bookworm. I'll report on succeed (you can follow on PiFinders Discord channel, if interested: "PiFinder in Stellarmate" on Discord . My discord name there is HeyApos :-). But that's another story.

Back to topic:

That's why I currently dual boot Stellarmate and the PiFinder on the same hardware and a Raspberry Pi HD cam is attached (datasheets.raspberrypi.com/hq-camera/hq-...ra-product-brief.pdf) It works fine with the Pifinder (which uses a pyhthon library and another OS version). So the camera itself and hardware is OK.

The new Stellarmate 1.8.1. claims to support the (official) Raspberry Pi cameras with Libcamera. I know there had been a lot of work by Jasem and others to get this work :-) Thanks for that. I tried to carefully read here and understand how to debug this.

Problem:
When I select the LibCamera driver in a new SM profile, the profile does not start at all.

- Stellarmate App v2.6.80 (Android) - also tried with iPad
- Stellarmate OS 64bit 1.8.1.
- Drivers: Telescope Simulator and Raspberry Pi Cam HD (LibCamera)

Any Idea, what I am doing wrong?

Logging:
Dmesg gives me nothing. And the indi log dir is empty. the other log files I attached.
stellarmate@stellarmate:~ $ libcamera-hello --version
rpicam-apps build: 9ae39f85ae6b 30-01-2024 (13:24:24)
libcamera build: v0.1.0+118-563cd78e

apt list --installed | grep libcamera
libcamera-ipa/stable,now 0.1.0+rpt20231122-1 arm64 [installed,automatic]
libcamera-tools/stable,now 0.1.0+rpt20231122-1 arm64 [installed]
libcamera0.1/stable,now 0.1.0+rpt20231122-1 arm64 [installed,automatic]
python3-libcamera/stable,now 0.1.0+rpt20231122-1 arm64 [installed,automatic]

apt list --installed | grep picamera
python3-picamera2/stable,stable,now 0.3.16-1 all [installed]

libcamera-hello --list-cameras
Available cameras
-----------------
0 : imx477 [4056x3040 12-bit RGGB] (/base/soc/i2c0mux/i2c@1/imx477@1a)
    Modes: 'SRGGB10_CSI2P' : 1332x990 [30.00 fps - (0, 0)/0x0 crop]
           'SRGGB12_CSI2P' : 2028x1080 [30.00 fps - (0, 0)/0x0 crop]
                             2028x1520 [30.00 fps - (0, 0)/0x0 crop]
                             4056x3040 [30.00 fps - (0, 0)/0x0 crop]


Troubleshoot


I followed this bug description: github.com/raspberrypi/picamera2/issues/502 and the test python code gives me the following, so this seems to work.
Opening camera 0: {'Model': 'imx477', 'Location': 2, 'Rotation': 180, 'Id': '/base/soc/i2c0mux/i2c@1/imx477@1a', 'Num': 0}
[1:20:28.197096230] [11781]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[1:20:28.229802128] [11791]  WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[1:20:28.232379551] [11791]  INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media1 and ISP device /dev/media2
[1:20:28.232457346] [11791]  INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
[1:20:28.235057231] [11781]  INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[1:20:28.267695056] [11794]  WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[1:20:28.270162722] [11794]  INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media1 and ISP device /dev/media2
[1:20:28.270281868] [11794]  INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Success.
>>> print('Finished.')
Finished.


When I turn on logging in EKOS (VNC) in "verbose" mode and "file" the error is:
[2024-02-04T21:09:03.079 CET WARN ][           org.kde.kstars.indi] - Driver "LibCamera" failed to start. Retrying in 5 seconds...
[2024-02-04T21:09:08.079 CET WARN ][           org.kde.kstars.indi] - Driver "LibCamera" failed to start. Retrying in 5 seconds...
[2024-02-04T21:09:13.087 CET WARN ][           org.kde.kstars.indi] - Driver "LibCamera" failed to start. Retrying in 5 seconds...
[...]

libcamera-still -r -o test.jpg WORKS (temporarily shut down EKOS / Indi-Webmanager)

libcamera-still -r -o test.jpg
[0:01:23.547791788] [1796] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e
[0:01:23.604749367] [1820] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:01:23.607778920] [1820] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media3 and ISP device /dev/media0
[0:01:23.607872746] [1820] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Preview window unavailable
Mode selection for 2028:1520:12:P
SRGGB10_CSI2P,1332x990/0 - Score: 3456.22
SRGGB12_CSI2P,2028x1080/0 - Score: 1083.84
SRGGB12_CSI2P,2028x1520/0 - Score: 0
SRGGB12_CSI2P,4056x3040/0 - Score: 887
Stream configuration adjusted
[0:01:23.610184360] [1796] INFO Camera camera.cpp:1183 configuring streams: (0) 2028x1520-YUV420 (1) 2028x1520-SBGGR12_CSI2P
[0:01:23.610655825] [1820] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 2028x1520-SBGGR12_1X12 - Selected unicam format: 2028x1520-pBCC
#0 (0.00 fps) exp 29999.00 ag 2.52 dg 1.63
#1 (30.00 fps) exp 29999.00 ag 2.52 dg 1.63
#2 (30.01 fps) exp 29999.00 ag 2.52 dg 1.63
[...]
Mode selection for 4056:3040:12:P
SRGGB10_CSI2P,1332x990/0 - Score: 10552.2
SRGGB12_CSI2P,2028x1080/0 - Score: 8179.84
SRGGB12_CSI2P,2028x1520/0 - Score: 7096
SRGGB12_CSI2P,4056x3040/0 - Score: 0
[0:01:29.203971624] [1796] INFO Camera camera.cpp:1183 configuring streams: (0) 4056x3040-YUV420 (1) 4056x3040-SBGGR12_CSI2P
[0:01:29.211876560] [1820] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 4056x3040-SBGGR12_1X12 - Selected unicam format: 4056x3040-pBCC
Still capture image received
Bayer format is BGGR-12


Cheers, Axel





2 months 4 weeks ago #98760
Attachments:

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

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

I pushed an update to indi-libcamera package yesterday, did you install that version? There was an update to rpicam-apps as well. Make sure to run this:
sudo apt-get update && sudo apt-get -y dist-upgrade
2 months 3 weeks ago #98771

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

  • Posts: 64
  • Thank you received: 10

Replied by Axel on topic INDI LibCamera Driver

Hi Jasem,

thanks a lot.

> Jasem Mutlaq post=98771: I pushed an update to indi-libcamera package yesterday, did you install that version? There was an update to rpicam-apps as well. Make sure to run this:
<code>sudo apt-get update && sudo apt-get -y dist-upgrade
</code>[/quote]

I did my test yesterday (here is CEST, so only 2 hours difference). Probably things got mixed up. Now I just did an upgrade and got a lot of indi drivers, but no indi-libcamera. And I now know why ...
stellarmate@stellarmate:~ $ dpkg -l indi-libcamera
dpkg-query: no packages found matching indi-libcamera
stellarmate@stellarmate:~ $ apt-cache search libcam | grep indi
python3-libcamera - complex camera support library (Python bindings)
indi-libcamera - INDI driver for cameras accessible via libcamera.
indi-libcamera-dbg - INDI driver for cameras accessible via libcamera.

:huh: Seems there had been no such module installed. Me culpa mea maxima culpa.
stellarmate@stellarmate:~ $ sudo apt install indi-libcamera
[...]
The following NEW packages will be installed:
  indi-libcamera
[...]
Setting up indi-libcamera (1.1+z+stable~202402051324) ...

Test:
- After starting Stellarmate I could select the driver LibCamera imx477 (see photo). Good.
- Taking photo leads to an abort
- I changed the image type in the Stellarmate App from DNG (default) to JPG and could take a photo.
- After fidling around with the filetype in EKOS (VNC), I got only "scrambled eggs" :-)
- rebooted. Captured OK (JPG) - > but after 4 or 5 times the capture aborts:
[ERROR] Error opening camera: failed to allocate capture buffers for stream
- rebooted. capture OK (JPG and DNG) ... after some tries: scrambled eggs or [ERROR]:-)


So this is a big step forward - Tux likes it :) But it needs some work to really beeing stable.

I'll try further on.
2 months 3 weeks ago #98823
Attachments:

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

Ok I have a clean version of stellarmate did update dist-upgrade
When I select Libcamera i indi is not starting.

Then I pulled recent version of indi-libcamera

Initially falied to cmake due to missing libcamera-dev installed by

sudo apt-get install libcamera-dev

Next issue was
-- Could NOT find Boost: missing: program_options (found /usr/lib/aarch64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0"))

Solved by
sudo apt-get install libboost-all-dev

And then it installed
The following user(s) said Thank You: Axel
2 months 3 weeks ago #98847

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

Very important trick is to set AWB Blue and AWB Red to 1, if itis set to 0, it will take 3 exposures to adjust awb. Default should be 1 I think as well.
2 months 2 weeks ago #99103

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

  • Posts: 64
  • Thank you received: 10

Replied by Axel on topic INDI LibCamera Driver

Hi Outta,

could you probably be a little bit more precise in what you really did and write it down in a row :-)

- Did you build (!) the indi-libcamera? How?
- What means "pulled"? - from where (git -which version exactly?)
- You write "And then it installed" - what exactly did you install (your built indi-libcamera ...?)

I think this would help people to understand what you exactly did and why :-) For me, it is not clear what your goal was and what you succeeded in the end and why.

THX and cheers
Axel
Last edit: 2 months 2 weeks ago by Axel .
2 months 2 weeks ago #99113

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 got fresh clean install of Stellarmate and did
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade?

Then i coppied commands in a row from this github github.com/indilib/indi-3rdparty

To ease up here are all in order without my failed steps, just run one by one when previous is finished.

sudo apt-get -y install libnova-dev libcfitsio-dev libusb-1.0-0-dev zlib1g-dev libgsl-dev build-essential cmake git libjpeg-dev libcurl4-gnutls-dev libtiff-dev libfftw3-dev libftdi-dev libgps-dev libraw-dev libdc1394-dev libgphoto2-dev libboost-dev libboost-regex-dev librtlsdr-dev liblimesuite-dev libftdi1-dev libavcodec-dev libavdevice-dev

sudo apt-get -y install libindi-dev

mkdir -p ~/Projects
cd ~/Projects

git clone --depth=1 github.com/indilib/indi-3rdparty

Then I ran this two commands I mentioned:

sudo apt-get install libcamera-dev
sudo apt-get install libboost-all-dev

Next I ran this set of commands
mkdir -p ~/Projects/build/indi-libcamera
cd ~/Projects/build/indi-libcamera
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ~/Projects/indi-3rdparty/indi-libcamera
make -j4
sudo make install

Then I started Kstats, opened Ekos, Selected Camera to be Raspberry Pi - Libcamera, started Ekos, and set AWB Blue and Red to 1 from zero and voila, it works!

OH IMPORTANT:
Gain has to be 1 or more. It crashes with 0
Last edit: 2 months 2 weeks ago by Outta.
2 months 2 weeks ago #99117

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

  • Posts: 7
  • Thank you received: 0
I was able to make it work! Thanks for the detailed instructions. Although I don't know if it happens to you, but for me after a couple pictures the camera crashes (or its driver).
Well at least we are getting some progress.
Best,
2 months 1 week ago #99257

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

Not a single crash for me,
1-2s exposures, gain 16, running all night in 8 bit phd2, this are my libcam versions

libcamera-dev:arm64 0.1.0+rpt20231122-1 >
ii libcamera-ipa:arm64 0.1.0+rpt20231122-1 >
ii libcamera-tools 0.1.0+rpt20231122-1 >
ii libcamera0.1:arm64 0.1.0+rpt20231122-1 >
2 months 1 week ago #99258

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

  • Posts: 2
  • Thank you received: 0

Replied by Matt on topic INDI LibCamera Driver


I've tried these steps a few times now with Stellarmate 1.8.1 on a pi 4B. After one to two captures the driver crashes. Tested with the LibCamera imx477. New to this software as of last week, but willing to provide any logs or testing if you can point me in the right direction. I would prefer to get this camera working vs buying another at this time.
2 months 3 days ago #99417

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

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

Issue with upstream RPICAM leading to out-of-memory error, it's reported here: github.com/raspberrypi/rpicam-apps/issues/640
2 months 3 days ago #99420

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

Replied by Jasem Mutlaq on topic INDI LibCamera Driver

Apparently the OOM issue was due to not parsing options, I uploaded a new version. Please check it out.
2 months 3 days ago #99422

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

Time to create page: 1.145 seconds