コード例 #1
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);
        }
コード例 #2
0
 public WhiskerVideoSettingsXml(IWhiskerVideoSettings settings)
 {
     CropScaleFactor               = settings.CropScaleFactor;
     InterpolationType             = (int)settings.InterpolationType;
     LineMinIntensity              = settings.LineMinIntensity;
     LowerBound                    = settings.LowerBound;
     OrientationResolution         = settings.OrientationResolution;
     RemoveDuds                    = settings.RemoveDuds;
     ResolutionIncreaseScaleFactor = settings.ResolutionIncreaseScaleFactor;
     UpperBound                    = settings.UpperBound;
 }
コード例 #3
0
        public IWhiskerVideoSettings Clone()
        {
            IWhiskerVideoSettings clone = ModelResolver.Resolve <IWhiskerVideoSettings>();

            clone.CropScaleFactor               = CropScaleFactor;
            clone.InterpolationType             = InterpolationType;
            clone.LineMinIntensity              = LineMinIntensity;
            clone.LowerBound                    = LowerBound;
            clone.OrientationResolution         = OrientationResolution;
            clone.RemoveDuds                    = RemoveDuds;
            clone.ResolutionIncreaseScaleFactor = ResolutionIncreaseScaleFactor;
            clone.UpperBound                    = UpperBound;

            return(clone);
        }
コード例 #4
0
        public SingleMouseViewModel(ISingleMouse model)
        {
            Model = model;
            ResetProgress();
            ParallelOptions = new ParallelOptions();
            ParallelOptions.MaxDegreeOfParallelism = 4;

            ThresholdValue  = 20;
            ThresholdValue2 = 10;
            GapDistance     = 35;
            SmoothMotion    = true;

            WhiskerSettings = ModelResolver.Resolve <IWhiskerVideoSettings>();
            WhiskerSettings.AssignDefaultValues();
        }
コード例 #5
0
ファイル: SettingsViewModel.cs プロジェクト: BrettHewitt/ARWT
        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;

            SingleMouseViewModel firstMouse = mice.FirstOrDefault();

            if (firstMouse != null)
            {
                m_GapDistance      = firstMouse.GapDistance;
                m_BinaryThreshold  = firstMouse.ThresholdValue;
                m_BinaryThreshold2 = firstMouse.ThresholdValue2;
                SmoothMotion       = firstMouse.SmoothMotion;
                WhiskerSettings    = firstMouse.WhiskerSettings;
            }

            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();
        }
コード例 #6
0
        public void SaveFile(string fileLocation, string videoFileName, SingleFileResult result, Dictionary <int, ISingleFrameExtendedResults> headPoints, PointF[] motionTrack, PointF[] smoothedMotionTrack, Vector[] orientationTrack, IEnumerable <IBehaviourHolder> events, IEnumerable <IBoundaryBase> boundaries, Dictionary <IBoundaryBase, IBehaviourHolder[]> interactions, double minInteractionDistance, double gapDistance, int thresholdValue, int thresholdValue2, int startFrame, int endFrame, double frameRate, bool smoothMotion, double smoothingFactor, double centroidSize, double pelvicArea1, double pelvicArea2, double pelvicArea3, double pelvicArea4, double unitsToMilimeters, Rectangle roi, IWhiskerVideoSettings whiskerSettings, string message = "")
        {
            if (string.IsNullOrWhiteSpace(fileLocation))
            {
                return;
            }

            TrackedVideoWithSettingsXml fileXml;
            XmlSerializer serializer;
            RectangleXml  roiXml = new RectangleXml(roi);

            if (result != SingleFileResult.Ok)
            {
                fileXml    = new TrackedVideoWithSettingsXml(videoFileName, result, null, null, null, null, null, null, null, minInteractionDistance, gapDistance, thresholdValue, thresholdValue2, startFrame, endFrame, frameRate, smoothMotion, smoothingFactor, centroidSize, pelvicArea1, pelvicArea2, pelvicArea3, pelvicArea4, unitsToMilimeters, roiXml, new WhiskerVideoSettingsXml(whiskerSettings), message);
                serializer = new XmlSerializer(typeof(TrackedVideoWithSettingsXml));

                using (StreamWriter writer = new StreamWriter(fileLocation))
                {
                    serializer.Serialize(writer, fileXml);
                }

                return;
            }

            int headCount = headPoints.Count;

            SingleFrameExtendedResultXml[] allPoints = new SingleFrameExtendedResultXml[headCount];
            for (int i = 0; i < headCount; i++)
            {
                allPoints[i] = new SingleFrameExtendedResultXml(headPoints[i]);
            }

            DictionaryXml <int, SingleFrameExtendedResultXml> headPointsXml = new DictionaryXml <int, SingleFrameExtendedResultXml>(headPoints.Keys.ToArray(), allPoints);

            PointFXml[] motionTrackXml         = motionTrack.Select(point => new PointFXml(point.X, point.Y)).ToArray();
            PointFXml[] smoothedMotionTrackXml = smoothedMotionTrack.Select(point => new PointFXml(point)).ToArray();
            VectorXml[] orientationTrackXml    = orientationTrack.Select(vector => new VectorXml(vector)).ToArray();

            List <BoundaryBaseXml> boundariesXml = boundaries.Select(boundary => boundary.GetData()).ToList();

            List <BehaviourHolderXml> eventsXml = new List <BehaviourHolderXml>();

            foreach (IBehaviourHolder behaviour in events)
            {
                BoundaryBaseXml      boundary    = null;
                InteractionBehaviour interaction = behaviour.Interaction;
                int frameNumber = behaviour.FrameNumber;
                boundary = behaviour.Boundary.GetData();

                eventsXml.Add(new BehaviourHolderXml(boundary, interaction, frameNumber));
            }

            BoundaryBaseXml[]      keys   = interactions.Keys.Select(key => key.GetData()).ToArray();
            BehaviourHolderXml[][] values = interactions.Values.Select(value => value.Select(behavHolder => new BehaviourHolderXml(behavHolder.Boundary.GetData(), behavHolder.Interaction, behavHolder.FrameNumber)).ToArray()).ToArray();
            DictionaryXml <BoundaryBaseXml, BehaviourHolderXml[]> interactionBoundries = new DictionaryXml <BoundaryBaseXml, BehaviourHolderXml[]>(keys, values);
            WhiskerVideoSettingsXml whiskerSettingsXml = new WhiskerVideoSettingsXml(whiskerSettings);

            //fileXml = new TrackedVideoXml(videoFileName, result, headPointsXml, motionTrackXml, smoothedMotionTrackXml, orientationTrackXml, minInteractionDistance, gapDistance, thresholdValue, thresholdValue2, startFrame, endFrame, frameRate, smoothMotion, smoothingFactor, centroidSize, pelvicArea1, pelvicArea2, pelvicArea3, pelvicArea4, unitsToMilimeters, roiXml, message);
            fileXml = new TrackedVideoWithSettingsXml(videoFileName, result, headPointsXml, motionTrackXml, smoothedMotionTrackXml, orientationTrackXml, boundariesXml.ToArray(), eventsXml.ToArray(), interactionBoundries, minInteractionDistance, gapDistance, thresholdValue, thresholdValue2, startFrame, endFrame, frameRate, smoothMotion, smoothingFactor, centroidSize, pelvicArea1, pelvicArea2, pelvicArea3, pelvicArea4, unitsToMilimeters, roiXml, whiskerSettingsXml, message);


            serializer = new XmlSerializer(typeof(TrackedVideoWithSettingsXml));

            using (StreamWriter writer = new StreamWriter(fileLocation))
            {
                serializer.Serialize(writer, fileXml);
            }
        }