Example #1
0
        public int ProcessFrame(Mat buffer, out st_pointf_t[][] keypoints, out float[][] keypoint_scores)
        {
            keypoints       = null;
            keypoint_scores = null;

            // 初始化指针
            p_bodies     = IntPtr.Zero;
            bodies_count = 0;
            // body track
            ret = Motion_Track.st_motion_body_track(body_handle,
                                                    buffer.DataPointer,
                                                    //frame,
                                                    st_pixel_format.ST_PIX_FMT_BGR888,
                                                    buffer.Width, buffer.Height,
                                                    st_motion_orientation.ST_MOTION_UP,
                                                    ref p_bodies,
                                                    ref bodies_count);
            if (ret != ST_OK)
            {
                return(ret);
            }

            Motion_Track.Recon_Body_T(p_bodies, out st_motion_body_t[] p_bodies_m, bodies_count);
            keypoints       = new st_pointf_t[bodies_count][];
            keypoint_scores = new float[bodies_count][];
            for (int i = 0; i < bodies_count; i++)
            {
                Motion_Track.Recon_keypoints(p_bodies_m[i], out keypoints[i], out keypoint_scores[i]);
            }
            // release memory
            Motion_Track.st_motion_body_release_track_result(p_bodies, bodies_count);
            return(0);
        }
Example #2
0
        // cast intptr to managed datatype
        public static void Recon_keypoints(st_motion_body_t input, out st_pointf_t[] keypoints, out float[] keypoint_scores)
        {
            //st_motion_body_t input = (st_motion_body_t)Marshal.PtrToStructure(inputptr, typeof(st_pointf_t));
            var sizeInBytes = Marshal.SizeOf(typeof(st_pointf_t));

            keypoints       = new st_pointf_t[input.keypoints_count];
            keypoint_scores = new float[input.keypoints_count];
            for (int i = 0; i < input.keypoints_count; i++)
            {
                IntPtr p = new IntPtr((input.keypoints.ToInt64() + i * sizeInBytes));
                keypoints[i] = (st_pointf_t)Marshal.PtrToStructure(p, typeof(st_pointf_t));
            }
            Marshal.Copy(input.keypoint_scores, keypoint_scores, 0, input.keypoints_count);
        }