//開放する public override void Close() { if (ailia_pose_estimator != IntPtr.Zero) { AiliaPoseEstimator.ailiaDestroyPoseEstimator(ailia_pose_estimator); ailia_pose_estimator = IntPtr.Zero; } base.Close(); }
private List <AiliaPoseEstimator.AILIAPoseEstimatorObjectUpPose> ComputeUpPoseFromImageWithFormat(Color32[] camera, int tex_width, int tex_height, uint format) { if (ailia_pose_estimator == IntPtr.Zero) { if (logging) { Debug.Log("ailia_pose_estimator is null"); } return(null); } //バッファの固定 GCHandle preview_handle = GCHandle.Alloc(camera, GCHandleType.Pinned); IntPtr preview_buf_ptr = preview_handle.AddrOfPinnedObject(); //画像認識を行ってカテゴリを表示 //Unityのカメラ画像は上下反転しているのでAILIA_IMAGE_FORMAT_RGBA_B2Tを指定 int status = AiliaPoseEstimator.ailiaPoseEstimatorCompute(ailia_pose_estimator, preview_buf_ptr, (UInt32)tex_width * 4, (UInt32)tex_width, (UInt32)tex_height, format); if (status != Ailia.AILIA_STATUS_SUCCESS) { if (logging) { Debug.Log("ailiaPoseEstimatorCompute failed " + status); } return(null); } //推論結果を表示 List <AiliaPoseEstimator.AILIAPoseEstimatorObjectUpPose> result_list = new List <AiliaPoseEstimator.AILIAPoseEstimatorObjectUpPose>(); uint count = 0; AiliaPoseEstimator.ailiaPoseEstimatorGetObjectCount(ailia_pose_estimator, ref count); for (int i = 0; i < count; i++) { AiliaPoseEstimator.AILIAPoseEstimatorObjectUpPose classifier_obj = new AiliaPoseEstimator.AILIAPoseEstimatorObjectUpPose(); status = AiliaPoseEstimator.ailiaPoseEstimatorGetObjectUpPose(ailia_pose_estimator, classifier_obj, (uint)i, AiliaPoseEstimator.AILIA_POSE_ESTIMATOR_OBJECT_UPPOSE_VERSION); if (status != Ailia.AILIA_STATUS_SUCCESS) { if (logging) { Debug.Log("ailiaPoseEstimatorGetObjectUpPose failed" + status); } break; } result_list.Add(classifier_obj); } //バッファの開放 preview_handle.Free(); return(result_list); }
private bool OpenPoseEstimator() { int status = AiliaPoseEstimator.ailiaCreatePoseEstimator(ref ailia_pose_estimator, base.ailia, algorithm); if (status != Ailia.AILIA_STATUS_SUCCESS) { if (logging) { Debug.Log("ailiaCreatePoseEstimator failed " + status); } Close(); return(false); } return(true); }