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); } }
public tErr InitCamera() { tErr err = 0; if (Inited) { return(0); } // Initialize the API. if ((err = Pv.Initialize()) == 0) { lLinkCB = new tLinkCallback(LinkCB); // Register callbacks. Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero); Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero); Inited = true; } else { Console.Write("无法加载相机API,错误代码: "); Console.WriteLine(err); err_string = "无法加载相机API,错误代码: " + err.ToString(); } return(err); }
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); } }
static void Main(string[] args) { tErr err = 0; tCameraInfo[] List = new tCameraInfo[10]; // Initialize the API. if ((err = Pv.Initialize()) == 0) { tCamera Camera = new tCamera(); // Wait for a camera to be detected. WaitForCamera(); // Get info from the camera. CameraGet(ref Camera); if (CameraGrab()) { // Open the camera. if (CameraOpen(ref Camera)) { // Change some attributes. CameraAdjust(ref Camera); // Unsetup the camera. CameraClose(ref Camera); } else { Console.WriteLine("Failed to open camera."); } } else { Console.WriteLine("Failed to grab camera."); } // Uninitialize the API. Pv.UnInitialize(); } else { Console.WriteLine("Failed to initalize."); } }
public GigEVision() { tErr error = Pv.Initialize(); this.connectionChangedCallback = OnCameraConnectionChanged; if (error == tErr.eErrSuccess) { error = Pv.LinkCallbackRegister(this.connectionChangedCallback, tLinkEvent.eLinkAdd, IntPtr.Zero); if (error == tErr.eErrSuccess) { error = Pv.LinkCallbackRegister(this.connectionChangedCallback, tLinkEvent.eLinkRemove, IntPtr.Zero); } } if (error != tErr.eErrSuccess) { throw new PvException(error); } }
static void Main(string[] args) { tErr err = 0; // initialize the API. if ((err = Pv.Initialize()) == 0) { in_addr Camera = new in_addr(); ListingCameras(ref Camera); // Uninitialize the API. Pv.UnInitialize(); } else { Console.WriteLine("Failed to initialize."); } }
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); } }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.Initialize()) == 0) { // Wait for a camera to be detected. WaitForCamera(); // Obtains a camera from the list. if (CameraGet()) { // Open the first camera detected. if (CameraOpen()) { // Set the camera up for triggering. if (CameraSetup()) { // Allows the user to terminate program. SpawnAbortThread(); UInt32 Count = 0; String filename; Console.WriteLine("The camera is ready now, press 'X' to terminate program."); while (close == false) { // Snaps a frame. if (CameraSnap()) { filename = "Snap"; filename += Count++; filename += ".bmp"; if (close == false) { // Saves the snapped frame. if (FrameSave(filename) == false) { Console.WriteLine("Failed to save the image."); } else { Console.WriteLine("Frame saved under filename: {0}", filename); } } } else { Console.WriteLine("Failed to snap an image."); } } // Stop the streaming. CameraStop(); } else { Console.WriteLine("Failed to setup the camera."); } // Close the camera. CameraClose(); } else { Console.WriteLine("Camera {0} failed to be open.", GCamera.UID); } } else { Console.WriteLine("Failed to get a camera."); } Pv.UnInitialize(); } else { Console.Write("Failed to initialize the API : "); Console.WriteLine(err); } Thread.Sleep(800); }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.Initialize()) == 0) { tCamera Camera = new tCamera(); // Wait for a camera to be detected. WaitForCamera(); if (CameraGet(ref Camera)) { // Open the first camera detected. if (CameraOpen(ref Camera)) { // Set the camera up for triggering. if (CameraSetup(ref Camera)) { UInt32 Count = 0; String filename; Console.WriteLine("The camera is ready now. Press Q to quit or S to take a picture."); while (WaitForUserToQuitOrSnap()) { if (CameraSnap(ref Camera)) { filename = "Snap"; filename += Count++; filename += ".bmp"; if (FrameSave(ref Camera, filename) == false) { Console.WriteLine("Failed to save the image."); } else { Console.WriteLine("Frame saved."); } Console.WriteLine("The camera is waiting for a trigger. Press Q to quit or S to take a picture."); } else { Console.WriteLine("Failed to snap an image."); } } } else { Console.WriteLine("Failed to setup the camera."); } CameraClose(ref Camera); } else { Console.WriteLine("Camera {0} failed to be open.", Camera.UID); } } else { Console.WriteLine("Failed to get a camera."); } Pv.UnInitialize(); } else { Console.Write("Failed to initialize the API : "); Console.WriteLine(err); } Thread.Sleep(800); }
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); }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.Initialize()) == 0) { tCamera Camera = new tCamera(); UInt32 FrameCount = 600; // Wait for a camera to be detected. WaitForCamera(); if (CameraGet(ref Camera)) { // Open the first camera. if (CameraOpen(ref Camera)) { // Set the camera up for streaming. if (CameraSetup(ref Camera)) { UInt32 Count = 0; while (Count <= FrameCount) { // Start streaming. if (CameraSnap(ref Camera)) { Console.Write("[{0:000}]", Count); UInt32 status = (UInt32)(Camera.Frame.Status); Console.WriteLine(" Status = {0:00} ", status); Count++; } } CameraStop(ref Camera); } else { Console.WriteLine("Failed to setup the camera."); } CameraClose(ref Camera); } else { Console.WriteLine("Camera {0} failed to be open.", Camera.UID); } } else { Console.WriteLine("Failed to get a camera."); } Pv.UnInitialize(); } else { Console.Write("Failed to initialize the API : "); Console.WriteLine(err); } Thread.Sleep(800); }