techyian / MMALSharp

C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera.
MIT License
195 stars 33 forks source link

MMAP gives exception when initialising camera #204

Open martienpoels-bank2loyalty opened 2 years ago

martienpoels-bank2loyalty commented 2 years ago

Hi,

I was realy frustrated about the bullseye 64 bit implementation, which I need to run a onnx recognition under c#. I tried running the new tools libcamera-still and after a few succesfull creation of stills the os reports memory corruption. So that libcamera stuff seems like a nightmare path. Also no C# support zero/nada...

Now I have installed ubuntu server 21.10 64 bit on a pi4b 1Gb. Running "raspistill" works like a charm. So halleluia I thought, I installed v4l-utils and it's output showed mmal devices. Promising....

bcm2835-codec-decode (platform:bcm2835-codec): /dev/video10 /dev/video11 /dev/video12 /dev/media1

bcm2835-isp (platform:bcm2835-isp): /dev/video13 /dev/video14 /dev/video15 /dev/video16 /dev/media0

mmal service 16.1 (platform:bcm2835-v4l2-0): /dev/video0

I installed .dotnet sdk 5.0.401 on the device, including the latest version of MMAL. But unfortunately the lib crashes on initialisation.

mmal: mmal_component_create_core: could not find component 'vc.ril.camera' Unhandled exception. MMALSharp.MMALNotImplementedException: Function not implemented. Unable to create component at MMALSharp.MMALNativeExceptionHelper.MMALCheck(MMAL_STATUS_T status, String message) at MMALSharp.MMALComponentBase.CreateComponent(String name) at MMALSharp.MMALComponentBase..ctor(String name) at MMALSharp.Components.MMALCameraComponent..ctor() at MMALSharp.MMALCamera..ctor() at MMALSharp.MMALCamera.<>c.<.cctor>b__30_0() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at System.Lazy1.get_Value() at MMALSharp.MMALCamera.get_Instance() at PeopleDetectFirmware.MMAL_camera.CameraControl..ctor(Boolean monitorOn, Boolean useRaw, ICameraControl itf, MMALEncoding encodingType, MMALEncoding pixelFormat, Int32 width, Int32 height, Int32 quality) in D:\GitHub_HomeAutomation\ai\PeopleDetectFirmware\PeopleDetectFirmware\MMAL-camera\CameraControl.cs:line 40 at PeopleDetectFirmware.FirmwareCore..ctor() in D:\GitHub_HomeAutomation\ai\PeopleDetectFirmware\PeopleDetectFirmware\FirmwareCore.cs:line 15 at PeopleDetectFirmware.Program.Main() in D:\GitHub_HomeAutomation\ai\PeopleDetectFirmware\PeopleDetectFirmware\Program.cs:line 28 Aborted (core dumped)

relevant output form uname -a 5.13.0-1008-raspi #9-Ubuntu SMP PREEMPT Wed Sep 29 08:27:44 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

I set LD_DEBUG=files and now it shows where it happens:

file=/lib/aarch64-linux-gnu/libmmal.so [0]; needed by /lib/aarch64-linux-gnu/libmmal_core.so [0] (relocation dependency) 12125: mmal: mmal_component_create_core: could not find component 'vc.ril.camera' Unhandled exception.

Any idea what's going on? Am I missing a library that I could check for. Or is just 64bit killing me..

Please help!

techyian commented 2 years ago

Apologies for the late response here. I have been mostly inactive on this project for some time now due to other commitments. MMALSharp is untested on other operating systems apart from Raspbian 32bit pre-Bullseye. Are there raspistill/raspivid implementations included in the Ubuntu distro that you can test against? Also, have you enabled the camera stack in raspiconfig?