Exemple #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);
        }
Exemple #2
0
        //public TrackedVideoXml(string fileName, SingleFileResult result, DictionaryXml<int, SingleFrameExtendedResultXml> results, PointFXml[] motionTrack, PointFXml[] smoothedMotionTrack, VectorXml[] orientationTrack, 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, RectangleXml roi, string message = "")
        //{
        //    FileName = fileName;
        //    Result = result;
        //    Results = results;
        //    MotionTrack = motionTrack;
        //    SmoothedMotionTrack = smoothedMotionTrack;
        //    OrientationTrack = orientationTrack;
        //    MinInteractionDistance = minInteractionDistance;
        //    GapDistance = gapDistance;
        //    ThresholdValue = thresholdValue;
        //    ThresholdValue2 = thresholdValue2;
        //    StartFrame = startFrame;
        //    EndFrame = endFrame;
        //    SmoothMotion = smoothMotion;
        //    SmoothFactor = smoothingFactor;
        //    FrameRate = frameRate;
        //    CentroidSize = centroidSize;
        //    PelvicArea1 = pelvicArea1;
        //    PelvicArea2 = pelvicArea2;
        //    PelvicArea3 = pelvicArea3;
        //    PelvicArea4 = pelvicArea4;
        //    UnitsToMilimeters = unitsToMilimeters;
        //    ROI = roi;
        //    Message = message;
        //}

        public TrackedVideoWithSettingsXml(string fileName, SingleFileResult result, DictionaryXml <int, SingleFrameExtendedResultXml> results, PointFXml[] motionTrack, PointFXml[] smoothedMotionTrack, VectorXml[] orientationTrack, BoundaryBaseXml[] boundries, BehaviourHolderXml[] events, DictionaryXml <BoundaryBaseXml, BehaviourHolderXml[]> 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, RectangleXml roi, WhiskerVideoSettingsXml whiskerSettings, string message = "")
        {
            FileName               = fileName;
            Result                 = result;
            Results                = results;
            MotionTrack            = motionTrack;
            SmoothedMotionTrack    = smoothedMotionTrack;
            OrientationTrack       = orientationTrack;
            Boundries              = boundries;
            Events                 = events;
            InteractingBoundries   = interactions;
            MinInteractionDistance = minInteractionDistance;
            GapDistance            = gapDistance;
            ThresholdValue         = thresholdValue;
            ThresholdValue2        = thresholdValue2;
            StartFrame             = startFrame;
            EndFrame               = endFrame;
            SmoothMotion           = smoothMotion;
            SmoothFactor           = smoothingFactor;
            FrameRate              = frameRate;
            CentroidSize           = centroidSize;
            PelvicArea1            = pelvicArea1;
            PelvicArea2            = pelvicArea2;
            PelvicArea3            = pelvicArea3;
            PelvicArea4            = pelvicArea4;
            UnitsToMilimeters      = unitsToMilimeters;
            ROI             = roi;
            Message         = message;
            WhiskerSettings = whiskerSettings;
        }
Exemple #3
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);
            }
        }