×

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

Bi-monthly release with minor bug fixes and improvements

INDI LibCamera Driver

  • Posts: 123
  • Thank you received: 13

Replied by Outta on topic INDI LibCamera Driver

Indeed you are right,and I have been writing "analog" to terminal for nothing whole last year or so :D
1 year 3 months ago #89233

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

  • Posts: 27
  • Thank you received: 4
Libcamera knows:

"analogue_gain": This tunes a physical amplifier between pixel circuit and ADC on the camera chip. It influences raw and processed frames.

"digital_gain" and "colour_gains": These are parameters of the software running in the ISP for processing the frames. They are digital multiplication factors and influence only the processed frame. The "colour_gains" are used to set the white balance.
1 year 3 months ago #89234

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

Yeah, but:

www.waveshare.com/wiki/IMX519-78_16MP_AF_Camera#libcamera-jpeg

"The gain parameter set will first set the analog gain parameter inside the photosensitive chip. If the set gain exceeds the maximum built-in analog gain value of the driver, the maximum analog gain of the chip will be set first, and then the remaining gain multiples will be used as numbers. gain to take effect. "

So you unless you exceed the analog gain max, you'll never use the digital gain.
1 year 3 months ago #89275

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

  • Posts: 27
  • Thank you received: 4
That "gain" is implemented by the "libcamera-jpeg" application. But the "libcamera" library distinguishes between analogue and digital gains.

The "libcamera" has algorithms for automated gain control (AGC) and automated exposure control (AEC). As long as these algorithms are not disabled the gain and exposure time settings are ignored (or used as start values for the optimization). I do not know if "libcamera-jpeg" disables the algorithms automatically when you set values for gain and exposure time. But when you use "libcamera" directly you need to disable the algorithms explicitly. Otherwise you will have no control over final exposure time and gains.

The AGC/AEC algorithms do experimental exposures to find optimized values for exposure time and gains. Not only that you do not have control over the final exposure time and gains you will also wait much longer until you get the frame.
1 year 2 months ago #89302

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

  • Posts: 27
  • Thank you received: 4
Happy New Year!

I pushed a new version of my Python driver to GitHub: github.com/scriptorron/indi_pylibcamera

Screenshots are attached. New in this version is:
  1. selection of different raw modes provided by libcamera
  2. raw frames with Bayer pattern and processed frames as RGB images
  3. processed frames can be scaled to configurable sizes (size of raw frames is defined by camera hardware and libcamera)
  4. the exchanged R ang B channel in the Bayer pattern is fixed

It is tested with HQ camera on Raspberry Pi Zero, controlled by KStars/EKOS from laptop.

The Raspberry Pi Zero is very limited in RAM. The current driver will run out of RAM when you capture a processed frame in full size. Capturing scaled down frames or raw frames in full size works fine.

The driver is still not finished and I will work on it in the next days. There are still some open issues I need to solve. Maybe you know answers to that:
  1. I implemented a "Fast exposure" mode in the driver. Everytime when an exposure finished a new exposure is started and runs in paralell to the processing and transmission of the finished exposure. That works fine when I press "Capture a preview" in EKOS. But EKOS freezes when I pressing "Start framing (looping)": it shows "Downloading..." without ending. Does EKOS do something different when "Fast exposure" ("CCD_FAST_TOGGLE" switch vector) is enabled?
  2. When I configure the HQ camera for RGGB raw frames I get BGGR data. When configuring for BGR processed frames I get RGB data. Is that a bug in "picamera2" or libcamera? Or has that something to do with the global camera info "Rotation"=180?
  3. EKOS allows to safe the images "Locally", "Remotely" and "Both". Is it true that these options set the "UPLOAD_MODE" switch vector? Is it also true that the driver and not the indiserver needs to take care for the local saving?
1 year 2 months ago #89353

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

When I attach KStars/Ekos to my indiserver driver works, but when I press capture button it crashes:
indiserver -v indi_libcamera_ccd 
2023-01-04T06:16:47: startup: indiserver -v indi_libcamera_ccd
2023-01-04T06:16:47: Driver indi_libcamera_ccd: pid=4933 rfd=6 wfd=6 efd=7
2023-01-04T06:16:47: listening to port 7624 on fd 5
2023-01-04T06:16:47: Local server: listening on local domain at: @/tmp/indiserver
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Telescope Simulator.EQUATORIAL_EOD_COORD
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Telescope Simulator.EQUATORIAL_COORD
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Telescope Simulator.TELESCOPE_INFO
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Telescope Simulator.GEOGRAPHIC_COORD
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Telescope Simulator.TELESCOPE_PIER_SIDE
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Rotator Simulator.ABS_ROTATOR_ANGLE
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Focuser Simulator.ABS_FOCUS_POSITION
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on Focuser Simulator.FOCUS_TEMPERATURE
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on CCD Simulator.FILTER_SLOT
2023-01-04T06:16:48: Driver indi_libcamera_ccd: [19:03:09.181523222] [4933]  INFO Camera camera_manager.cpp:299 libcamera v0.0.1
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on CCD Simulator.FILTER_NAME
2023-01-04T06:16:48: Driver indi_libcamera_ccd: snooping on SQM.SKY_QUALITY
2023-01-04T06:16:48: Driver indi_libcamera_ccd: [19:03:09.262540175] [4937]  INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media3 and ISP device /dev/media0
2023-01-04T06:17:04: Client 9: new arrival from 127.0.0.1:53984 - welcome!
2023-01-04T06:17:05: Client 10: new arrival from 127.0.0.1:53986 - welcome!
2023-01-04T06:17:38: Driver indi_libcamera_ccd: Running without preview window
2023-01-04T06:17:38: Driver indi_libcamera_ccd: Opening camera...
2023-01-04T06:17:38: Driver indi_libcamera_ccd: [19:03:58.505618538] [4935] FATAL IPAManager ipa_manager.cpp:109 Multiple IPAManager objects are not allowed
2023-01-04T06:17:38: Driver indi_libcamera_ccd: Backtrace:
2023-01-04T06:17:38: Driver indi_libcamera_ccd: 
2023-01-04T06:17:38: Driver indi_libcamera_ccd: read EOF
<delProperty device="LibCamera"/>
2023-01-04T06:17:38: Driver indi_libcamera_ccd: restart #0
2023-01-04T06:17:38: Driver indi_libcamera_ccd: pid=4954 rfd=7 wfd=7 efd=11
2023-01-04T06:17:38: Client 9: read EOF
2023-01-04T06:17:38: Client 9: shut down complete - bye!
2023-01-04T06:17:38: Client 10: read EOF
2023-01-04T06:17:38: Client 10: shut down complete - bye!
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Telescope Simulator.EQUATORIAL_EOD_COORD
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Telescope Simulator.EQUATORIAL_COORD
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Telescope Simulator.TELESCOPE_INFO
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Telescope Simulator.GEOGRAPHIC_COORD
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Telescope Simulator.TELESCOPE_PIER_SIDE
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Rotator Simulator.ABS_ROTATOR_ANGLE
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Focuser Simulator.ABS_FOCUS_POSITION
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on Focuser Simulator.FOCUS_TEMPERATURE
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on CCD Simulator.FILTER_SLOT
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on CCD Simulator.FILTER_NAME
2023-01-04T06:17:38: Driver indi_libcamera_ccd: snooping on SQM.SKY_QUALITY
2023-01-04T06:17:38: Driver indi_libcamera_ccd: [19:03:59.105795000] [4954]  INFO Camera camera_manager.cpp:299 libcamera v0.0.1
2023-01-04T06:17:38: Driver indi_libcamera_ccd: [19:03:59.172564166] [4956]  INFO RPI raspberrypi.cpp:1386 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media3 and ISP device /dev/media0
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
 
uname -a
Linux stellarmate 5.15.76-v8+ #1597 SMP PREEMPT Fri Nov 4 12:16:41 GMT 2022 aarch64 GNU/Linux

This error happens on freshly rebooted system, so I'm really sure no other device is using camera.
Could it be some libcamera bug on 64 bit systems?

I'm using 64bit Stellarmate OS that is based on Bullseye.
@Anjo, @OUTTA, what OS version are you to using? Also my "Main control" tab is showing a lot less parameters than yours.
Last edit: 1 year 2 months ago by Simon.
1 year 2 months ago #89400
Attachments:

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 have made little change in your branch, INDILibCamera::Connect() method to get sensor size and pixel size from camera.

github.com/anjok/indi-3rdparty/commit/81...d060da020aafb068a482

It works on my imx477, can you see if it works for you too?
1 year 2 months ago #89409

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

I am using
Linux raspberrypi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux

I will try to pull that now and test it on IMX462
1 year 2 months ago #89412

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

It seems fine, although default resolution is still max - 1937x1097 and that results in failure, despite device detecting correct frame ROI of 1920x1080:
Capture JPG works, exposure and gain works as per histogram
Capture DNG works, exposure and gain works as per histogram
Streaming crashes whole Kstars :)

but the issue I notice the most, we only get single channel(only red from RGB)
2023-01-04T12:18:22: [INFO] World Coordinate System is enabled. 
2023-01-04T12:18:22: [INFO] WCS_CONTROL.WCS_ENABLE -> 1 
2023-01-04T12:18:22: [INFO] Device configuration applied. 
2023-01-04T12:18:22: [INFO] LIMITS.LIMITS_PREVIEW_FPS -> 10.000000 
2023-01-04T12:18:22: [INFO] LIMITS.LIMITS_BUFFER_MAX -> 512.000000 
2023-01-04T12:18:22: [INFO] CCD_STREAM_RECORDER.SER -> 1 
2023-01-04T12:18:22: [INFO] RECORD_OPTIONS.RECORD_FRAME_TOTAL -> 30.000000 
2023-01-04T12:18:22: [INFO] RECORD_OPTIONS.RECORD_DURATION -> 1.000000 
2023-01-04T12:18:22: [INFO] CCD_STREAM_ENCODER.MJPEG -> 0 
2023-01-04T12:18:22: [INFO] CCD_STREAM_ENCODER.RAW -> 1 
2023-01-04T12:18:22: [INFO] Setting frame buffer size to 2073600 bytes. 
2023-01-04T12:18:22: [INFO] Frame ROI x:0 y:0 w:1920 h:1080 
2023-01-04T12:18:22: [INFO] CCD_BINNING.VER_BIN -> 1.000000 
2023-01-04T12:18:22: [INFO] CCD_BINNING.HOR_BIN -> 1.000000 
2023-01-04T12:18:22: [WARNING] Cannot subframe JPEG streams. 
2023-01-04T12:18:22: [INFO] Setting frame buffer size to 2073600 bytes. 
2023-01-04T12:18:22: [INFO] Frame ROI x:0 y:0 w:1920 h:1080 
2023-01-04T12:18:22: [INFO] CCD_FRAME.HEIGHT -> 1080.000000 
2023-01-04T12:18:22: [INFO] CCD_FRAME.WIDTH -> 1920.000000 
2023-01-04T12:18:22: [INFO] CCD_FRAME.Y -> 0.000000 
2023-01-04T12:18:22: [INFO] CCD_FRAME.X -> 0.000000 
2023-01-04T12:18:22: [INFO] CCD_TRANSFER_FORMAT.FORMAT_NATIVE -> 0 
2023-01-04T12:18:22: [INFO] CCD_TRANSFER_FORMAT.FORMAT_FITS -> 1 
2023-01-04T12:18:22: [INFO] CCD_CAPTURE_FORMAT.JPG -> 1 
2023-01-04T12:18:22: [INFO] CCD_CAPTURE_FORMAT.DNG -> 0 
2023-01-04T12:18:22: [INFO] CCD_COMPRESSION.INDI_DISABLED -> 1 
2023-01-04T12:18:22: [INFO] CCD_COMPRESSION.INDI_ENABLED -> 0 
2023-01-04T12:18:22: [INFO] CCD_FAST_TOGGLE.INDI_DISABLED -> 1 
2023-01-04T12:18:22: [INFO] CCD_FAST_TOGGLE.INDI_ENABLED -> 0 
2023-01-04T12:18:22: [INFO] Upload settings set to client only. 
2023-01-04T12:18:22: [INFO] UPLOAD_MODE.UPLOAD_BOTH -> 0 
2023-01-04T12:18:22: [INFO] UPLOAD_MODE.UPLOAD_LOCAL -> 0 
2023-01-04T12:18:22: [INFO] UPLOAD_MODE.UPLOAD_CLIENT -> 1 
2023-01-04T12:18:22: [INFO] LOG_OUTPUT.FILE_DEBUG -> 0 
2023-01-04T12:18:22: [INFO] LOG_OUTPUT.CLIENT_DEBUG -> 1 
2023-01-04T12:18:22: [INFO] LOGGING_LEVEL.LOG_DEBUG -> 0 
2023-01-04T12:18:22: [INFO] LOGGING_LEVEL.LOG_SESSION -> 1 
2023-01-04T12:18:22: [INFO] LOGGING_LEVEL.LOG_WARNING -> 1 
2023-01-04T12:18:22: [INFO] LOGGING_LEVEL.LOG_ERROR -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_DEBUG -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_SESSION -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_WARNING -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_ERROR -> 1 
2023-01-04T12:18:22: [INFO] POLLING_PERIOD.PERIOD_MS -> 1000.000000 
2023-01-04T12:18:22: [INFO] DEBUG.DISABLE -> 0 
2023-01-04T12:18:22: [INFO] DEBUG.ENABLE -> 1 
2023-01-04T12:18:22: [INFO] Loading device configuration... 
2023-01-04T12:18:22: [INFO] CONFIG_PROCESS.CONFIG_PURGE -> 0 
2023-01-04T12:18:22: [INFO] CONFIG_PROCESS.CONFIG_DEFAULT -> 0 
2023-01-04T12:18:22: [INFO] CONFIG_PROCESS.CONFIG_SAVE -> 0 
2023-01-04T12:18:22: [INFO] CONFIG_PROCESS.CONFIG_LOAD -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_DEBUG -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_SESSION -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_WARNING -> 1 
2023-01-04T12:18:22: [INFO] DEBUG_LEVEL.DBG_ERROR -> 1 
2023-01-04T12:18:22: [INFO] DEBUG.ENABLE -> 1 
2023-01-04T12:18:22: [INFO] UnitCellSize 2.900000 x 2.900000 
2023-01-04T12:18:22: [INFO] PixelArraySize 1937 x 1097 (actual 1936 x 1097) 
2023-01-04T12:18:22: [INFO] Setting frame buffer size to 2123792 bytes. 
2023-01-04T12:18:22: [INFO] Frame ROI x:0 y:0 w:1936 h:1097 
2023-01-04T12:18:22: [INFO] CONNECTION.CONNECT -> 1 
2023-01-04T12:18:21: [INFO] LOG_OUTPUT.FILE_DEBUG -> 0 
2023-01-04T12:18:21: [INFO] LOG_OUTPUT.CLIENT_DEBUG -> 1 
2023-01-04T12:18:21: [INFO] POLLING_PERIOD.PERIOD_MS -> 1000.000000 
2023-01-04T12:18:21: [INFO] LOGGING_LEVEL.LOG_DEBUG -> 0 
2023-01-04T12:18:21: [INFO] LOGGING_LEVEL.LOG_SESSION -> 1 
2023-01-04T12:18:21: [INFO] LOGGING_LEVEL.LOG_WARNING -> 1 
2023-01-04T12:18:21: [INFO] LOGGING_LEVEL.LOG_ERROR -> 1 
2023-01-04T12:18:21: [INFO] DEBUG_LEVEL.DBG_DEBUG -> 1 
2023-01-04T12:18:21: [INFO] DEBUG_LEVEL.DBG_SESSION -> 1 
2023-01-04T12:18:21: [INFO] DEBUG_LEVEL.DBG_WARNING -> 1 
2023-01-04T12:18:21: [INFO] DEBUG_LEVEL.DBG_ERROR -> 1 
2023-01-04T12:18:21: [INFO] Debug is enabled. 
2023-01-04T12:18:21: [INFO] DEBUG.DISABLE -> 0 
2023-01-04T12:18:21: [INFO] DEBUG.ENABLE -> 1 
1 year 2 months ago #89414

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

I am using 
Linux raspberrypi 5.15.61-v7l+ #1579 SMP Fri Aug 26 11:13:03 BST 2022 armv7l GNU/Linux
 
I will try to pull that now and test it on IMX462


I guess FATAL IPAManager ipa_manager.cpp:109 Multiple IPAManager objects are not allowed crash is only related to 64 bit systems?
Could it be a libcamera bug?
Last edit: 1 year 2 months ago by Simon.
1 year 2 months ago #89415

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

It seems fine, although default resolution is still max - 1937x1097 and that results in failure, despite device detecting correct frame ROI of 1920x1080:

That's strange on my imx477 it returns correct values 4056 x 3040.
1 year 2 months ago #89416

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

I'm testing new indi_libcamera_ccd driver.
Is it normal that I get two welcome messages in LOG when I start EKOS from KStars with arrow button?
2023-01-11T09:01:01: Client 9: new arrival from 127.0.0.1:43488 - welcome!
2023-01-11T09:01:02: Client 10: new arrival from 127.0.0.1:43494 - welcome!

I'm wandering if this is somehow related to this error message and driver crash when I press "Capture a preview" button on EKOS/CCD tab?
2023-01-11T09:01:10: Driver indi_libcamera_ccd: [0:47:13.714290735] [4642] FATAL IPAManager ipa_manager.cpp:109 Multiple IPAManager objects are not allowed

I can't get pass this error no mater what I try :(.

@Anjo, @OUTTA, is "Capture a preview" in EKOS working for you?
1 year 2 months ago #89567

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

Time to create page: 1.868 seconds