예제 #1
0
        static void Main(string[] args)
        {
            tErr err = 0;

            // Initialize the API.
            if ((err = Pv.Initialize()) == 0)
            {
                tLinkCallback lLinkCB = new tLinkCallback(LinkCB);

                // Register callbacks.
                Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero);
                Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero);

                // Wait for the user to terminate or to unplug the camera.
                WaitForEver();

                // Unregister the callbacks.
                Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd);
                Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove);

                // Uninitialize the API.
                Pv.UnInitialize();
            }
            else
            {
                Console.Write("Failed to initialize the API : ");
                Console.WriteLine(err);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            tErr err = 0;

            // Initialize the API.
            if ((err = Pv.Initialize()) == 0)
            {
                tLinkCallback lLinkCB = new tLinkCallback(LinkCB);

                // Register callbacks.
                Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero);
                Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero);

                WaitForCamera();

                if (CameraGrab())
                {
                    if (CameraSetup())
                    {
                        if (CameraStart())
                        {
                            Console.WriteLine("The camera will be streaming for the next 10 seconds.");
                            Thread.Sleep(10000);
                            CameraStop();
                        }
                        else
                        {
                            Console.WriteLine("The camera failed to start streaming.");
                        }

                        CameraClose();
                    }
                    else
                    {
                        Console.WriteLine("The camera could not be setup.");
                    }
                }
                else
                {
                    Console.WriteLine("The was no camera grabbed.");
                }


                // Unregister the callbacks.
                Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd);
                Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove);

                // Uninitialize the API.
                Pv.UnInitialize();
            }
            else
            {
                Console.Write("Failed to initialize the API : ");
                Console.WriteLine(err);
            }
        }
예제 #3
0
 public void dispose()
 {
     Started = false;
     // Unregister the callbacks.
     Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd);
     Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove);
     CameraClose();
     // Uninitialize the API.
     Pv.UnInitialize();
     Inited = false;
 }
예제 #4
0
        static void Main(string[] args)
        {
            tErr err = 0;

            // Initialize the API.
            if ((err = Pv.Initialize()) == 0)
            {
                tCamera       Camera  = new tCamera();
                tLinkCallback lLinkCB = new tLinkCallback(LinkCB);


                // Add callbacks for camera events.
                if (Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero) != 0)
                {
                    Console.WriteLine("Failed to register the callback.");
                }
                if (Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero) != 0)
                {
                    Console.WriteLine("Failed to register the callback.");
                }

                // Wait for a camera to be plugged in.
                WaitForCamera();

                // Grab a camera from the list.
                if (CameraGrab(ref Camera))
                {
                    // Setup the camera.
                    if (CameraSetup(ref Camera))
                    {
                        DoSnap(ref Camera);
                        DoSnap(ref Camera);
                        DoStream(ref Camera);
                        DoStream(ref Camera);
                        DoSnap(ref Camera);
                        DoStream(ref Camera);
                        DoStream(ref Camera);

                        // Unsetup the camera.
                        CameraUnsetup(ref Camera);
                    }

                    else
                    {
                        Console.WriteLine("Camera {0} failed to be setup.", Camera.UID);
                    }
                }
                else
                {
                    Console.WriteLine("Failed to find a camera.");
                }

                // Remove callbacks.
                if (Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd) != 0)
                {
                    Console.WriteLine("Failed to unregister the callback.");
                }
                if (Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove) != 0)
                {
                    Console.WriteLine("Failed to unregister the callback.");
                }

                // Uninitialize the API.
                Pv.UnInitialize();
            }
            else
            {
                Console.Write("Failed to initialize the API.");
                Console.WriteLine(err);
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            tErr err = 0;


            // Initialize the API.
            if ((err = Pv.Initialize()) == 0)
            {
                tCamera       Camera  = new tCamera();
                tLinkCallback lLinkCB = new tLinkCallback(LinkCB);


                // Add callbacks for camera events.
                if (Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero) != 0)
                {
                    Console.WriteLine("Failed to register callback.");
                }
                if (Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero) != 0)
                {
                    Console.WriteLine("Failed to register callback.");
                }


                WaitForCamera();

                if (CameraGrab(ref Camera))
                {
                    if (CameraSetup(ref Camera))
                    {
                        // Stream as long as CTRL C isn't pressed.
                        while (close == false)
                        {
                            if (CameraStart(ref Camera))
                            {
                                Console.WriteLine("Camera is now streaming.");

                                // Stream the Camera until the use stops it.
                                Abort();
                                CameraStop(ref Camera);
                            }

                            else
                            {
                                Console.WriteLine("Failed to start the streaming process.");
                            }

                            CameraClose(ref Camera);
                        }
                    }

                    else
                    {
                        Console.WriteLine("Camera {0} failed to be setup.", Camera.UID);
                    }
                }
                else
                {
                    Console.WriteLine("Failed to find a camera.");
                }

                //remove callbacks
                if (Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd) != 0)
                {
                    Console.WriteLine("Failed to unregister the callback.");
                }
                if (Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove) != 0)
                {
                    Console.WriteLine("Failed to unregister the callback.");
                }


                Pv.UnInitialize();
            }
            else
            {
                Console.Write("Failed to initialize the API : ");
                Console.WriteLine(err);
            }

            Thread.Sleep(800);
        }