Reputation: 21
I am currently working with the mono run-time on a raspberry pi (B). I use Visual Studio Express 2012 for Windows Desktop. What i basically want to achieve is to save a series of pictures from a webcam (Logitech C270) to a .jpg file.
I found a project that seems to do just what i need: http://www.raspberry-sharp.org/romain-flechner/2012/10/projects/use-a-webcam-plugged-in-a-raspberry-pi-with-mono-in-c-using-raspberrycam/ So I installed it via NuGet into my project and copied the code sample:
Cameras cameras = Cameras.DeclareDevice()
.Named(“Camera 1″).WithDevicePath(“/dev/video0″)
.Memorize();
cameras.Get(“Camera 1″).SavePicture(new PictureSize(640, 480), “/var/www/test.jpg”, 20);
As written in the instructions on the project page, I copied the RaspberryCam.so into the /lib directory (I also copied it to /Lib for that matter). Then I downloaded the built files (my.exe, RaspberryCam.dll) to my Raspberry PI.
Now here's my problem: Whenever I try to execute my program with mono I get a DllNotFoundException for RaspberryCam.so.
I added my project path to /etc/ld.so.conf and ran ldconfig but that doesn't help.
I also tried running mono in debug mode (MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono /var/www/my.exe) and it appears to be searching for "libRaspberryCam.so", so I copied the /lib/RaspberryCam.so to /lib/libRaspberryCam.so, but that didn't change anything either.
BTW i changed the access rights of the .so file to 755 (read, write, execute for root and read, execute for world).
To be honest with you, I don't really know much about DLL-Import stuff so i could just be making some dumb mistake here. However I've already written a comment in the raspberrycam project page last week but I didn't get any answer yet.
Can anyone help me with this matter?
Thanks Dominik
Edit: The Code of the actual DLLImport is from the Raspberrycam project "RaspberryCamInterop.cs":
using System;
using System.Runtime.InteropServices;
namespace RaspberryCam.Interop
{
public class RaspberryCamInterop
{
[DllImport("RaspberryCam.so", EntryPoint = "TakePicture")]
public static extern PictureBuffer TakePicture(string device, uint width, uint height, uint jpegQuantity);
[DllImport("RaspberryCam.so", EntryPoint = "OpenCameraStream")]
public static extern IntPtr OpenCameraStream(string device, uint width, uint height, uint fps);
[DllImport("RaspberryCam.so", EntryPoint = "CloseCameraStream")]
public static extern void CloseCameraStream(IntPtr src);
[DllImport("RaspberryCam.so", EntryPoint = "ReadVideoFrame")]
public static extern PictureBuffer ReadVideoFrame(IntPtr src, uint jpegQuantity);
[DllImport("RaspberryCam.so", EntryPoint = "GrabVideoFrame")]
public static extern PictureBuffer GrabVideoFrame(IntPtr src);
}
}
Edit 2: It appears to be some problem with the soft-float wheezy. I have now installed the standard hard-float raspbian (as it was written in the guide on the project page: http://www.raspberry-sharp.org/eric-bezine/2012/10/mono-framework/installing-mono-raspberry-pi/) and it works, well it isn't particularly fast but it does save a picture. I find it a bit irritating that they used the hard-float raspbian image even though mono isn't compatible with the ARM hard-float abi. In the mono installation guide they don't mention any hard-float patch either and I've even found some workarounds in the source code of the RaspberryCam project, so they did notice the bugs related with running mono on hard-float abi.
Snippet from "PicturesCache.cs"
//Timespan bug with ARM version of MONO, so we will use int in milliseconds
private readonly int duration;
However, I'm going to stick with the soft-float wheezy and just use a tool called uvccapture in collaboration with some shell scripts to do the job.
Yet I am still grateful for any advice or solution from you.
Upvotes: 2
Views: 2078
Reputation: 21
I had the same exception and it got resolved by copying RaspberryCam.so into /usr/lib (as opposed to the root /lib)
Upvotes: 0
Reputation: 11
What is working for me: I copied the lib in the .exe folder and renamed it as libRaspberryCam.so.
On my side, quality is very poor. I can't configure the camera from this lib.
Upvotes: 1
Reputation: 36
Did you try with
$sudo make
$sudo make install
?
Verify acces right to RaspberryCam.so and fix it a chmod.
Bye
Upvotes: 0