示例#1
0
        private void InitRuntime()
        {
            //Some Runtimes' status will be NotPowered, or some other error state. Only want to Initialize the runtime, if it is connected.
            if (_Kinect.Status == KinectStatus.Connected)
            {
                bool skeletalViewerAvailable = IsSkeletalViewerAvailable;

                // NOTE:  Skeletal tracking only works on one Kinect per process right now.
                RuntimeOptions = skeletalViewerAvailable ?
                                 RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor
                                     : RuntimeOptions.UseDepth | RuntimeOptions.UseColor;
                _Kinect.Initialize(RuntimeOptions);
                skeletonPanel.Visibility = skeletalViewerAvailable ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
                if (RuntimeOptions.HasFlag(RuntimeOptions.UseSkeletalTracking))
                {
                    _Kinect.SkeletonEngine.TransformSmooth = true;
                }
            }

            string[] array = { "HipCenterX",      "HipCenterY",      "HipCenterZ",  "SpineX",      "SpineY",      "SpineZ",         "ShoulderCenterX",
                               "ShoulderCenterY", "ShoulderCenterZ", "HeadX",       "HeadY",       "HeadZ",       "ShoulderLeftX",
                               "ShoulderLeftY",   "ShoulderLeftZ",   "ElbowLeftX",  "ElbowLeftY",  "ElbowLeftZ",  "WristLeftX",
                               "WristLeftY",      "WristLeftZ",      "HandLeftX",   "HandLeftY",   "HandLeftZ",   "ShoulderRightX",
                               "ShoulderRightY",  "ShoulderRightZ",  "ElbowRightX", "ElbowRightY", "ElbowRightZ",
                               "WristRightX",     "WristRightY",     "WristRightZ", "HandRightX",  "HandRightY",  "HandRightZ",
                               "HipLeftX",        "HipLeftY",        "HipLeftZ",    "KneeLeftX",   "KneeLeftY",   "KneeLeftZ",      "AnkleLeftX",
                               "AnkleLeftY",      "AnkleLeftZ",      "FootLeftX",   "FootLeftY",   "FootLeftZ",   "HipRightX",      "HipRightY",
                               "HipRightZ",       "KneeRightX",      "KneeRightY",  "KneeRightZ",  "AnkleRightX", "AnkleRightY",
                               "AnkleRightZ",     "FootRightX",      "FootRightY",  "FootRightZ" };

            string[] array1 = { "x", "y", "z", "w" };


            for (int i = 0; i < 60; i++)
            {
                DataColumn column1 = new DataColumn(array[i], System.Type.GetType("System.Double"));
                dt1.Columns.Add(column1);
            }


            for (int i = 0; i < 4; i++)
            {
                DataColumn column1 = new DataColumn(array1[i], System.Type.GetType("System.Double"));
                dt1gp.Columns.Add(column1);
            }
        }
示例#2
0
        /// <summary>
        /// Execute internal of OData v2 call
        /// </summary>
        /// <typeparam name="REQ"></typeparam>
        /// <typeparam name="RES"></typeparam>
        /// <param name="endpoint"></param>
        /// <param name="req"></param>
        /// <param name="parm"></param>
        /// <param name="runtimeOption"></param>
        /// <returns></returns>
        private OD2Body <RES> ExecuteODataV2Internal <REQ, RES>(string endpoint, REQ req, Parameters parm, RuntimeOptions runtimeOption, MeisterOptions options)
        {
            CancellationTokenSource cancel = null;

            try
            {
                RestRequest request = new RestRequest(Method.GET);
                DoResourceAllocation(request, ExecuteMeister);
                request.AddQueryParameter(EndPoint, InQuotes(endpoint));
                request.AddQueryParameter(Parms, InQuotes(PerformExtensions <Parameters>(parm)));
                if (options.HasFlag(MeisterOptions.CompressionsOutbound))
                {
                    request.AddQueryParameter(Content, InQuotes(Zip(PerformExtensions <REQ>(req))));
                }
                else
                {
                    request.AddQueryParameter(Content, InQuotes(PerformExtensions <REQ>(req)));
                }
                cancel = new CancellationTokenSource();
                IRestResponse <OD2Body <RES> > response = null;
                if (runtimeOption.HasFlag(RuntimeOptions.ExecuteAsync))
                {
                    var task = Task.Run(async() =>
                    {
                        response = await Client.ExecuteAsync <OD2Body <RES> >(request, cancel.Token).ConfigureAwait(true);
                        BuildStatusData <RES, OD2Body <RES> >(response);
                        return(response.Data);
                    });
                    task.Wait(cancel.Token);
                    return(task.Result);
                }
                else
                {
                    return(ExecuteSync <OD2Body <RES> >(request).Result);
                }
            }
            finally
            {
                if (cancel != null)
                {
                    cancel.Dispose();
                }
            }
        }
示例#3
0
        private void InitRuntime()
        {
            //Some Runtimes' status will be NotPowered, or some other error state. Only want to Initialize the runtime, if it is connected.
            if (_Kinect.Status == KinectStatus.Connected)
            {
                bool skeletalViewerAvailable = IsSkeletalViewerAvailable;

                // NOTE:  Skeletal tracking only works on one Kinect per process right now.
                RuntimeOptions = skeletalViewerAvailable ?
                                 RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor
                                     : RuntimeOptions.UseDepth | RuntimeOptions.UseColor;
                _Kinect.Initialize(RuntimeOptions);
                skeletonPanel.Visibility = skeletalViewerAvailable ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
                if (RuntimeOptions.HasFlag(RuntimeOptions.UseSkeletalTracking))
                {
                    _Kinect.SkeletonEngine.TransformSmooth = true;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Internal runtime for OD4
        /// </summary>
        /// <typeparam name="REQ"></typeparam>
        /// <typeparam name="RES"></typeparam>
        /// <param name="endpoint"></param>
        /// <param name="req"></param>
        /// <param name="parm"></param>
        /// <param name="runtimeOption"></param>
        /// <returns></returns>
        private OD4Body <RES> ExecuteODataV4Internal <REQ, RES>(string endpoint, REQ req, Parameters parm, RuntimeOptions runtimeOption, MeisterOptions options)
        {
            CancellationTokenSource cancel = null;

            try
            {
                RestRequest request = null;
                if (string.IsNullOrEmpty(CsrfToken))
                {
                    request = new RestRequest(Method.GET);
                    DoResourceAllocation(request, TokenFetch);
                    request.AddHeader(csrf, "Fetch");
                    Client.CookieContainer = new CookieContainer();
                    IRestResponse resp = Client.Execute(request);
                    if (HttpResponseInValidRange(resp.StatusCode))
                    {
                        CsrfToken = (from h in resp.Headers where h.Name == csrf select h).FirstOrDefault().Value.ToString();
                        request   = null;
                    }
                    else
                    {
                        throw new MeisterException(resourceManager.GetString("FailedCsrfToken", CultureInfo.InvariantCulture));
                    }
                }
                IRestResponse <OD4Body <RES> > response = null;
                request = new RestRequest(Method.POST);
                request.RequestFormat = DataFormat.Json;
                var body     = new Body <REQ>(endpoint, parm, req);
                var bodycall = new BodyCall();
                DoResourceAllocation(request, ExecuteMeister);
                bodycall.Parms    = PerformExtensions <Parameters>(body.Parms);
                bodycall.Endpoint = body.Endpoint;
                bodycall.Json     = PerformExtensions <REQ>(body.Json);
                if (options.HasFlag(MeisterOptions.CompressionsInbound))
                {
                    bodycall.Json = Zip(bodycall.Json);
                }
                string json = JsonConvert.SerializeObject(bodycall);
                cancel = new CancellationTokenSource();
                request.AddJsonBody(json);
                request.AddHeader("X-Request-With", "XMLHttpRequest");
                request.AddHeader("Accept", "*/*");
                request.AddHeader(csrf, CsrfToken);
                request.AddHeader("Content-Type", "application/json;odata.metadata=minimal; charset=utf-8");
                response = null;
                if (runtimeOption.HasFlag(RuntimeOptions.ExecuteAsync))
                {
                    var task = Task.Run(async() =>
                    {
                        response = await Client.ExecuteAsync <OD4Body <RES> >(request, cancel.Token).ConfigureAwait(true);
                        BuildStatusData <RES, OD4Body <RES> >(response);
                        return(response.Data);
                    });
                    task.Wait(cancel.Token);
                    return(task.Result);
                }
                else
                {
                    return(ExecuteSync <OD4Body <RES> >(request).Result);
                }
            }
            finally
            {
                if (cancel != null)
                {
                    cancel.Dispose();
                }
            }
        }