// Get the first camera found. static bool CameraGrab() { UInt32 connected = 0; tCameraInfo[] list = new tCameraInfo[1]; return(Pv.CameraList(list, 1, ref connected) >= 1); }
// Get the UID and Serial Number of the first camera listed. static bool CameraGet(ref tCamera Camera) { UInt32 count, connected = 0; tCameraInfo[] list = new tCameraInfo[1]; if ((count = Pv.CameraList(list, 1, ref connected)) != 0) { Camera.UID = list[0].UniqueId; return(true); } else { return(false); } }
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."); } }
// get the UID and Serial Number of the first camera listed. static bool CameraGrab(ref tCamera Camera) { UInt32 count, connected = 0; tCameraInfo[] list = new tCameraInfo[1]; if ((count = Pv.CameraList(list, 1, ref connected)) != 0) { Camera.UID = list[0].UniqueId; Camera.Serial = list[0].SerialString; Console.WriteLine("Grabbing camera: {0}", Camera.Serial); return(true); } else { return(false); } }
// Get the UID and Serial number of the first camera listed. static bool CameraGrab() { UInt32 count, connected = 0; tCameraInfo[] list = new tCameraInfo[1]; if ((count = Pv.CameraList(list, 1, ref connected)) != 0) { GCamera.UID = list[0].UniqueId; GCamera.Serial = list[0].SerialString; Console.WriteLine("Camera {0} grabbed. ", GCamera.Serial); return(true); } else { return(false); } }
// Get the UID and Serial Number of the first camera listed. static bool CameraGet() { UInt32 count, connected = 0; tCameraInfo[] list = new tCameraInfo[1]; count = Pv.CameraList(list, 1, ref connected); if (count == 1) { GCamera.UID = list[0].UniqueId; GCamera.Serial = list[0].SerialString; Console.WriteLine("Got camera: {0}", GCamera.Serial); return(true); } else { return(false); } }
protected void OnCameraConnectionChanged(IntPtr context, tInterface iface, tLinkEvent evt, UInt32 uniqueId) { bool connected = (evt == tLinkEvent.eLinkAdd); Camera camera; if (connected) { tCameraInfo cameraInfo = new tCameraInfo(); tErr err = Pv.CameraInfo(uniqueId, ref cameraInfo); if (err != tErr.eErrSuccess) { throw new PvException(err); } camera = new Camera(cameraInfo); cameras.Add(camera); } else { camera = cameras.Find(c => c.UniqueId == uniqueId); } if (camera != null && (CameraConnected != null && connected) || (CameraDisconnected != null && !connected)) { CameraConnectionHandler eventHandler = connected ? CameraConnected : CameraDisconnected; Delegate[] delegates = eventHandler.GetInvocationList(); foreach (CameraConnectionHandler handler in delegates) { DispatcherObject dispatcherObject = handler.Target as DispatcherObject; if (dispatcherObject != null && !dispatcherObject.CheckAccess()) { dispatcherObject.Dispatcher.Invoke(DispatcherPriority.DataBind, handler, camera); } else { handler(camera); } } } }
public Camera(tCameraInfo cameraInfo) { this.cameraInfo = cameraInfo; callback = OnFrameReady; }
static void ListingCameras(ref in_addr Camera) { UInt32 MaxCameraList = 20; tCameraInfo[] CameraList = new tCameraInfo[MaxCameraList]; UInt32 CameraNum = 0; UInt32 CameraRle; UInt32 Zero = 0; bool gstop = true; while (gstop) { Console.WriteLine("***********************************"); // Get list of reachable cameras. CameraNum = Pv.CameraList(CameraList, MaxCameraList, ref Zero); // Store how many cameras listed are reachable. CameraRle = CameraNum; // Append the list of unreachable cameras. if (CameraNum < MaxCameraList) { CameraNum += Pv.CameraListUnreachable(CameraList, (MaxCameraList - CameraNum), ref Zero); } if (CameraNum > 0) { // Go through the number of cameras detected. for (UInt32 i = 0; i < CameraNum; i++) { if (i < CameraRle) { // Get the camera's IP configuration. if ((Camera.lErr = Pv.CameraIpSettingsGet(CameraList[i].UniqueId, ref Camera.Conf)) == tErr.eErrSuccess) { Camera.S_addr = Camera.Conf.CurrentIpAddress; System.Net.IPAddress Address = new IPAddress(Camera.S_addr); // Display the camera info. Console.Write("{0}- {1} - Unique ID = {2} IP@ = {3}", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId, Address); // Check to see if the camera is being used. if (CameraList[i].PermittedAccess == 6) { Console.WriteLine(" [Available]"); } else { Console.WriteLine(" [In use]"); } Console.WriteLine(); } else { Console.Write("{0}- {1} - Unique ID = {2} [Unavailable] ", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId); } } else { Console.Write("{0}- {1} - Unique ID = {2}", CameraList[i].SerialString, CameraList[i].DisplayName, CameraList[i].UniqueId); } } if (CameraNum != CameraRle) { Console.WriteLine("Camera is unreachable."); } } else { Console.WriteLine("There is no camera detected."); } // Wait a certain amount of time before checking again. Thread.Sleep(1500); } }
public Camera(tCameraInfo cameraInfo) { this.heartbeatTimer = new Timer(Heartbeat, null, 100, 100); this.cameraInfo = cameraInfo; this.callback = new tFrameCallback(OnFrameReady); }