Beispiel #1
0
        public void LoadData(IMouseFrame[] frames)
        {
            //Load Whisker Angle Data
            WhiskerAngle.LoadData(frames);
            ProtractionRetraction.LoadData(frames);

            //Get whiskers
            List <ISingleWhiskerAmplitude> whiskers = new List <ISingleWhiskerAmplitude>();

            foreach (IWhisker whisker in frames[0].Whiskers)
            {
                if (whisker.IsGenericPoint)
                {
                    continue;
                }

                ISingleWhiskerAmplitude singleWhisker = ModelResolver.Resolve <ISingleWhiskerAmplitude>();
                singleWhisker.Whisker = whisker;
                ISingleWhiskerProtractionRetraction proRetWhisker = ProtractionRetraction.Whiskers.Single(x => x.WhiskerId == whisker.WhiskerId);
                singleWhisker.ProtractionRetractionData       = proRetWhisker.ProtractionRetractionData;
                singleWhisker.ProtractionRetractionDictionary = proRetWhisker.ProtractionRetractionDictionary;
                whiskers.Add(singleWhisker);
            }

            Whiskers = whiskers.ToArray();

            UpdateTValue();
        }
Beispiel #2
0
        public TrackedVideoWithSettingsXml(TrackedVideoXml trackedVideo)
        {
            FileName               = trackedVideo.FileName;
            Result                 = trackedVideo.Result;
            Results                = trackedVideo.Results;
            MotionTrack            = trackedVideo.MotionTrack;
            SmoothedMotionTrack    = trackedVideo.SmoothedMotionTrack;
            OrientationTrack       = trackedVideo.OrientationTrack;
            Boundries              = trackedVideo.Boundries;
            Events                 = trackedVideo.Events;
            InteractingBoundries   = trackedVideo.InteractingBoundries;
            MinInteractionDistance = trackedVideo.MinInteractionDistance;
            GapDistance            = trackedVideo.GapDistance;
            ThresholdValue         = trackedVideo.ThresholdValue;
            ThresholdValue2        = trackedVideo.ThresholdValue2;
            StartFrame             = trackedVideo.StartFrame;
            EndFrame               = trackedVideo.EndFrame;
            SmoothMotion           = trackedVideo.SmoothMotion;
            SmoothFactor           = trackedVideo.SmoothFactor;
            FrameRate              = trackedVideo.FrameRate;
            CentroidSize           = trackedVideo.CentroidSize;
            PelvicArea1            = trackedVideo.PelvicArea1;
            PelvicArea2            = trackedVideo.PelvicArea2;
            PelvicArea3            = trackedVideo.PelvicArea3;
            PelvicArea4            = trackedVideo.PelvicArea4;
            UnitsToMilimeters      = trackedVideo.UnitsToMilimeters;
            ROI     = trackedVideo.ROI;
            Message = trackedVideo.Message;
            IWhiskerVideoSettings videoSettings = ModelResolver.Resolve <IWhiskerVideoSettings>();

            videoSettings.AssignDefaultValues();
            WhiskerSettings = new WhiskerVideoSettingsXml(videoSettings);
        }
        public void LoadData(IMouseFrame[] frames)
        {
            //Load Whisker Angle Data
            WhiskerAngle.LoadData(frames);
            WhiskerAngle.UpdateTValue(0);
            //WhiskerAngularVelocity.LoadData(frames);

            List <ISingleWhiskerProtractionRetraction> whiskers = new List <ISingleWhiskerProtractionRetraction>();

            foreach (IWhisker whisker in frames[0].Whiskers)
            {
                if (whisker.IsGenericPoint)
                {
                    continue;
                }

                ISingleWhiskerProtractionRetraction singleWhisker = ModelResolver.Resolve <ISingleWhiskerProtractionRetraction>();
                singleWhisker.Whisker = whisker;

                double[] signal = new double[frames.Length];
                for (int i = 0; i < frames.Length; i++)
                {
                    signal[i] = WhiskerAngle.Frames[i].Targets.Single(x => x.Whisker.WhiskerId == whisker.WhiskerId).Angle;
                }

                singleWhisker.AngleSignal = signal;

                whiskers.Add(singleWhisker);
            }

            Whiskers = whiskers.ToArray();

            UpdateTValue();
        }
Beispiel #4
0
        private void PostProcessWhiskers2(PointF midPoint, Vector orientation, IWhiskerCollection whiskers, IWhiskerCollection finalWhiskers)
        {
            IWhiskerDetector wd            = ModelResolver.Resolve <IWhiskerDetector>();
            double           minAngleDelta = 15;

            //Whisker angle is measured against horizontal
            //Vector horiztonalVec = new Vector(1, 0);
            //double headAngle = Vector.AngleBetween(orientation, horiztonalVec);

            //return;

            if (whiskers.LeftWhiskers != null && whiskers.LeftWhiskers.Any())
            {
                List <IWhiskerSegment> leftWhiskers = whiskers.LeftWhiskers.ToList();

                wd.RemoveDudWhiskers(midPoint, leftWhiskers, orientation, minAngleDelta, true);
                finalWhiskers.LeftWhiskers = leftWhiskers.ToArray();
            }

            if (whiskers.RightWhiskers != null)
            {
                List <IWhiskerSegment> rightWhiskers = whiskers.RightWhiskers.ToList();

                wd.RemoveDudWhiskers(midPoint, rightWhiskers, orientation, minAngleDelta, false);
                finalWhiskers.RightWhiskers = rightWhiskers.ToArray();
            }
        }
Beispiel #5
0
        public NewWizardViewModel(string fileName)
        {
            VideoSettings          = ModelResolver.Resolve <IVideoSettings>();
            VideoSettings.FileName = fileName;
            Video = ModelResolver.Resolve <IVideo>();
            Video.SetVideo(fileName);
            MaxFrame    = Video.FrameCount - 1;
            FrameNumber = 0;
            //if (fileName.StartsWith(@"C:\Users\10488835\Desktop\PhD\Datasets\100722 -d"))
            //{
            //ThresholdValue = 20;
            //}
            //else
            //{
            ThresholdValue = 60;
            //}

            InteractionValue = 15;
            GapDistance      = 60;
            ThresholdValue2  = 10;
            using (Image <Gray, Byte> tempImage = Video.GetGrayFrameImage())
            {
                ThresholdValue = (int)CalculateOtsu(tempImage);
            }
        }
Beispiel #6
0
        private void AddTgFolder()
        {
            string folderLocation = FileBrowser.BrowseForFolder();

            if (string.IsNullOrWhiteSpace(folderLocation))
            {
                return;
            }

            ObservableCollection <SingleMouseViewModel> currentList = new ObservableCollection <SingleMouseViewModel>(TgItemsSource);

            string[] files = Directory.GetFiles(folderLocation);

            foreach (string file in files)
            {
                string extension = Path.GetExtension(file);

                if (CheckIfExtensionIsVideo(extension))
                {
                    ISingleMouse newFile = ModelResolver.Resolve <ISingleMouse>();
                    newFile.AddFile(GetSingleFile(file));
                    newFile.Name = Path.GetFileNameWithoutExtension(file);
                    currentList.Add(new SingleMouseViewModel(newFile));
                }
            }

            TgItemsSource = currentList;
        }
        public void LoadData(IMouseFrame frame, IWhiskerVelocityFrame previousFrame, IFrameRateSettings frameRateSettings, IUnitSettings unitSettings)
        {
            TargetFrame = frame;

            int numberOfWhiskers = TargetFrame.Whiskers.Length;

            int previousFrameCounter         = 0;
            ISingleWhiskerVelocity nosePoint = null;

            for (int i = 0; i < numberOfWhiskers; i++)
            {
                IWhisker whisker = TargetFrame.Whiskers[i];

                ISingleWhiskerVelocity singleWhiskerVelocity = ModelResolver.Resolve <ISingleWhiskerVelocity>();
                singleWhiskerVelocity.Whisker           = whisker;
                singleWhiskerVelocity.FrameRateSettings = frameRateSettings;
                singleWhiskerVelocity.UnitSettings      = unitSettings;
                singleWhiskerVelocity.NosePoint         = nosePoint;

                if (whisker.WhiskerId == -1)
                {
                    nosePoint = singleWhiskerVelocity;
                }

                if (previousFrame != null)
                {
                    singleWhiskerVelocity.PreviousFrame = previousFrame.Targets[previousFrameCounter];
                }

                Targets.Add(singleWhiskerVelocity);
                previousFrameCounter++;
            }
        }
Beispiel #8
0
        private void BrowseForUnitVideo()
        {
            string filePath = FileBrowser.BroseForVideoFiles();

            if (string.IsNullOrWhiteSpace(filePath))
            {
                return;
            }

            using (IVideo video = ModelResolver.Resolve <IVideo>())
            {
                video.SetVideo(filePath);

                using (Image <Bgr, Byte> image = video.GetFrameImage())
                {
                    Image = image.ToBitmap();

                    PickUnitsPointsViewModel viewModel = new PickUnitsPointsViewModel(Image);
                    PickUnitsPointsView      view      = new PickUnitsPointsView()
                    {
                        DataContext = viewModel,
                    };

                    view.ShowDialog();

                    if (viewModel.OkPressed)
                    {
                        PixelDistance = viewModel.GetDistance();
                    }
                }
            }
        }
        public PickUnitsPointsViewModel(Bitmap bitmap, IWhiskerPoint point1 = null, IWhiskerPoint point2 = null)
        {
            Image = bitmap;

            IGenericPoint genericPoint1 = ModelResolver.Resolve <IGenericPoint>();
            IGenericPoint genericPoint2 = ModelResolver.Resolve <IGenericPoint>();

            genericPoint1.PointId = 1;
            genericPoint2.PointId = 2;

            GenericPointViewModel viewModel1 = new GenericPointViewModel(genericPoint1);
            GenericPointViewModel viewModel2 = new GenericPointViewModel(genericPoint2);

            //IWhisker whisker = ModelResolver.Resolve<IWhisker>();
            //whisker.WhiskerId = 1;

            //IWhiskerPoint whiskerPoint1 = point1 ?? ModelResolver.Resolve<IWhiskerPoint>();
            //whiskerPoint1.Parent = whisker;
            ////whiskerPoint1.WhiskerId = 0;

            //IWhiskerPoint whiskerPoint2 = point2 ?? ModelResolver.Resolve<IWhiskerPoint>();
            //whiskerPoint2.Parent = whisker;
            ////whiskerPoint2.WhiskerId = 1;
            //whisker.WhiskerPoints = new IWhiskerPoint[] { whiskerPoint1, whiskerPoint2 };

            //WhiskerViewModel whiskerViewModel = new WhiskerViewModel(whisker);
            //WhiskerPointViewModel viewModel1 = new WhiskerPointViewModel(whiskerPoint1, whiskerViewModel);
            //WhiskerPointViewModel viewModel2 = new WhiskerPointViewModel(whiskerPoint2, whiskerViewModel);

            CanvasChildren.Add(viewModel1);
            CanvasChildren.Add(viewModel2);
        }
Beispiel #10
0
        public void LoadData(IMouseFrame frame)
        {
            TargetFrame = frame;

            IAngleTypeBase angleType;
            IWhisker       noseWhisker        = TargetFrame.Whiskers.FirstOrDefault(x => x.WhiskerId == -1);
            IWhisker       orientationWhisker = TargetFrame.Whiskers.FirstOrDefault(x => x.WhiskerId == 0);

            if (noseWhisker == null || orientationWhisker == null)
            {
                //can't generate centerline, use vertical
                angleType = ModelResolver.Resolve <IVertical>();
            }
            else
            {
                ICenterLine centerLine = ModelResolver.Resolve <ICenterLine>();
                centerLine.NosePoint        = noseWhisker.WhiskerPoints[0];
                centerLine.OrientationPoint = orientationWhisker.WhiskerPoints[0];
                angleType = centerLine;
            }


            foreach (IWhisker whisker in TargetFrame.Whiskers)
            {
                if (whisker.IsGenericPoint)
                {
                    continue;
                }

                ISingleWhiskerAngle singleWhiskerCurve = ModelResolver.Resolve <ISingleWhiskerAngle>();
                singleWhiskerCurve.Whisker   = whisker;
                singleWhiskerCurve.AngleType = angleType;
                Targets.Add(singleWhiskerCurve);
            }
        }
Beispiel #11
0
        protected override void OnStartup(StartupEventArgs e)
        {
            IRepository repository = RepositoryResolver.Resolve <IRepository>();

            if (!repository.GetValue <bool>("SeenLicense"))
            {
                var result = MessageBox.Show("This program is distrubuted under the General Public License. You must agree to the terms and conditions of this license before using the program", "GPL License", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.No)
                {
                    Application.Current.Shutdown();
                    return;
                }

                IColorSettings colorSettings = ModelResolver.Resolve <IColorSettings>();
                colorSettings.ReturnToDefault();
                colorSettings.SaveSettings();

                repository.SetValue("SeenLicense", true);
                repository.Save();
            }

            MainWindow          view      = new MainWindow();
            MainWindowViewModel viewModel = new MainWindowViewModel(e.Args);

            view.DataContext = viewModel;

            view.Show();

            base.OnStartup(e);
        }
Beispiel #12
0
        public SettingsViewModel(IEnumerable <SingleMouseViewModel> mice)
        {
            GapDistanceMin      = 5;
            GapDistanceMax      = 300;
            BinaryThresholdMin  = 0;
            BinaryThresholdMax  = 255;
            BinaryThreshold2Min = 0;
            BinaryThreshold2Max = 255;

            m_GapDistance      = 35;
            m_BinaryThreshold  = 20;
            m_BinaryThreshold2 = 10;
            SmoothMotion       = true;

            ObservableCollection <SingleFileViewModel> singleFiles = new ObservableCollection <SingleFileViewModel>();

            foreach (var mouse in mice)
            {
                foreach (var file in mouse.VideoFiles)
                {
                    singleFiles.Add(new SingleFileViewModel(file, ""));
                }
            }

            Mice = singleFiles;

            using (IVideo video = ModelResolver.Resolve <IVideo>())
            {
                video.SetVideo(Mice.First().VideoFileName);
                FrameRate = video.FrameRate;
            }

            SelectedMouse = Mice.First();
        }
Beispiel #13
0
        private void SaveFile()
        {
            if (File.Exists(ArtFile))
            {
                var result = MessageBox.Show("Would you like to overwrite the original file?", "Overwrite?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }

                ISaveArtFile save      = ModelResolver.Resolve <ISaveArtFile>();
                string       videoFile = SelectedVideo.VideoFileName;

                if (result == MessageBoxResult.Yes)
                {
                    save.SaveFile(ArtFile, videoFile, CurrentResult);
                }
                else
                {
                    string saveFile = FileBrowser.SaveFile("ART|*.art");

                    if (string.IsNullOrWhiteSpace(saveFile))
                    {
                        return;
                    }

                    save.SaveFile(saveFile, videoFile, CurrentResult);
                }
            }
        }
        private void UpdateNumberOfWhiskers()
        {
            int startIndex = 1;

            if (ViewModel.IncludeNosePoint)
            {
                startIndex = -1;
            }

            ObservableCollection <IWhiskerClipSettings> whiskers = new ObservableCollection <IWhiskerClipSettings>();

            for (int index = startIndex; index <= ViewModel.NumberOfWhiskers; index++)
            {
                string name;
                bool   isGeneric;
                int    numberOfPoints = SelectedNumberOfPointsPerWhisker;
                if (index == -1)
                {
                    name           = "Nose Point";
                    isGeneric      = true;
                    numberOfPoints = 1;
                }
                else if (index == 0)
                {
                    if (!ViewModel.IncludeOrientationPoint)
                    {
                        continue;
                    }

                    name           = "Orientation Point";
                    isGeneric      = true;
                    numberOfPoints = 1;
                }
                else
                {
                    name      = "Whisker " + index;
                    isGeneric = false;
                }

                IWhiskerClipSettings whisker = ModelResolver.Resolve <IWhiskerClipSettings>();
                whisker.WhiskerId      = index;
                whisker.WhiskerName    = name;
                whisker.IsGenericPoint = isGeneric;
                whisker.NumberOfPoints = numberOfPoints;
                whiskers.Add(whisker);
            }

            if (GenericPoints.Count > 0)
            {
                int genericStartId = ViewModel.NumberOfWhiskers + 1;
                int delta          = genericStartId - GenericPoints.Min(x => x.WhiskerId);
                foreach (IWhiskerClipSettings genericWhisker in GenericPoints)
                {
                    genericWhisker.WhiskerId += delta;
                    whiskers.Add(genericWhisker);
                }
            }

            Whiskers = whiskers;
        }
Beispiel #15
0
        public void LoadData(IMouseFrame[] frames)
        {
            //Load Whisker Angle Data
            WhiskerAngle.LoadData(frames);

            //Get whiskers
            double frameRate     = GlobalSettings.GlobalSettings.FrameRateSettings.OriginalFrameRate;
            double frameInterval = GlobalSettings.GlobalSettings.ClipSettings.FrameInterval;

            List <ISingleWhiskerFrequency> whiskers = new List <ISingleWhiskerFrequency>();

            foreach (IWhisker whisker in frames[0].Whiskers)
            {
                if (whisker.IsGenericPoint)
                {
                    continue;
                }

                ISingleWhiskerFrequency singleWhisker = ModelResolver.Resolve <ISingleWhiskerFrequency>();
                singleWhisker.Whisker       = whisker;
                singleWhisker.FrameRate     = frameRate;
                singleWhisker.FrameInterval = frameInterval;
                whiskers.Add(singleWhisker);
            }

            Whiskers = whiskers.ToArray();

            CreateWhiskers();
            UpdateTValue();
        }
Beispiel #16
0
        public WhiskerAngularVelocityViewModel(AnalyserViewModel parent)  : base(parent, "Whisker Angular Velocity")
        {
            Model = ModelResolver.Resolve <IWhiskerAngularVelocity>();

            Model.LoadData(parent.Frames.Values.Select(x => x.Model).ToArray());
            CreateFrames();

            MethodControl = new WhiskerAngularVelocityView()
            {
                DataContext = this,
            };

            ObservableCollection <AngleTypeBase> angleOptions = new ObservableCollection <AngleTypeBase>();

            IWhisker nosePoint        = Parent.CurrentFrame.Whiskers.Select(x => x.Model).FirstOrDefault(x => x.WhiskerId == -1);
            IWhisker orientationPoint = Parent.CurrentFrame.Whiskers.Select(x => x.Model).FirstOrDefault(x => x.WhiskerId == 0);

            if (nosePoint != null && orientationPoint != null)
            {
                angleOptions.Add(new CenterLineViewModel());
            }

            angleOptions.Add(new VerticalViewModel());
            angleOptions.Add(new HorizontalViewModel());

            AngleOptions        = angleOptions;
            SelectedAngleOption = AngleOptions.First();

            Initialise();
        }
Beispiel #17
0
        public override IBoundaryBase GetBoundary()
        {
            IOuterBoundary boundary = ModelResolver.Resolve <IOuterBoundary>();

            boundary.Id     = Id;
            boundary.Points = Points.Select(x => x.GetPoint()).ToArray();;
            return(boundary);
        }
Beispiel #18
0
        public void SetVideo(string fileName)
        {
            if (Video == null)
            {
                Video = ModelResolver.Resolve <IVideo>();
            }

            Video.SetVideo(fileName);
        }
Beispiel #19
0
        private void OpenFile(string fileName)
        {
            XmlSerializer     serializer = new XmlSerializer(typeof(WhiskerTrackerXml));
            WhiskerTrackerXml whiskerTracker;

            using (StreamReader reader = new StreamReader(fileName))
            {
                whiskerTracker = (WhiskerTrackerXml)serializer.Deserialize(reader);
            }

            if (!File.Exists(whiskerTracker.ClipSettings.ClipFilePath))
            {
                MessageBoxResult result = MessageBox.Show("File not found, would you like to browse for it?", "File not found", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    whiskerTracker.ClipSettings.ClipFilePath = FileBrowser.BroseForVideoFiles();

                    if (string.IsNullOrWhiteSpace(whiskerTracker.ClipSettings.ClipFilePath))
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            WorkingFile  = fileName;
            WhiskerVideo = ModelResolver.Resolve <IWhiskerVideo>();
            WhiskerVideo.SetVideo(whiskerTracker.ClipSettings.ClipFilePath);
            m_VideoWidth  = (int)WhiskerVideo.Width;
            m_VideoHeight = (int)WhiskerVideo.Height;
            FrameCount    = WhiskerVideo.FrameCount;

            GlobalSettings.GlobalSettings.ClipSettings = whiskerTracker.ClipSettings.GetClipSettings();
            GlobalSettings.GlobalSettings.ClipSettings.Commit();
            GlobalSettings.GlobalSettings.UnitSettings = whiskerTracker.UnitSettings.GetSettings();
            GlobalSettings.GlobalSettings.UnitSettings.Commit();
            GlobalSettings.GlobalSettings.FrameRateSettings = whiskerTracker.FrameRateSettings.GetSettings();
            GlobalSettings.GlobalSettings.FrameRateSettings.Commit();

            Image         = null;
            Started       = false;
            VideoSelected = true;
            ClearUndoActions();

            Dictionary <int, MouseFrameViewModel> frames = new Dictionary <int, MouseFrameViewModel>();

            foreach (MouseFrameXml mouseFrame in whiskerTracker.Frames)
            {
                frames.Add(mouseFrame.IndexNumber, new MouseFrameViewModel(mouseFrame.GetMouseFrame()));
            }

            StartPicking(frames);
        }
Beispiel #20
0
        public WhiskerProtractionRetractionViewModel(AnalyserViewModel parent) : base(parent, "Whisker Protraction/Retraction Velocity")
        {
            Model = ModelResolver.Resolve <IWhiskerProtractionRetraction>();

            MethodControl = new WhiskerProtractionRetractionView()
            {
                DataContext = this,
            };
        }
Beispiel #21
0
        private ISingleFile GetSingleFile(string fileName)
        {
            ISingleFile singleFile = ModelResolver.Resolve <ISingleFile>();

            singleFile.VideoFileName = fileName;
            singleFile.VideoNumber   = Path.GetFileNameWithoutExtension(fileName);

            return(singleFile);
        }
        public WhiskerAmplitudeViewModel(AnalyserViewModel parent) : base(parent, "Whisker Amplitude")
        {
            Model = ModelResolver.Resolve <IWhiskerAmplitude>();

            MethodControl = new WhiskerAmplitudeView()
            {
                DataContext = this,
            };
        }
Beispiel #23
0
        public SingleVideoExportViewModel()
        {
            ObservableCollection <ISmoothingBase> smoothingFunctions = new ObservableCollection <ISmoothingBase>();

            smoothingFunctions.Add(ModelResolver.Resolve <IGaussianSmoothing>());
            smoothingFunctions.Add(ModelResolver.Resolve <IBoxCarSmoothing>());
            SmoothingFunctions        = smoothingFunctions;
            SelectedSmoothingFunction = SmoothingFunctions.First();
        }
Beispiel #24
0
        public IBehaviourHolder GetData()
        {
            IBehaviourHolder data = ModelResolver.Resolve <IBehaviourHolder>();

            data.Boundary    = Boundary.GetBoundary();
            data.Interaction = Interaction;
            data.FrameNumber = FrameNumber;

            return(data);
        }
Beispiel #25
0
        private void StartPicking(Dictionary <int, MouseFrameViewModel> data = null)
        {
            Started = true;

            m_Frames = new Dictionary <int, MouseFrameViewModel>();
            int indexNumber  = 0;
            int frameCounter = 1;

            while (frameCounter <= EndFrame)
            {
                using (Image <Bgr, Byte> currentFrame = WhiskerVideo.GetFrameImage())
                {
                    if (currentFrame == null)
                    {
                        break;
                    }

                    int startRange = frameCounter - StartFrame;
                    if (startRange >= 0)
                    {
                        //We're within range
                        if (startRange % FrameInterval == 0)
                        {
                            //We're on the interval
                            MouseFrameViewModel mouseFrameViewModel;
                            IMouseFrame         mouseFrame;
                            if (data == null)
                            {
                                mouseFrame             = ModelResolver.Resolve <IMouseFrame>();
                                mouseFrame.FrameNumber = frameCounter;
                                mouseFrame.IndexNumber = indexNumber;
                                mouseFrame.Whiskers    = GlobalSettings.GlobalSettings.ClipSettings.CreateEmptyWhiskers(mouseFrame);
                                mouseFrameViewModel    = new MouseFrameViewModel(mouseFrame);
                            }
                            else
                            {
                                mouseFrameViewModel = data[indexNumber];
                                mouseFrame          = mouseFrameViewModel.Model;
                            }

                            mouseFrame.Frame = currentFrame.Clone();

                            m_Frames.Add(indexNumber, mouseFrameViewModel);
                            indexNumber++;
                        }
                    }
                }

                frameCounter++;
            }

            m_FrameCounter = -1;
            UpdateWhiskerPositions(LastKnownImageWidth, LastKnownImageHeight);
            GetNextFrame();
        }
 public BodyDetectionViewModel(ITrackedVideo headPoints = null, Dictionary <int, ISingleFrameResult> results = null, string file = "")
 {
     ThresholdValue = headPoints.ThresholdValue;
     Video          = ModelResolver.Resolve <IVideo>();
     VideoSettings  = ModelResolver.Resolve <IVideoSettings>();
     BlobDetector   = new CvBlobDetector();
     RBSK           = MouseService.GetStandardMouseRules();
     HeadPoints     = results;
     FileLocation   = file;
     OpenVideo();
 }
Beispiel #27
0
        static GlobalSettings()
        {
            UnitSettings = ModelResolver.Resolve <IUnitSettings>();
            UnitSettings.LoadSettings();

            ColorSettings = ModelResolver.Resolve <IColorSettings>();
            ColorSettings.LoadSettings();

            ClipSettings = ModelResolver.Resolve <IClipSettings>();

            FrameRateSettings = ModelResolver.Resolve <IFrameRateSettings>();
        }
Beispiel #28
0
        public HeadOrientationViewModel(AnalyserViewModel parent) : base(parent, "Head Orientation")
        {
            Model = ModelResolver.Resolve <IHeadOrientation>();
            Model.LoadData(parent.Frames.Values.Select(x => x.Model).ToArray());
            CreateFrames();

            MethodControl = new HeadOrientationView()
            {
                DataContext = this,
            };

            Initialise();
        }
Beispiel #29
0
        public WhiskerVelocityViewModel(AnalyserViewModel parent) : base(parent, "Whisker Velocity")
        {
            Model = ModelResolver.Resolve <IWhiskerVelocity>();
            Model.LoadData(parent.Frames.Values.Select(x => x.Model).ToArray());
            CreateFrames();

            MethodControl = new WhiskerVelocityView()
            {
                DataContext = this,
            };

            Initialise();
        }
Beispiel #30
0
        private PointF[] ProcessFrame(Image <Bgr, Byte> image, AutomatedRodentTracker.Services.RBSK.RBSK rbsk, out double waist, out double waistArea, out double waistArea2, out double waistArea3, out double waistArea4, out PointF centroid, bool useBackground = false)
        {
            //Rectangle roi = Rectangle.Empty;

            //if (image.IsROISet)
            //{
            //    roi = image.ROI;
            //    image.ROI = Rectangle.Empty;
            //}

            if (BackgroundImage != null && useBackground)
            {
                using (Image <Gray, Byte> grayImage = image.Convert <Gray, Byte>())
                    //using (Image<Gray, Byte> filteredImage = grayImage.SmoothMedian(rbsk.Settings.FilterLevel))
                    using (Image <Gray, Byte> binaryImage = grayImage.ThresholdBinary(new Gray(rbsk.Settings.BinaryThreshold), new Gray(255)))
                        using (Image <Gray, Byte> backgroundNot = BackgroundImage.Not())
                            using (Image <Gray, Byte> finalImage = binaryImage.Add(backgroundNot))
                                using (Image <Gray, Byte> filteredImage = finalImage.SmoothMedian(rbsk.Settings.FilterLevel))
                                {
                                    //ImageViewer.Show(finalImage);
                                    PointF[] result = RBSKService.RBSK(filteredImage, rbsk);

                                    IBodyDetection bodyDetection = ModelResolver.Resolve <IBodyDetection>();
                                    bodyDetection.BinaryBackground = BackgroundImage;
                                    //bodyDetection.ThresholdValue = ThresholdValue;

                                    if (result == null)
                                    {
                                        waist      = -1;
                                        waistArea  = -1;
                                        waistArea2 = -1;
                                        waistArea3 = -1;
                                        waistArea4 = -1;
                                        bodyDetection.GetBody(grayImage, out centroid);
                                        return(null);
                                    }

                                    bodyDetection.FindBody(grayImage, out waist, out waistArea, out waistArea2, out waistArea3, out waistArea4, out centroid);

                                    return(result);
                                }
            }

            waist      = -1;
            waistArea  = -1;
            waistArea2 = -1;
            waistArea3 = -1;
            waistArea4 = -1;
            centroid   = PointF.Empty;
            return(RBSKService.RBSK(image, rbsk));
        }