Exemplo n.º 1
0
        public void Dispose()
        {
            ShapeData.Dispose();
            MotionData.Dispose();
            ColorData.Dispose();

            Current.Dispose();
            Prev1.Dispose();
            Prev2.Dispose();
        }
Exemplo n.º 2
0
        private void StartStopMarking(object sender, RoutedEventArgs e)
        {
            IsMarking = true;

            SetupPlayer();

            videoCanvas.Focus();

            Thread.Sleep(50);
            HideInstructions();


            new Thread(() =>
            {
                while (IsMarking)
                {
                    //for(var i = 0; i < 500; i++)
                    {
                        if (_decoder == null)
                        {
                            SetupPlayer();
                        }

                        lock (_decoder)
                        {
                            _decoder.Stop();
                            _decoder.ClearBuffer();
                            _decoder.SeekTo(iterator.FrameIndex);
                            _decoder.Start(true);

                            while (!_decoder.FramesInBuffer)
                            {
                                Thread.Sleep(5);
                            }

                            if (nextFrame != null)
                            {
                                nextFrame.Dispose();
                            }

                            nextFrame = _decoder.PlayNextFrame();
                        }
                    }

                    if (currentFrame != null)
                    {
                        currentFrame.Dispose();
                    }

                    currentFrame = nextFrame;

                    Dispatcher.Invoke(() =>
                    {
                        lblActivePartName.Text = TemplateView.Current.CurrentPartName;
                        ShowFrame(currentFrame);

                        GC.Collect();
                    });



                    ReadyForNextFrame = false;

                    while (!ReadyForNextFrame && IsMarking)
                    {
                        Thread.Sleep(5); //Wait for position data (use value < smallest inter-click interval)
                    }

                    //Store the position data
                    if (!FrameData.ContainsKey(currentFrame.FrameIndex))
                    {
                        FrameData[currentFrame.FrameIndex] = new Dictionary <string, System.Drawing.Point?>();
                    }

                    if (_capturedMousePosition != null)
                    {
                        FrameData[currentFrame.FrameIndex][TemplateView.Current.CurrentPartName] = _capturedMousePosition;
                    }

                    UpdateReward();

                    if (iterator.IsAtEndOfBurstOrSequenceOrVideo && iterator.IsAtEndOfBatch)
                    {
                        iterator.AdvanceBurst();
                        templateView.CurrentPartIndex = iterator.BatchPartIndex;
                        IsMarking = false;
                        ShowInstructions();
                        return;
                    }

                    if (iterator.IsAtEndOfBurstOrSequenceOrVideo)
                    {
                        iterator.AdvanceBurst();
                        templateView.CurrentPartIndex = iterator.BatchPartIndex;
                        SetupPlayer(); //Rewind to first frame
                        IsMarking = false;
                        ShowInstructions();
                        return;
                    }

                    iterator.AdvanceBurst();

                    Thread.Sleep(10);
                }
            }).Start();
        }