×

INDI Library v2.0.7 is Released (01 Apr 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

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 3 months ago by Anjo.
1 year 3 months ago #89202
Attachments:

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

  • Posts: 27
  • Thank you received: 4
I can only speak about Raspberry Pi cameras directly connected to the CSI port:

Only exposure time ("ExposureTime") and analogue gain ("AnalogueGain"") influence raw pictures. True raw pictures have a Bayer pattern like "RGGB" (with two "G" in it!). Formats like "RGB" or "YUV" are already processed by the Image Signal Processor (ISP) on the Raspberry Pi.

It is my strong opinion that processed pictures are useless for later stacking:
  • One of the very first steps in the ISP is to subtract the black level. In contrast to a dark frame subtraction a factory value is used here. This is not measured on your particular image sensor. Ususally the value used as black level is too high. You can be lucky when you have enough light pollution. But when observing a really dark sky all faint structures like nebulas will be saturated to black. There is no way to correct this afterwards.
  • The ISP uses fixed point arithmetic and scales the resulting frame to 8 bit. This adds a lot of discretization noise. A good stacking software does all these things with floating point arithmetic.
  • Lossy compression like JPG adds so many artifacts to underexposed pictures that after stacking with a good software you can not believe anymore what you see.

I would recommend to focus on raw Bayer pictures.
1 year 3 months ago #89212

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

  • Posts: 3
  • Thank you received: 1
@Anjo you did an impressive work. Thanks.

If I understand correctly your code, libcamera driver resolution is not updated with resolution update messages coming from indi server

Maybe adding/editing the following lines could help:

bool INDILibCamera::Connect()
{
    try
    {
 
        ...
 
        // stillOptions->width = 1920;
        // stillOptions->height = 1080;
 
        // Get resolution from indi:ccd (whatever is settled when we are connecting), and update libcamera driver resolution
        stillOptions->width = PrimaryCCD.getXRes();
        stillOptions->height = PrimaryCCD.getYRes();
 
       ...

bool INDILibCamera::UpdateCCDFrame(int x, int y, int w, int h)
{
    ...
 
    // Always set BINNED size
    Streamer->setSize(subW, subH);
 
    // Set libcamera resolution as defined in update message
    auto stillOptions = m_StillApp->GetOptions();   
    stillOptions->width = w;
    stillOptions->height = h;
 
   ...
1 year 3 months ago #89214

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

  • Posts: 27
  • Thank you received: 4
By the way: I implemented a libcamera driver for the HQ camera in Python: indi_pylibcamra

It runs on a Raspberry Pi Zero (Raspian without XServer) and delivers raw Bayer pattern images. It is in an early stage. For instance I did not check if the color information is set in the right order in the FITS. During a first check with a photo lense I got the impression that I exchanged blue and red. Local saving is also not implemented. And doing Connect->Disconnect->Connect leads to an error. It also needs documentation. I will continue to work on it after Xmas.

Marry Christmas and Happy New Year to all of you!
The following user(s) said Thank You: Anjo
1 year 3 months ago #89216

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

This fellow is smart listen to what he says.

Let me just digress on images from this implementation, in this current state, changing gain does not change histogram, and that is main thing you should watch. Changing exposure does change it, but up to certain point, depending what is supported from camera driver.

I know that imx290/462 can support up to 15s but to activate that mode you need to set some address, in driver to 0xFFFFF, and that is not implemented in RPI driver, only in arducam driver.
The following user(s) said Thank You: Ronald Schreiber
1 year 3 months ago #89217

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 DNG doesn't change at all with exposure and gain settings at least not from what I see. It's only after you shoot a jpeg it does change.

Also, the controls can be useful for a variety of things, getting video to work better being one.

So yeah, for the "actual" images raw is fine, but it's a lot more convenient when you have other options, too.
1 year 3 months ago #89220

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

For me it does, but again not for raw images. They don't change at all unless you shoot jpegs first.
1 year 3 months ago #89221

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

Thanks for this, I hope I'll get try it in the next few days.

Frankly, if I had time I would have written a pure python command line driver (ie, not using picamera2, but forking to a new process and getting stdout or the file it produces). Otherwise libcamera is just too flaky for my tastes.

I'd just have used a pre-exisitng lib like github.com/MMTObservatory/pyINDI/tree/mmtcam_stuff

I think they have a CCD template floating around. But I also definitely wanted video, and have no idea on how to show that on the client and how many props I would have to implement for it.
The following user(s) said Thank You: Ronald Schreiber
1 year 3 months ago #89222

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

  • Posts: 27
  • Thank you received: 4
@Anjo

Thank you. Last week I started to write the driver based on the mentioned pyINDI package. But then I found too many things to work around and decided to implement the protocol by myself. It was not difficult.

I agree that having the possibility to get processed pictures has advantages. At least when you focus your telescope on a bright star you don't need raw images. In this situation it is more important to have short dead time between changing focus and seeing the effect on the image. With smaller JPG images you can save a lot transmission time. My Raspberry Pi needs about 13 seconds to transmit the Raw image - searching focus becomes a nightmare.
1 year 3 months ago #89224

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, so I re-added CloseCamera/OpenCamera calls so the cam is now locked only for the duration of shots.

Playing with the text props will still crash, so be careful with them. Probably best leave them at the first item.

And I added width/height setting. You need to do this on the "Image Setting" page - and make sure your width is divisible by 2.

I also noticed that you can't compile the driver on buster, as there are changes in libcamera (exposure is a long, not a pointer and a few other things). Then again, it probably won't run the newer cams anyway.
1 year 3 months ago #89229

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

@OUTTA Have you seen this: github.com/raspberrypi/libcamera-apps/issues/344

I have the waveshare module and contrary to what it reports

2022-12-22T16:38:58: Driver ../build/indi-libcamera/indi_libcamera_ccd: ExposureTime : [14..7229147]

it seems like it does expose for 15s?
1 year 3 months ago #89230

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

Interesting I have IMX462 but it does not seem to work as expected.
Do you run V4L2 command before or that is in driver? Is that PR in latest version?

Also one thing i noticed about gain, do you use "gain" or "analoggain" parameter. Gain is digital, and analoggain is one we are interested in.
1 year 3 months ago #89231

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

Time to create page: 1.827 seconds