On board Raspberry Pi Camera not working with Raspbian Stretch

havent sussed this yet… just not loading the file, despite running

sudo apt-get install libgd2-noxpm-dev -y
chmod 777 /usr/local/bin/homegenie/lib/mig/libCameraCaptureV4L.so
echo /usr/local/bin/homegenie/lib/mig > /etc/ld.so.conf.d/homegenie.conf
sudo ldconfig
sudo ldconfig -p |grep V4L

Maybe if you have a look at the C# source code it may help. Also if nothing obvious shows up a possible starting point would be a look at the last working version of the Raspberry Pi camera module in HomeGenie, in Raspbian Wheezy and make a comparison

I cannot see any obvious difference in the boot sequence between HG v526 in Raspbian Wheezy v Raspbian Stretch.

If you could compare both boots you may be able to see where the loading of the camera module falls down in Stretch.

I’m not a programmer and C# is way out of my league but I can see no logic as to why it’s working in one release of Raspbian and not another. The only thing that comes to mind is a change in the Linux kernel firmware between releases which Gene never addressed.

I’m assuming this is the build that Gene included in the MIG Packager. I’m wondering I’d there could be any clues in here as to why it appears to load but not run.

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: