private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { CameraFactory.RemoveAllCameras(); try { SrVision.SRV_Dispose(); } catch (Exception ex) { Logging.Error(ex); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //加载训练集 try { SrVision.SRV_Init(SystemParams.SrDetFilePath); } catch (Exception ex) { Logging.Error(ex); MessageBox.Show(ex.Message); } }
/// <summary> /// 执行场景 /// </summary> /// <param name="scene"></param> private RunStatus ExecuteScene(Scene scene, out string visionResult, out int glassesType) { visionResult = ""; glassesType = -1; if (RunningWindow1.Content != scene.VisionFrame.RunningWindow) { RunningWindow1.Content = scene.VisionFrame.RunningWindow; } RunStatus runStatus = scene.Execute(2000, out visionResult); ShowResult(runStatus, visionResult); if (runStatus.Result == EResult.Accept) { if (File.Exists(SystemParams.DefaultImageFile)) { try { try { glassesType = SrVision.SRV_Run(SystemParams.DefaultImageFile); } catch (Exception ex) { Logging.Error(ex); } UpdateGlassesType(glassesType); } catch (Exception) { UpdateGlassesType(-1); } } } else if (runStatus.Result == EResult.Error) { UpdateGlassesType(-1); MessageBox.Show(runStatus.Message); } else { UpdateGlassesType(-1); } return(runStatus); }