openastroproject / openastro

Open Astro Project
GNU General Public License v3.0
91 stars 27 forks source link

HQ camera ROI not working, slow frame rate, only max resolution available #499

Open MikeIsInProcess opened 3 years ago

MikeIsInProcess commented 3 years ago

I'm using the Raspberry Pi HQ camera w/ a Pi 4 w/ 2G.

I can see live preview, but I'm only getting 1.6fps and no lower resolution is available in the drop down to improve this besides the max of 4056x3040. Setting the ROI to something like 1024x768 or one of the other resolutions for this camera causes the 2nd value under ROI to change to zero and the preview is blanked out, and an error message is thrown.

Image of errors attached.

Screen Shot 2021-03-21 at 11 56 06 PM

The out of memory error occurs even after I have set GPU RAM to 512M.

The only preview I see is at the max resolution and it's slow.

Changing the mode of the camera in v4l2-ctl prior to running oacapture changes nothing in oacapture.

Here are other resolutions listed in the cam's documentation.

Mode | Size | Aspect Ratio | Frame rates | FOV | Binning/Scaling 0 | automatic selection |   |   |   |   1 | 2028x1080 | 169:90 | 0.1-50fps | Partial | 2x2 binned 2 | 2028x1520 | 4:3 | 0.1-50fps | Full | 2x2 binned 3 | 4056x3040 | 4:3 | 0.005-10fps | Full | None 4 | 1332x990 | 74:55 | 50.1-120fps | Partial | 2x2 binned

openastroproject commented 3 years ago

Hmm. I feel sure that worked for me when I tested it. I'll have another look

MikeIsInProcess commented 3 years ago

What did you find?

openastroproject commented 3 years ago

I've been having some reliability issues with my RPi4, but I think I have them sorted now. I will hopefully have some news in the next couple of days.

openastroproject commented 3 years ago

Ok, it appears that the Linux V4L2 interface doesn't offer multiple resolutions. It actually gives the full resolution of the camera and then says it can be changed in steps of two pixels. Clearly I have something not working there and I'll try to get that fixed for the next release.

I'm not sure about the frame rates at the moment. There is some suggestion in the documentation that the frame rate may be dependent on turning off automatic exposure time and gain settings, but the V4L2 interface doesn't appear to be offering any gain control that I can see, so that's another that I need to look into. Perhaps there's something in the list of unsupported controls that relates to this, so I'll look into that as well.

openastroproject commented 3 years ago

Well, that's unpleasant. If I try to set a resolution of 2028x1080, the V4L2 driver refuses despite the fact that it appears to match the sizes that are apparently allowed. Instead it offers 2024x1080 as an alternative, but then returns a mangled frame if I try to set that.

1332x990 is also disallowed with 1328x990 offered as an alternative (which also doesn't actually work if requested).

640x480, 800x600, 1280x1024 and 2560x2048 seem to work absolutely fine however.

I'm wondering if what is possible using V4L2 doesn't match what is possible using libmmal (and if the V4L2 implementation may be buggy). I'll check I have all the latest updates installed in case that makes a difference, but it may be that the only way to get the camera working as per the documentation is to build a completely new camera interface built on libmmal. At the moment I can't find any helpful documentation for using libmmal, so I have no idea if that's even reasonably possible.

openastroproject commented 3 years ago

This may be helpful as an example of how to use libmmal, but I'm not sure:

https://github.com/fpasteau/raspicam_node

openastroproject commented 3 years ago

Some reference docs here, but that doesn't really help to use them.

http://www.jvcref.com/files/PI/documentation/mmal_10_2015/html/index.html