openastroproject / openastro

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

Raspberry pi camera capture using oacapture #468

Closed simonachmueller closed 3 years ago

simonachmueller commented 4 years ago

I want to try planetary imaging with the raspberry camera (I have raspberry pi 3 model b and raspberry camera rev. 1.3, latest raspbian installed). Yesterday I downloaded latest master source code for openastro project and successfully build it on my raspberry pi. It runs, but when I select the "camera0", it crashes with an segmentation fault.

Console output is below:

pi@raspberrypi:~/openastro/oacapture $ ./oacapture can't load libqhyccd.so.20: libqhyccd.so.20: cannot open shared object file: No such file or directory currently unsupported V4L2 control 0x9a0913 currently unsupported V4L2 control 0x9a0916 currently unsupported V4L2 control 0x9a0917 currently unsupported V4L2 control 0x9a0918 currently unsupported V4L2 control 0x9a0919 currently unsupported V4L2 control 0x9a091a Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG) Unhandled V4L2 format 'H.264': 0x34363248 (H264) Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG) Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU) Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY) Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12) Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12) Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21) Unhandled V4L2 format '32-bit BGRA/X 8-8-8-8': 0x34524742 (BGR4) Can't handle framesizing type 3 Segmentation fault

There are other camera devices listed: image but when I choose any from bcm2835 devices, I get "Unable to connect camera" and bcm2835-*** does not support video capture message in the console.

I'm able to capture images and video by using raspivid/raspistill.

Any idea what can be wrong here?

simonachmueller commented 4 years ago

Just tested with a normal webcam (Logitech C210) connected to raspberry pi: oacapture works, but I want to use raspberry camera because the sensor seems to be much better then the old webcam's one.

simonachmueller commented 4 years ago

Here is the output of v4l2-ctl -d /dev/video0 --list-formats-ext

Driver Info:
        Driver name      : bm2835 mmal
        Card type        : mmal service 16.1
        Bus info         : platform:bcm2835-v4l2
        Driver version   : 4.19.97
        Capabilities     : 0x85200005
                Video Capture
                Video Overlay
                Read/Write
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x05200005
                Video Capture
                Video Overlay
                Read/Write
                Streaming
                Extended Pix Format
Priority: 2
Video input : 0 (Camera 0: ok)
Format Video Capture:
        Width/Height      : 32/32
        Pixel Format      : 'BGR3' (24-bit BGR 8-8-8)
        Field             : None
        Bytes per Line    : 96
        Size Image        : 3072
        Colorspace        : SMPTE 170M
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
Format Video Overlay:
        Left/Top    : 150/50
        Width/Height: 1024/768
        Field       : None
        Chroma Key  : 0x00000000
        Global Alpha: 0xff
        Clip Count  : 0
        Clip Bitmap : No
Framebuffer Format:
        Capability    : Extern Overlay
                        Global Alpha
        Flags         : Overlay Matches Capture/Output Size
        Width         : 32
        Height        : 32
        Pixel Format  : 'YU12'
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 1.000 (1/1)
        Read buffers     : 1

User Controls

                     brightness 0x00980900 (int)    : min=0 max=100 step=1 default=50 value=50 flags=slider
                       contrast 0x00980901 (int)    : min=-100 max=100 step=1 default=0 value=0 flags=slider
                     saturation 0x00980902 (int)    : min=-100 max=100 step=1 default=0 value=0 flags=slider
                    red_balance 0x0098090e (int)    : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
                   blue_balance 0x0098090f (int)    : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
                horizontal_flip 0x00980914 (bool)   : default=0 value=0
                  vertical_flip 0x00980915 (bool)   : default=0 value=0
           power_line_frequency 0x00980918 (menu)   : min=0 max=3 default=1 value=1
                      sharpness 0x0098091b (int)    : min=-100 max=100 step=1 default=0 value=0 flags=slider
                  color_effects 0x0098091f (menu)   : min=0 max=15 default=0 value=0
                         rotate 0x00980922 (int)    : min=0 max=360 step=90 default=0 value=0 flags=modify-layout
             color_effects_cbcr 0x0098092a (int)    : min=0 max=65535 step=1 default=32896 value=32896

Codec Controls

             video_bitrate_mode 0x009909ce (menu)   : min=0 max=1 default=0 value=0 flags=update
                  video_bitrate 0x009909cf (int)    : min=25000 max=25000000 step=25000 default=10000000 value=10000000
         repeat_sequence_header 0x009909e2 (bool)   : default=0 value=0
            h264_i_frame_period 0x00990a66 (int)    : min=0 max=2147483647 step=1 default=60 value=60
                     h264_level 0x00990a67 (menu)   : min=0 max=11 default=11 value=11
                   h264_profile 0x00990a6b (menu)   : min=0 max=4 default=4 value=4

Camera Controls

                  auto_exposure 0x009a0901 (menu)   : min=0 max=3 default=0 value=0
         exposure_time_absolute 0x009a0902 (int)    : min=1 max=10000 step=1 default=1000 value=1000
     exposure_dynamic_framerate 0x009a0903 (bool)   : default=0 value=0
             auto_exposure_bias 0x009a0913 (intmenu): min=0 max=24 default=12 value=12
      white_balance_auto_preset 0x009a0914 (menu)   : min=0 max=10 default=1 value=1
            image_stabilization 0x009a0916 (bool)   : default=0 value=0
                iso_sensitivity 0x009a0917 (intmenu): min=0 max=4 default=0 value=0
           iso_sensitivity_auto 0x009a0918 (menu)   : min=0 max=1 default=1 value=1
         exposure_metering_mode 0x009a0919 (menu)   : min=0 max=2 default=0 value=0
                     scene_mode 0x009a091a (menu)   : min=0 max=13 default=0 value=0

JPEG Compression Controls

            compression_quality 0x009d0903 (int)    : min=1 max=100 step=1 default=30 value=30
simonachmueller commented 4 years ago

And v4l2-ctl -d /dev/video0 --list-formats-ext

ioctl: VIDIOC_ENUM_FMT
        Type: Video Capture

        [0]: 'YU12' (Planar YUV 4:2:0)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [1]: 'YUYV' (YUYV 4:2:2)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [2]: 'RGB3' (24-bit RGB 8-8-8)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [3]: 'JPEG' (JFIF JPEG, compressed)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [4]: 'H264' (H.264, compressed)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [5]: 'MJPG' (Motion-JPEG, compressed)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [6]: 'YVYU' (YVYU 4:2:2)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [7]: 'VYUY' (VYUY 4:2:2)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [8]: 'UYVY' (UYVY 4:2:2)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [9]: 'NV12' (Y/CbCr 4:2:0)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [10]: 'BGR3' (24-bit BGR 8-8-8)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [11]: 'YV12' (Planar YVU 4:2:0)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [12]: 'NV21' (Y/CrCb 4:2:0)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
        [13]: 'BGR4' (32-bit BGRA/X 8-8-8-8)
                Size: Stepwise 32x32 - 2592x1944 with step 2/2
openastroproject commented 4 years ago

I might have to try to get one of these cameras and see if I can debug the problem that way. Can you give me a link to the camera so I know I'm looking at the correct one?

simonachmueller commented 4 years ago

It would be awesome if I can get it work! I'm using a camera module v1 https://www.raspberrypi.org/documentation/hardware/camera, https://uk.pi-supply.com/products/raspberry-pi-camera-board-v1-3-5mp-1080p

simonachmueller commented 4 years ago

Is that worth to try it out after 651efc0?

openastroproject commented 4 years ago

Not quite ready yet, but I think I'm much closer now.

fliker09 commented 4 years ago

Confirming the issue. Running Raspbian Jessie (aka Debian 8.0) on Raspberry Pi 2B and oaCapture 1.6.0.

lea instruction #1 not found at address 0x71ffe466
lea + 00: 63
lea + 01: 88
lea + 02: b3
lea + 03: 42
lea + 04: 16
lea + 05: d0
lea + 06: a3
lea + 07: 88
lea + 08: b3
lea + 09: 42
lea + 0a: 13
lea + 0b: d0
lea + 0c: 14
lea + 0d: 34
lea + 0e: bc
lea + 0f: 42
currently unsupported V4L2 control 0x9a0913
currently unsupported V4L2 control 0x9a0916
currently unsupported V4L2 control 0x9a0917
currently unsupported V4L2 control 0x9a0918
currently unsupported V4L2 control 0x9a0919
currently unsupported V4L2 control 0x9a091a
Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG)
Unhandled V4L2 format 'H.264': 0x34363248 (H264)
Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG)
Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU)
Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY)
Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12)
Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12)
Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21)
Unhandled V4L2 format '32-bit BGRA/X 8-8-8-8': 0x34524742 (BGR4)
Can't handle framesizing type 3
dragonlost commented 4 years ago

Confirming the issue. Running Raspbian Jessie (aka Debian 8.0) on Raspberry Pi 2B and oaCapture 1.6.0.

lea instruction #1 not found at address 0x71ffe466
lea + 00: 63
lea + 01: 88
lea + 02: b3
lea + 03: 42
lea + 04: 16
lea + 05: d0
lea + 06: a3
lea + 07: 88
lea + 08: b3
lea + 09: 42
lea + 0a: 13
lea + 0b: d0
lea + 0c: 14
lea + 0d: 34
lea + 0e: bc
lea + 0f: 42
currently unsupported V4L2 control 0x9a0913
currently unsupported V4L2 control 0x9a0916
currently unsupported V4L2 control 0x9a0917
currently unsupported V4L2 control 0x9a0918
currently unsupported V4L2 control 0x9a0919
currently unsupported V4L2 control 0x9a091a
Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG)
Unhandled V4L2 format 'H.264': 0x34363248 (H264)
Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG)
Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU)
Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY)
Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12)
Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12)
Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21)
Unhandled V4L2 format '32-bit BGRA/X 8-8-8-8': 0x34524742 (BGR4)
Can't handle framesizing type 3

You must use the current version to be able to confirming the issue. Version 1.6.0 is much too old.

openastroproject commented 4 years ago

Not quite ready yet, but I'm much closer now. There were a couple of bugs here that haven't come up before with V4L2 cameras, one so subtle that it has taken me ages to find. And there's some new functionality that I've not seen with V4L2 cameras before. So it should all work once I release 1.8.0.

sidersc commented 4 years ago

This problem persists in version 1.8.0 on Raspberry Pi with the HQ camera.

qt5ct: using qt5ct plugin qt5ct: D-Bus global menu: no currently unsupported V4L2 control 0x9a0913 currently unsupported V4L2 control 0x9a0916 currently unsupported V4L2 control 0x9a0917 currently unsupported V4L2 control 0x9a0918 currently unsupported V4L2 control 0x9a0919 currently unsupported V4L2 control 0x9a091a Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG) Unhandled V4L2 format 'H.264': 0x34363248 (H264) Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG) Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU) Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY) Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12) Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12) Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21) Unhandled V4L2 format '32-bit BGRA/X 8-8-8-8': 0x34524742 (BGR4) Can't handle framesizing type 3 Segmentation fault

openastroproject commented 4 years ago

Can you point me to the exact camera you're using for this issue?

Thanks.

sidersc commented 4 years ago

Raspberry Pi HQ camera on an 8GB Raspberry Pi 4.

openastroproject commented 4 years ago

Are you able to run the application in a debugger (gdb?) and give a backtrace for the segfault? Unfortunately I can't test it myself as I don't have such a camera.

sidersc commented 4 years ago

Sorry for the delay - it wasn't till this weekend I had free time. I have used gdb to run oacapture and examine the backtrace:

0 0x00061588 in ?? ()

1 0x00069f8c in ?? ()

2 0x00074a9c in ?? ()

3 0x0008272c in ?? ()

4 0xb2df1244 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5

5 0xb2dfb844 in QSignalMapper::mapped(int) () from /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5

6 0xb2dfce90 in QSignalMapper::map(QObject*) () from /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5

7 0xb2df1244 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5

8 0xb356dd58 in QAction::triggered(bool) () from /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5

9 0xb3570774 in QAction::activate(QAction::ActionEvent) () from /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5

Backtrace stopped: previous frame identical to this frame (corrupt stack?)

openastroproject commented 4 years ago

I've now tried this myself with the HQ camera and it appears to work, at least to a certain point. The only frame format that works for me is YUV420P. Other frame formats work for other V4L2 cameras so I'm not sure what's going on with this specific camera.

sidersc commented 4 years ago

I can't find anyplace to set YUV420P as an option (that isn't just grayed out and unelectable).

openastroproject commented 4 years ago

I've committed more changes today that make this camera work for me in all offered frame formats (RGB, BGR, YUV420P, YUYV amd UYVY) and improved the colour conversion for the last two. Tested with both the old camera and the HQ model. So once v1.8.0 is released this should fix things for you.

sidersc commented 4 years ago

Sweet! And many thanks. What's the ETA on v1.8.0?

totoantibes commented 3 years ago

Hi i am running on a Rpi3b+ (also on a 2B) the HQ camera. works well with raspistill and raspivid. also I am able to see it via qv4l2. however with oacapture (latest 1.8.0) I still have the unhandled formats reported in this post although i am not getting the seg fault. only the unhandled formats and permissioned not permitted as per below:

currently unsupported V4L2 control 0x9a0903 currently unsupported V4L2 control 0x9a0913 currently unsupported V4L2 control 0x9a0916 currently unsupported V4L2 control 0x9a0917 currently unsupported V4L2 control 0x9a0918 currently unsupported V4L2 control 0x9a0919 currently unsupported V4L2 control 0x9a091a Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG) Unhandled V4L2 format 'H.264': 0x34363248 (H264) Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG) Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU) Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY) Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12) Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12) Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21) Unhandled V4L2 format '32-bit XBGR 8-8-8-8': 0x34325852 (RX24) libv4l2: error turning on stream: Operation not permitted VIDIOC_STREAMON: Operation not permitted

any idea as to what i am missing? other clue: cheese says : Failed to allocate required memory.: gstv4l2src.c(658): gst_v4l2src_decide_allocation (): /GstCameraBin:camerabin/GstWrapperCameraBinSrc:camera_source/GstBin:bin28/GstV4l2Src:v4l2src1: Buffer pool activation failed

openastroproject commented 3 years ago

Both the standard and HQ cameras definitely both worked for me, but there was some weirdness relating to the pool of buffers for image transfer at some point. I have a feeling it can be resolved by changing the RPi configuration somewhere. But off the top of my head I can't recall what the change was. I'll check my systems to see if I can find out.

openastroproject commented 3 years ago

Ok, can you run raspi-config and under the performance settings make sure that the memory available for the GPU is at least 256?

If you need to change it then a reboot may be required to make the change come into effect. I'm not sure.

totoantibes commented 3 years ago

Thx. Just tried that setting but to no avail. 256 and 512 did not work

openastroproject commented 3 years ago

I can't think of any other reason this wouldn't work at the moment. Can you give me more details about exactly which hardware and OS you're using? Perhaps I can duplicate it here.

totoantibes commented 3 years ago

well - i ended up reinstalling OS from scratch (astroberry.io)

uname -a
5.4.83-v7+ #1379 SMP Mon Dec 14 13:08:57 GMT 2020 armv7l GNU/Linux

and got it to work (GPU Mem at 512). I still have the following messaging in the terminal:

currently unsupported V4L2 control 0x9a0903
currently unsupported V4L2 control 0x9a0913
currently unsupported V4L2 control 0x9a0916
currently unsupported V4L2 control 0x9a0917
currently unsupported V4L2 control 0x9a0918
currently unsupported V4L2 control 0x9a0919
currently unsupported V4L2 control 0x9a091a
Unhandled V4L2 format 'JFIF JPEG': 0x4745504a (JPEG)
Unhandled V4L2 format 'H.264': 0x34363248 (H264)
Unhandled V4L2 format 'Motion-JPEG': 0x47504a4d (MJPG)
Unhandled V4L2 format 'YVYU 4:2:2': 0x55595659 (YVYU)
Unhandled V4L2 format 'VYUY 4:2:2': 0x59555956 (VYUY)
Unhandled V4L2 format 'Y/CbCr 4:2:0': 0x3231564e (NV12)
Unhandled V4L2 format 'Planar YVU 4:2:0': 0x32315659 (YV12)
Unhandled V4L2 format 'Y/CrCb 4:2:0': 0x3132564e (NV21)
Unhandled V4L2 format '32-bit XBGR 8-8-8-8': 0x34325852 (RX24)

but preview in the oacapture window shows the preview of the HQ camera

When hitting record i get the additional msg:

libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

I also was able to record a SER file.

So maybe we can close it again.

Thanks

openastroproject commented 3 years ago

Yes, those are all debug messages for stuff that isn't supported yet or needs sorting out, but they shouldn't break anything for you so I think this can be closed now.

kigege commented 3 years ago

Dear, I still have trouble using Raspberry HQ cam with Oacapture... I can use the program with an USB cam but not with the HQ cam. It could be verry interesting to be able to use the HQ cam also. I use the Astroberry project including Oacapture 1.9.0 (on the openastroproject.org download I see only the 1.8.0 version??) is it a real version from your project? When I try to use HQ cam, nothing happens... The camera is found, I can connect to the camera, adjust parameters but I don't have any image. If I try to take a capture, no capture is taken and the stop button don't stop it. Have you any idea of the problem? Thank you for your efforts for this verry interesting project! Many thanks in advance!

IoTingIt commented 2 years ago

Kigege, I think we just needs to wait until it is supported. Seems like Astro Project is trying to make this work, but they need time. Not ideal, I know. I want this to work badly too.

ikeysolomon commented 7 months ago

Any movement on this? I would like to use a raspberry pi HQ cam with oacapture too. Regards Sam