start webcam

Oct 11, 2008 at 10:55 AM
Hi@all,
I have some problems with the integration of my webcam.

First: I had/have a problem to integrate the webcamlib.dll, but this is described in an other thread, what actualy is no help for me.

Second: I list up my cam with TouchlessMgr cam = new TouchlessMgr() => Cameras() but I cant get a CurrentImage() cause the cam is not startet.
I searched in the Touchlesslib but I didn't find a method, that's for starting the webcam.

How I use the webcamlib.dll if I don't know which methods and objects exist??

Sorry for these absolutely newbie questions and for my bad english :) Hope you can help me!

Lithic[newbie]
Oct 11, 2008 at 10:56 AM
fyi: my webcam works fine in the touchless demo!
Coordinator
Oct 11, 2008 at 4:23 PM
Hi Lithic:

You should never need to use any methods in webcamlib.dll.  All of the methods there are exposed in TouchlessLib to managed code.  The step you are missing is to set the Camera property on TouchlessMgr to one of the Cameras returned from the Cameras() method.  That will start the webcam and allow you to get the current image from the Camera you selected.
Sep 2, 2009 at 6:54 PM
Edited Sep 2, 2009 at 6:56 PM

Hi Hypermoose,

i try again to integrate my  again, after try out WIA/Direct show with result, but not with satisfaction.

Now a new try with an error, I could not fix.

 


TouchlessMgr manager = new TouchlessMgr();

 

My summary error:

"System.EntryPointNotFoundException wurde nicht behandelt.
  Message="Der Einstiegspunkt Initialize wurde nicht in der DLL WebCamLib.dll gefunden."
  Source="TouchlessLib""

Message translation "There's no EntryPoint Initialize in the DLL WebCamLib.dll".

 

My Header includes:

using TouchlessLib;
using Webcamlib;

 

How should I integrate the TouchlessLib?? I saw the samples, but they are to complex to understand all details. I need a short discription like a checkliste(1. using TouchlessLIb 2. Get cam with TouchlessMgr....) The interaktion with the cam, I will get by autodidactic.

 

Many thanks for help and sorry for my §$§="§%()=§$%= english :)

Lithic

Sep 3, 2009 at 11:16 AM

OK, here comes your checklist:

1. Create the manager:

TouchlessMgr manager = new TouchlessMgr();

 

2. Choose your weapons -aehm- camera:

private void initTouchlessCam(TouchlessMgr manager)
        {
            Camera choosenCam = null;
            foreach (Camera cam in manager.Cameras)
            {
                try
                {
                    manager.CurrentCamera = cam;
                    choosenCam = cam;
                }
                catch
                {
                    choosenCam = null;
                }
            }
            if (choosenCam != null)
            {
                choosenCam.OnImageCaptured += new EventHandler(choosenCam_OnImageCaptured);
            }
            else
            {
                MessageBox.Show("no usable camera found");
            }
        }

        private void  choosenCam_OnImageCaptured(object sender, CameraEventArgs e)
        {
            Bitmap currentImage = e.Image;
            if (currentImage != null)
            {
                /* do whatever you want, see TouchlessDemo.drawLatestImage() for example */
            }
        }

 

3. Use manager.AddMarker(...) to add markers and register to the marker.MarkerChanged event to get updates concerning the marker.

Hope this helps,
Florian

Sep 3, 2009 at 4:20 PM
Edited Sep 4, 2009 at 11:23 AM

Thank you for your fast answer!

 

I think I found my mistake. I got the Visual Studio with C#, but without C++ addon, so I can't load the webcam.lib. Am I right thinking that's the reason for System.EntryPointNotFoundException error in WEbcamlib.dll??

No, it's not the reason for the error....

best regards!

Nov 11, 2009 at 7:15 PM

@lithic:

You should not require any special add-ons for the C# Express Edition of Visual Studio in order to interface with this library.  You should remove the "using Webcamlib;" directive as this is probably not necessary.  Also make sure that you've added a Reference to the TouchlessLib.dll in your project.  Go over to the Solution Explorer, right click on the "References" folder, and pick "Add Reference".  Then after that window loads (it may take a minute), go to the Browse tab and select your TouchlessLib.dll file in there.

If you are getting this problem when you hit F5 to compile, you will need to make sure that the TouchlessLib.dll file is located in your Project's bin/Debug folder along side of the debug .exe file.

Good luck!