public void CloseCamera() { if (_Camera != null) { _Camera.StopGraph(); _Camera.CloseAll(); _Camera.Dispose(); _Camera = null; } }
/// <summary> /// Cycles from one player to the next /// </summary> void PlayerCycle() { ActivePlayer = Players [m_CurrentPlayerIndex]; CameraSnap.CameraSnapOverTarget(ActivePlayer.transform); if (m_CurrentPlayerIndex >= 3) { m_CurrentPlayerIndex = 0; } else { m_CurrentPlayerIndex++; } }
// Set current camera to camera_device private void SetCamera(IMoniker moniker, Resolution resolution = null) { try { // Makes all magic with camera and DirectShow graph // Close current if it was opened CloseCamera(); if (moniker == null) { return; } // Create camera object _Camera = new CameraSnap(); string _DirectShowLogFilepath = string.Empty; if (!string.IsNullOrEmpty(_DirectShowLogFilepath)) { _Camera.DirectShowLogFilepath = _DirectShowLogFilepath; } // select resolution //ResolutionList resolutions = Camera.GetResolutionList(moniker); if (resolution != null) { _Camera.Resolution = resolution; } // Initialize _Camera.Initialize(moniker); // Build and Run graph _Camera.BuildGraph(); _Camera.RunGraph(); } catch (Exception e) { MessageBox.Show(e.Message, @"Error while running camera"); } }
void Start() { CameraSnap.CameraSnapOverTarget(ActivePlayer.transform); UpdateUI(); }