With the class AssistantItemFinderMain open in Visual Studio, let's add the variable and amend the methods responsible for the construction and destruction of FrameAnazlyer:
FrameAnalyzer frameAnalyzer;async void InitServices(){// ... frameAnalyzer = await FrameAnalyzer.CreateAsync();frameAnalyzer.Start();frameAnalyzer.OnAnalyzedFrame += FrameAnalyzer_OnAnalyzedFrame;}public void Dispose(){// ...if (frameAnalyzer != null){frameAnalyzer.Stop();frameAnalyzer = null;}}
As you may recall, ProcessNextFrame was the method responsible for passing the next available frame from FrameGrabber and adding it to the queue of FrameAnalyzer. Before this method proceeded, it checked whether it was in a valid state via the