private void SetDevice(DUODevice newDevice) { if (device != null) { device.DUOFrameReceived -= DUOFrameReceivedHandler; device.DUODeviceStatusChanged -= DUODeviceStatusChangedHandler; } if (newDevice != null) { newDevice.DUOFrameReceived += DUOFrameReceivedHandler; newDevice.DUODeviceStatusChanged += DUODeviceStatusChangedHandler; for (int i = 0; i < 2; i++) { if (images[i] == null) { continue; } images[i].SetBitmapResolution((uint)newDevice.FrameWidth, (uint)newDevice.FrameHeight); } } else { for (int i = 0; i < 2; i++) { if (images[i] == null) { continue; } images[i].SetBitmapResolution(0, 0); } } device = newDevice; }
private void Stop(DUODevice device) { if (timer != null) { timer.Stop(); } }
static void DUODeviceStatusChanged(DUODevice sender, bool isRunning) { if (isRunning) { Console.WriteLine("[START DUO DEVICE]"); } else { Console.WriteLine("[STOP DUO DEVICE]"); } }
private void DUODeviceStatusChangedHandler(DUODevice sender, bool isRunning) { if (isRunning) { Start(sender); } else { Stop(sender); } }
private void Start(DUODevice device) { if (timer != null) { timer.Start(); } else { lock (updateLock) { needToStart = true; } } }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { duoDevice = new DUODevice(); frameViewer.Device = duoDevice; duoDevice.Resolution = new DUOResolutionInfo() { width = 320, height = 240, binning = DUOBinning.DUO_BIN_HORIZONTAL2 | DUOBinning.DUO_BIN_VERTICAL2, fps = 30 }; duoDevice.Start(); duoDevice.Exposure = 100; duoDevice.Gain = 10; }
private void DUOFrameReceivedHandler(DUODevice sender, ref DUOFrame pFrameData) { lock (updateLock) { updated = true; if (images[0] != null) { images[0].SetDUOImageData(pFrameData.leftData); } if (images[1] != null) { images[1].SetDUOImageData(pFrameData.rightData); } } }
static void DUOFrameReceived(DUODevice sender, ref DUOFrame pFrameData) { frameCount++; Console.WriteLine("Frame ID: {0}, Timestamp: {1}", frameCount, pFrameData.timeStamp); if (pFrameData.IMUPresent) { for (int i = 0; i < pFrameData.IMUSamples; i++) { Console.WriteLine(" Sample #{0}", i + 1); Console.WriteLine(" Timestamp: {0}", pFrameData.IMUData[i].timeStamp); Console.WriteLine(" Acceleration : ({0}:{1}:{2})", pFrameData.IMUData[i].accelData[0], pFrameData.IMUData[i].accelData[1], pFrameData.IMUData[i].accelData[2]); Console.WriteLine(" Gyro : ({0}:{1}:{2})", pFrameData.IMUData[i].gyroData[0], pFrameData.IMUData[i].gyroData[1], pFrameData.IMUData[i].gyroData[2]); Console.WriteLine(" Temperature : {0} C", pFrameData.IMUData[i].tempData); } } }
static void Main(string[] args) { Console.WriteLine("Press Any Key to Create DUODevice"); Console.ReadKey(); DUODevice device = new DUODevice(); Console.WriteLine(device); Console.WriteLine("\nPress Any Key to Start Capture"); Console.ReadKey(); device.DUODeviceStatusChanged += DUODeviceStatusChanged; device.DUOFrameReceived += DUOFrameReceived; device.Start(); Console.WriteLine("\nPress Any Key to Stop Capture"); Console.ReadKey(); device.Stop(); device.Dispose(); }