// Stop the camera from streaming. static void CameraStop() { Console.WriteLine("The streaming is now being stopped."); Pv.CommandRun(GCamera.Handle, "AcquisitionStop"); Pv.CaptureEnd(GCamera.Handle); // Clear the queue. Pv.CaptureQueueClear(GCamera.Handle); }
// Close the camera. static void CameraClose() { // Clear the queue. Console.WriteLine("Clearing the queue..."); Pv.CaptureQueueClear(GCamera.Handle); // close the camera Console.WriteLine("The camera is now closed."); Pv.CameraClose(GCamera.Handle); }
// Close the camera. static void CameraClose() { Thread.Sleep(1000); // Unsetup event channel. Pv.AttrUint32Set(GCamera.Handle, "EventsEnable1", 0); Pv.CameraEventCallbackUnRegister(GCamera.Handle, EventDone); // Clear the queue. Console.WriteLine("Clearing the queue..."); Pv.CaptureQueueClear(GCamera.Handle); // close the camera Console.WriteLine("The camera is now closed."); Pv.CameraClose(GCamera.Handle); }
// Close the camera. static void CameraClose(ref tCamera Camera) { // Dequeue all the frame still queued (this will block until they all have been dequeued). Pv.CaptureQueueClear(Camera.Handle); // Reset the trigger mode. Pv.AttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun"); // Close the camera. Pv.CameraClose(Camera.Handle); Console.WriteLine("camera is closed, deleting the frames now"); // Delete the allocated buffer. Camera.GC.Free(); // Reset the handle. Camera.Handle = 0; }
// Close the camera. static void CameraClose(ref tCamera Camera) { // Reset the trigger mode. Pv.AttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun"); // Clear the queue. Console.WriteLine("Clearing the queue..."); Pv.CaptureQueueClear(Camera.Handle); // Close the camera. Pv.CameraClose(Camera.Handle); Console.WriteLine("Closing the camera."); // Delete the allocated buffer. Camera.GC.Free(); // Reset the handle. Camera.Handle = 0; }
// Snap a frame from the camera. static bool CameraSnap(ref tCamera Camera) { bool result; GCHandle pFrame = GCHandle.Alloc(Camera.Frame, GCHandleType.Pinned); tFrameCallback FrameCB = new tFrameCallback(FrameDummyCB); // Queue the frame. if (Pv.CaptureQueueFrame(Camera.Handle, pFrame.AddrOfPinnedObject(), FrameCB) == 0) { Console.WriteLine("Triggering the camera ..."); // Trigger the capture. if (Pv.CommandRun(Camera.Handle, "FrameStartTriggerSoftware") == 0) { Console.WriteLine("Waiting for the frame to be done ..."); // Wait for the frame to be returned. while (Pv.CaptureWaitForFrameDone(Camera.Handle, pFrame.AddrOfPinnedObject(), 10) == tErr.eErrTimeout) { Console.WriteLine("Still waiting ..."); } // Copy the frame structure back in the frame we have. Camera.Frame = (tFrame)Marshal.PtrToStructure(pFrame.AddrOfPinnedObject(), typeof(tFrame)); // Check the status flag. if (!(result = (Camera.Frame.Status == tErr.eErrSuccess))) { Console.WriteLine("Frame captured un-succesfully {0}", Camera.Frame.Status); } } else { Pv.CaptureQueueClear(Camera.Handle); result = false; } } else { result = false; } pFrame.Free(); return(result); }
// Snap a frame from the camera. static bool CameraSnap(ref tCamera Camera) { bool result; GCHandle pFrame = GCHandle.Alloc(Camera.Frame, GCHandleType.Pinned); tFrameCallback FrameCB = new tFrameCallback(FrameDummyCB); // Adjust packet for optimal preformance. Pv.CaptureAdjustPacketSize(Camera.Handle, 8228); // Queue the frame. if (Pv.CaptureQueueFrame(Camera.Handle, pFrame.AddrOfPinnedObject(), FrameCB) == 0) { // Trigger the capture. if (Pv.CommandRun(Camera.Handle, "FrameStartTriggerSoftware") == 0) { // Then wait for the frame to be returned. if (Pv.CaptureWaitForFrameDone(Camera.Handle, pFrame.AddrOfPinnedObject(), 0) == 0) { // Check the status flag. if (!(result = (Camera.Frame.Status == tErr.eErrSuccess))) { Console.WriteLine("Frame captured un-succesfully {0}.", Camera.Frame.Status); } } else { Pv.CaptureQueueClear(Camera.Handle); result = false; } } else { Pv.CaptureQueueClear(Camera.Handle); result = false; } } else { result = false; } pFrame.Free(); return(result); }
public void EndCapture() { if (!camera.HasValue) { throw new PvException(tErr.eErrUnavailable); } Pv.CaptureQueueClear(this.camera.Value); foreach (GCHandle handle in framePoolHandles) { handle.Free(); } foreach (GCHandle handle in frameBufferHandles) { handle.Free(); } frames = null; Pv.CommandRun(this.camera.Value, "AcquisitionStop"); Pv.CaptureEnd(this.camera.Value); }
// Stop the streaming. static void CameraStop(ref tCamera Camera) { Pv.CommandRun(Camera.Handle, "AcquisitionStop"); Pv.CaptureEnd(Camera.Handle); Pv.CaptureQueueClear(Camera.Handle); }