Beispiel #1
0
        private void beginRecording()
        {
            cache        = new CaptureCache();
            captureState = RecordingState.Recording;
            session      = ScriptableObject.CreateInstance <MocapSession>();

            session.MetaData    = InputProfile.GetSessionMetaData();
            session.CaptureData = new List <MocapSessionKeyframe>();

            startTime = DateTime.Now;
        }
Beispiel #2
0
        public RecordPipeline(bool loadFromEditorPrefs) : base(loadFromEditorPrefs)
        {
            loadProfiles(loadFromEditorPrefs);
            cache = new CaptureCache();

            recordingImage = EditorGUIUtility.Load("Cinema Suite/Cinema Mocap/" + "Recording.png") as Texture2D;
            if (recordingImage == null)
            {
                UnityEngine.Debug.LogWarning("Recording Image missing from Resources folder.");
            }

            LoadEditorPrefs();
        }
Beispiel #3
0
        private void InputProfile_FrameSelected(object sender, FrameSelectedEventArgs args)
        {
            previousArgs = args;
            if (MappingProfile != null && OutputProfile != null)
            {
                cache = new CaptureCache();

                // Build the cache
                int startingFrame = BaseSystem.Math.Max(args.frame - cache.CacheSize, 0);

                for (int i = startingFrame; i <= args.frame; i++)
                {
                    var elapsedTime = args.session.CaptureData[i].ElapsedMilliseconds;
                    var skeleton    = NUICaptureHelper.GetNUISkeleton(args.session.CaptureData[i].Skeleton);

                    cache.AddNewFrame(skeleton, elapsedTime);

                    // Filter the raw input with enabled filters.
                    NUISkeleton filtered = skeleton;
                    foreach (MocapFilter filter in preMapFilters)
                    {
                        if (filter.Enabled)
                        {
                            filtered = filter.Filter(cache);
                            cache.AddFiltered(filter.Name, filtered);
                        }
                    }

                    // Convert the input skeleton to the normalized skeleton (Unity)
                    NUISkeleton mapped = MappingProfile.MapSkeleton(filtered);
                    cache.AddMapped(mapped);

                    // Apply any post-mapped filters selected by the user.
                    filtered = mapped;
                    foreach (MocapFilter filter in postMapFilters)
                    {
                        if (filter.Enabled)
                        {
                            filtered = filter.Filter(cache);
                            cache.AddFiltered(filter.Name, filtered);
                        }
                    }
                    cache.AddResult(filtered);
                }

                var s = NUICaptureHelper.GetNUISkeleton(args.session.CaptureData[args.frame].Skeleton);
                OutputProfile.UpdatePreview(cache.CurrentSkeleton, MappingProfile.GetHipPosition(s));
            }
        }
Beispiel #4
0
        public override NUISkeleton Filter(CaptureCache cache)
        {
            List <NUISkeleton> skeletonCache = cache.GetCacheForFilter(this.Name);

            ResetHistory();
            NUISkeleton output = null;

            foreach (NUISkeleton skeleton in skeletonCache)
            {
                output = skeleton.Clone();

                Array jointTypeValues = Enum.GetValues(typeof(NUIJointType));
                JitterRadius = Math.Max(0.0001f, JitterRadius);

                float tempSmoothing          = Smoothing;
                float tempCorrection         = Correction;
                float tempPrediction         = Prediction;
                float tempJitterRadius       = JitterRadius;
                float tempMaxDeviationRadius = MaxDeviationRadius;

                foreach (NUIJointType jt in jointTypeValues)
                {
                    if (skeleton.Joints.ContainsKey(jt) && jt != NUIJointType.Unspecified)
                    {
                        if (skeleton.Joints[jt].Inferred)
                        {
                            tempJitterRadius       *= 2.0f;
                            tempMaxDeviationRadius *= 2.0f;
                        }

                        output.Joints[jt].Position = this.FilterJoint(skeleton, jt, tempSmoothing, tempCorrection,
                                                                      tempPrediction, tempJitterRadius, tempMaxDeviationRadius);
                    }
                }
            }

            return(output);
        }