body_frame = k4a.k4abt_frame_t()
                pop_frame_result = k4a.k4abt_tracker_pop_result(
                    tracker, ctypes.byref(body_frame), k4a.K4A_WAIT_INFINITE)
                if pop_frame_result == k4a.K4A_WAIT_RESULT_SUCCEEDED:
                    num_bodies = k4a.k4abt_frame_get_num_bodies(body_frame)
                    print("{} bodies are detected!".format(num_bodies))

                    timestamp = k4a.k4abt_frame_get_device_timestamp_usec(
                        body_frame)
                    print("{} timestamp are detected!".format(timestamp))

                    for i in range(num_bodies):
                        body = k4a.k4abt_body_t()
                        VERIFY(
                            k4a.k4abt_frame_get_body_skeleton(
                                body_frame, i, ctypes.byref(body.skeleton)),
                            "Get body from body frame failed!")
                        body.id = k4a.k4abt_frame_get_body_id(body_frame, i)

                        print_body_information(body)

                    body_index_map = k4a.k4abt_frame_get_body_index_map(
                        body_frame)
                    if body_index_map:
                        print_body_index_map_middle_line(body_index_map)
                        k4a.k4a_image_release(body_index_map)
                    else:
                        print("Error: Fail to generate bodyindex map!")

                    k4a.k4abt_frame_release(body_frame)
                elif pop_frame_result == k4a.K4A_WAIT_RESULT_TIMEOUT:
예제 #2
0
                    elif queue_capture_result == k4a.K4A_WAIT_RESULT_FAILED:
                        print("Error! Add capture to tracker process queue failed!")
                        break

                    body_frame = k4a.k4abt_frame_t()
                    pop_frame_result = k4a.k4abt_tracker_pop_result(tracker, ctypes.byref(body_frame), k4a.K4A_WAIT_INFINITE)
                    if pop_frame_result == k4a.K4A_WAIT_RESULT_SUCCEEDED:
                        num_bodies = k4a.k4abt_frame_get_num_bodies(body_frame)
                        # print("{} bodies are detected!".format(num_bodies))
                        timestamp = k4a.k4abt_frame_get_device_timestamp_usec(body_frame)
                        # print("{} timestamp are detected!".format(timestamp))
                        if num_bodies:
                            multi_pose = np.zeros((num_bodies, k4a.K4ABT_JOINT_COUNT, 3))
                            for i in range(num_bodies):
                                body = k4a.k4abt_body_t()
                                VERIFY(k4a.k4abt_frame_get_body_skeleton(body_frame, i, ctypes.byref(body.skeleton)), "Get body from body frame failed!")
                                body.id = k4a.k4abt_frame_get_body_id(body_frame, i)

                                multi_pose[i, :, :] = body_information(body)

                            # normalization
                            center_pelvis = multi_pose[0,0,:]
                            multi_pose[0, :, :] = multi_pose[0, :, :] - center_pelvis
                            # print(np.shape(center_pelvis))
                            multi_pose[:, :, 0] = multi_pose[:, :, 0] / img_w + 0.5
                            multi_pose[:, :, 1] = multi_pose[:, :, 1] / img_h + 0.5
                            multi_pose[:, :, 2] = multi_pose[:, :, 2] / img_h + 0.5
                        else:
                            multi_pose = np.zeros((1, k4a.K4ABT_JOINT_COUNT, 3))

                        # import pdb; pdb.set_trace()