tactic clear_tactic(name const & n) { auto fn = [=](environment const &, io_state const &, proof_state const & _s) -> optional<proof_state> { if (!_s.get_goals()) { throw_no_goal_if_enabled(_s); return none_proof_state(); } proof_state s = apply_substitution(_s); goals const & gs = s.get_goals(); goal g = head(gs); goals tail_gs = tail(gs); if (auto p = g.find_hyp(n)) { expr const & h = p->first; unsigned i = p->second; buffer<expr> hyps; g.get_hyps(hyps); hyps.erase(hyps.size() - i - 1); if (depends_on(g.get_type(), h)) { throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, conclusion depends on '" << n << "'"); return none_proof_state(); } if (auto h2 = depends_on(i, hyps.end() - i, h)) { throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, hypothesis '" << *h2 << "' depends on '" << n << "'"); return none_proof_state(); } name_generator ngen = s.get_ngen(); expr new_type = g.get_type(); expr new_meta = mk_app(mk_metavar(ngen.next(), Pi(hyps, new_type)), hyps); goal new_g(new_meta, new_type); substitution new_subst = s.get_subst(); assign(new_subst, g, new_meta); proof_state new_s(s, goals(new_g, tail_gs), new_subst, ngen); return some_proof_state(new_s); } else { throw_tactic_exception_if_enabled(s, sstream() << "invalid 'clear' tactic, goal does not have a hypothesis " << " named '" << n << "'"); return none_proof_state(); } }; return tactic01(fn); }
// Callback: Detected a pose void XN_CALLBACK_TYPE UserPose_PoseDetected(xn::PoseDetectionCapability& /*capability*/, const XnChar* strPose, XnUserID nId, void* /*pCookie*/){ //TODO : archivage du squelette, puis mise à jours du squelette. // Si la distance est trop éloignée, reprendre le squelette précédent (peut être faire une transition entre les deux ?) Skeleton new_s(nId); float distance = m_skeleton.find(nId)->second.distance(new_s); if(distance < SEUIL_DISTANCE) m_skeleton.find(nId)->second = new_s; // else // possibilité de détecter la pose courante et voir si elle n'a pas déjà été enregistrée (à un delta près), probablement il faut revoir la fonction distance du squelette // si on perd le personnage mais qu'on en trouve un nouveau dans une pose connue, on peu essayer de faire une transition. //TODO export du squelette XnUInt32 epochTime = 0; xnOSGetEpochTime(&epochTime); printf("%d Pose %s detected for user %d\n", epochTime, strPose, nId); g_UserGenerator.GetPoseDetectionCap().StopPoseDetection(nId); g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE); }