On board Raspberry Pi Camera not working with Raspbian Stretch

Obviously I am looking at the C# code :stuck_out_tongue:

The issue is at the moment where c# is referencing an externall DLL using these lines:

           /// <summary>
           /// The CloseCameraStream
           /// </summary>
           /// <param name="source">The <see cref="IntPtr"/></param>
           [DllImport("CameraCaptureV4L", EntryPoint = "CloseCameraStream")]
           public static extern void CloseCameraStream(IntPtr source);

there is an issue finding the file, but its there, Iā€™ve made sure it has permissionsā€¦ I may try running the makefile on the source on stretch and compile on this platform and see if it changes - if not Ill see if I can get in touch with the guy whoā€™s code it uses.

Hi, David.
Take a look at this article http://www.mono-project.com/docs/advanced/pinvoke/dllnotfoundexception/
Maybe it will help you troubleshoot this issue (at least you should be able to see where exactly mono is looking for the library).

@Bounz - Thanks, thatā€™s the link I was reading last night, and how I got those debug logsā€¦ thinking about it this morning though due to my grep statement - I may be missing lines if its another library being loaded - so will try dumping the log to a file later and then looking at it in an editor.

got furtherā€¦ by manually copying the fileā€¦

 cp /usr/local/bin/homegenie/lib/mig/raspbian_libCameraCaptureV4L.so /usr/lib/libCameraCaptureV4L.so

but this then causes a crash:

need to do more investigation - but I need to go cook dinnerā€¦

I tried that earlier too. Is there a permissions issue with that file.

no, thatā€™s not a permissions issue, as its loading it - calling a method and then crashingā€¦ Iā€™ve even built that file on the pi - but its unclear as to the differences to the two files that Gene providesā€¦ need to do more testingā€¦

Im thinking just a re-write might be easier with thisā€¦ which supports .net core tooā€¦

It certainly sounds like it would. The last time the camera module worked in HG was in Mono 3.2 on Raspbian Wheezy and a lot has changed both in Raspbian and Mono since.

As a programmer I imagine thereā€™s nothing worse than trawling through some other programmers work particularly when this work lacks accurate documentation.

Looks like this is the first big challenge for you. The Raspberry Pi board makers provided the ability to add a compact onboard camera which is ideal for integrated HA projects and it would be a shame if HG could not exploit this.

I appreciate that this type of effort takes time and energy and itā€™s great to see people like yourself giving both.

This is a section of the HG startup in Raspbian Wheezy relating to the camera module. I noticed a 10 second delay added after the device is opened. I assume this is to allow time for some other system resource to start.

The other thing I noticed is an allocation of 128mb of GPU memory allocated to the video device. Iā€™m not sure how relevant this is to the current problem

2018-02-14 12:28:00.3984 Debug Adding Interface Media.CameraInput
2018-02-14 12:28:00.4037 Debug Setting Interface options
2018-02-14 12:28:00.4173 Trace Media.CameraInput: Configuration=/dev/video0,640,480,10

2018-02-14 12:28:15.5305 Debug Enabling Interface Media.CameraInput
Testing source module v4l2ā€¦
Testing source module v4l1ā€¦
Testing source module fileā€¦
Testing source module rawā€¦
Testing source module testā€¦
Testing source module v4l2ā€¦
Trying source module v4l2ā€¦
/dev/video0 opened.
Delaying 10 seconds.
2018-02-14 12:28:18.7847 Info Media.CameraInput
2018-02-14 12:28:18.9073 Info Media.CameraInput AV0 Camera Input Widget.DisplayModule homegenie/generic/camerainput

I get the same output in Stetchā€¦ but it then bombsā€¦

The only prob using that new module is that it would initially break integration with h264 etcā€¦

Personally though I would say why do you need a web cam in your HA system, what you actually need is the integration with itā€¦ and the way forward might actually to be to integrate with openCV (the are libā€™s for this) this would then allow integration / actions based on face recognition etcā€¦

Yes having the camera loading as dev/video0 provides little functionality other than being able to view its output. I thought that Gene was going to develop this a bit more at the time but that never happened.

What Iā€™m really trying to do is get to the bottom of the reason why the camera module doesnā€™t function after loading in Stretch but does in Wheezy.

Iā€™m still curious as to why there is a 10 second delay inserted after the camera module loads and goes through its tests in Wheezy but not in Stretch

There is a ten second delay in stretch, I have seen thatā€¦

Looking into this, I can get my camera working with raspistill but not using this driverā€¦

its code I dont understand and low level and not very maintainableā€¦ so unless we find someone versed with c# and low level c on the rpi then I think its time to create a new interface. I hardly see the point though, but will try and take a look at this.

Are you saying you got raspistill working in HG.

Theres plenty of point having the Raspberry Pi camera module working in HG. thereā€™s plenty of Raspberry Pi users out there using the camera module and they are looking at using HG.

MMAL appears to be the backbone of all this. Motion for one is very popular. If you have a look at MotionEyeOS it does the full detection and notification thing all in with the Raspberry Pi.

No, Iā€™m saying raspistill works in stretch on my camera - so I know thats all good.

I understand you may want it - but I have to question the second partā€¦ Agreed there are plenty of pi users with cameraā€™s but are they looking to use HG because it can display a web page with jpgā€™s streamed to itā€¦ and not a H264 / 265 video stream?

Please donā€™t take this the wrong way butā€¦

if you want to use that then use Motion to do that - as thats what its good at - then letā€™s look at how we integrate motionā€™s events with Homegenieā€¦

I donā€™t particularly have the time or inclination to make a camera integrate with hg in the way that was - it feels wrong to be taking a 4mb capture every second or so and then have the web page refreshing every second to pull that imageā€¦ just doesnā€™t smell great when you want lights to turn on when walking in a room with ms latency - not seconds! - however there is a library I linked to which ā€˜couldā€™ be used - I don#t quite like the fact that it proxies wiringPI as this feels wrong - but if it worksā€¦ There is also the mig interface template project that can be used for this or the and happy to help point you in the correct direction.

I have been an bought a HikVision DVR which supports a streaming API - I havenā€™t even written an interface dll for this yet.

Again as you have been quite vocal of how bad you think it is but I think its worth focusing effort on the ā€˜higher priorityā€™ issues - such as the stats db interop dll issue / migrating to a different db engine etc etc.

Again please dont take that the wrong way, just trying to get my thoughts outā€¦

For me, my personal goals are:

Ability to replace interface modules without issues of locked files.
Better code editing experience with intellisense (not necessarlly through the gui)
Hierarchical location supportā€¦ (prototyped -just need to implement)
State Machine Support.
Serialisation of state.

All I was trying to determine was why the camera module was working in HG in one version of Raspbian and not another. That canā€™t be achieved at the moment so Iā€™ll leave it for now.

Iā€™ll keep my postings to the level of other contributors here.

Thanks for your time and efforts.

Iā€™ll keep my postings to the level of other contributors here - why??

If you have an opinion speak up :slight_smile: