public CameraParams(Videoinsight.LIB.Camera _camera, int _w, int _h, int _displayRow, int _displayCol, int _surfaceIndex, IntPtr _pSurface, D3DImage _d3dImage = null) { camera = _camera; Width = _w; Height = _h; DisplayRow = _displayRow; DisplayCol = _displayCol; SurfaceIndex = _surfaceIndex; pSurface = _pSurface; d3dImage = _d3dImage; }
public Videoinsight.LIB.Camera GetCamera(int id) { Videoinsight.LIB.Camera cam = null; foreach (Videoinsight.LIB.Camera camera in CameraList) { if (camera.CameraID == id) { cam = camera; } } return(cam); }
private Videoinsight.LIB.Camera GetCamera(int id) { Videoinsight.LIB.Camera camera = null; foreach (Videoinsight.LIB.Camera cam in vm.CameraList) { if (id == cam.CameraID) { camera = cam; break; } } return(camera); }
void ServerController_Connected(VIServerController serverController, EventArgs e) { // run on UI thread Application.Current.Dispatcher.Invoke(() => { // Disable the Connect Button since, at this time, we can't disconnect/reconnect ConnectPB.IsEnabled = false; // get the list of cameras on this server ObservableCollection <Videoinsight.LIB.Camera> cameraList; m_serverController.GetCameraList(out cameraList); // Set the camera list to the View Model for this app vm.CameraList = cameraList; // open dialog that allows you to select the cameras that you want to stream CameraSelection dlg = new CameraSelection(cameraList); dlg.ShowDialog(); // After the dialog is closed, build ViewModel's ActiveDictionary, which is the dictionary that contains the list of the cameras that were marked to be streamed // in the dialog above (the cameras that were checked) vm.ResetActiveDictionary(); // clear the ActiveDictionary foreach (CheckedListItem <Videoinsight.LIB.Camera> cam in dlg.vm.CameraList) { if (cam.IsChecked) { vm.ActiveDictionary.Add(cam.Item.CameraID, new CameraParams(cam.Item, 0, 0, 0, 0, -1, IntPtr.Zero)); } } // Figure out the size of the array of display panels needed to show all the cameras in the Active Dictionary int cols = 0; int rows = 0; GetMatrixDimensions(vm.ActiveDictionary.Count, ref rows, ref cols); // this is a really dumb function that sets the number of rows and cols depending on the number of cameras to be displayed if (m_surfArray != null) { m_surfArray.Shutdown(); m_surfArray = null; } // build the SurfArray = this is the 2D "array" of D3D9 panels that are used to display the decoded images m_surfArray = new SurfArray(rows, cols, DisplayContainer); // configure the behavior and look of the Surface Array Color panelSelectedColor = Colors.Red; Color panelUnselectedColor = Colors.Gray; Color panelTitleTextColor = Colors.White; Color surfArrayBackgroundColor = Colors.Gray; double titleFontSize = 12.0; double panelMargin = 10.0; m_surfArray.SetDisplayParams(panelSelectedColor, panelUnselectedColor, panelTitleTextColor, titleFontSize, surfArrayBackgroundColor, panelMargin); m_surfArray.SetPanelsSelectable(true); // if true, the callback function is called when a panel is clicked // set the callback function that is called whenever a particular panel is clicked m_surfArray.SetCallback(CallbackFunction); // assign each camera to a position in the SurfArray int index = 0; foreach (KeyValuePair <int, CameraParams> entry in vm.ActiveDictionary) { int id = entry.Key; //CameraParams cp = entry.Value; if (index >= vm.ActiveDictionary.Count) { break; } int r = index / cols; int c = index - (r * cols); Videoinsight.LIB.Camera cam = vm.GetCamera(id); if (cam != null) { m_surfArray.AssignCameraToPosition(r, c, (uint)cam.CameraID, m_defaultWidth, m_defaultHeight, cam.CameraName, false); } entry.Value.DisplayRow = r; entry.Value.DisplayCol = c; entry.Value.SurfaceIndex = m_surfArray.GetSurfaceIndex(r, c); uint w = m_defaultWidth; uint h = m_defaultHeight; bool useAlpha = false; IntPtr pSurf = IntPtr.Zero; m_surfArray.GetSurface_Params(entry.Value.SurfaceIndex, out pSurf, out w, out h, out useAlpha); entry.Value.Width = (int)w; entry.Value.Height = (int)h; entry.Value.pSurface = pSurf; entry.Value.d3dImage = m_surfArray.GetD3DImage(entry.Value.DisplayRow, entry.Value.DisplayCol); bool success = CudaTools.DX_GpuAddD3DSurface(m_cudaUtil, id, entry.Value.pSurface, entry.Value.Width, entry.Value.Height); //if (vm.ActiveDictionary.ContainsKey(id)) // vm.ActiveDictionary[id] = cp; //else // Debug.Print("Shit"); index++; } // See how much memory is left on GPU ulong totMem = 0; ulong freeMem = 0; CudaTools.Cuda_GetDeviceMemory64(m_cudaUtil, out totMem, out freeMem); //MessageBox.Show("Total = " + totMem.ToString() + " Free = " + freeMem.ToString()); // command server to start streaming List <int> cameraIDList = new List <int>(); foreach (int id in vm.ActiveDictionary.Keys) { cameraIDList.Add(id); } m_serverController.GetLive(cameraIDList); }); }