├── .gitignore ├── Accessories ├── AbsolutePosition.cs ├── Matrix33.cs ├── Position.cs ├── RelativePosition.cs ├── Transduction.cs └── Vector3.cs ├── App.config ├── App.xaml ├── App.xaml.cs ├── DistanceTree ├── BodyTree.cs ├── MoveSequence.cs └── TreeBodyPart.cs ├── External ├── Antlr4.Runtime.v4.5.dll ├── BigRationalLibrary.dll ├── ICSharpCode.AvalonEdit.dll ├── ICSharpCode.AvalonEdit.pdb ├── Microsoft.Automata.Z3.dll ├── Microsoft.Automata.dll ├── Microsoft.Fast.dll ├── antlr4-csharp-4.2.2-SNAPSHOT-complete.jar ├── x64 │ ├── Kinect20.dll │ ├── Microsoft.Kinect.dll │ ├── Microsoft.Z3.dll │ └── libz3.dll └── x86 │ ├── Microsoft.Z3.dll │ └── libz3.dll ├── Fast └── bodytree.fast ├── FastGestureRecognizer.csproj ├── FastGestureRecognizer.csproj.vspscc ├── GenerateCSharp ├── App.config ├── FastToCSharp.csproj ├── FastToCSharp.csproj.vspscc ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── GestureRecognizer.sln ├── GestureRecognizer.vssscc ├── Images ├── CheckedHover.png ├── CheckedNormal.png ├── Kinect.ico ├── Logo.png ├── ScreenshotHover.png ├── ScreenshotNormal.png ├── Status.png ├── UncheckedHover.png ├── UncheckedNormal.png └── prepose-shot.png ├── LICENSE ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── PrePose.pptx ├── PreposeGesturesFrameReader ├── PreposeGesturesFrameReader.cs ├── PreposeGesturesFrameReader.csproj ├── PreposeGesturesFrameReader.csproj.vspscc ├── Properties │ └── AssemblyInfo.cs └── Z3KinectConverter.cs ├── PreposeGesturesFrameReaderConsoleExample ├── App.config ├── Kinect20.dll ├── PreposeGesturesFrameReaderConsoleExample.csproj ├── PreposeGesturesFrameReaderConsoleExample.csproj.vspscc ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── libz3.dll └── soccer.app ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── README.docx ├── README.md ├── Z3Experiments └── Z3Experiments │ ├── App.config │ ├── GestureStatistics.cs │ ├── Gestures │ ├── Analysis │ │ ├── Ambiguity.cs │ │ ├── Safety.cs │ │ ├── Validity.cs │ │ └── Z3AnalysisInterface.cs │ ├── App.cs │ ├── BodyMatching.cs │ ├── ExecutionStep.cs │ ├── Gestures.cs │ ├── JointTypeHelper.cs │ ├── Pose.cs │ ├── PoseBuilder.cs │ ├── Restrictions.cs │ ├── Transforms.cs │ ├── TrigonometryHelper.cs │ ├── Z3Body.cs │ └── Z3SampleCode.cs │ ├── Parser │ ├── PreposeGestures.g4 │ ├── PreposeGesturesBaseListener.cs │ ├── PreposeGesturesBaseVisitor.cs │ ├── PreposeGesturesLexer.cs │ ├── PreposeGesturesListener.cs │ ├── PreposeGesturesParser.cs │ ├── PreposeGesturesVisitor.cs │ ├── PreposeParserException.cs │ └── Visitor.cs │ ├── PreposeGestures.csproj │ ├── PreposeGestures.csproj.vspscc │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Tests.zip │ ├── Tests │ ├── ballet.app │ ├── simple.app │ ├── soccer.app │ ├── taichi.app │ ├── test.app │ └── therapy.app │ ├── TupleTest.cs │ └── build.bat ├── Z3GestureRecognizer ├── App.config ├── App.xaml ├── App.xaml.cs ├── BodyMatching.cs ├── CustomHighlighting.xshd ├── Images │ ├── Kinect.ico │ ├── Logo.png │ └── Status.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── PreposeGestureRecognizer.csproj ├── PreposeGestureRecognizer.csproj.vspscc ├── PreposeSyntaxCompletionData.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── UpdatingNotes.txt ├── Z3KinectConverter.cs └── packages.config └── packages ├── AvalonEdit.4.4.2.9744 ├── AvalonEdit.4.4.2.9744.nupkg ├── AvalonEdit.4.4.2.9744.nuspec └── lib │ ├── Net35 │ ├── ICSharpCode.AvalonEdit.dll │ └── ICSharpCode.AvalonEdit.xml │ └── Net40 │ ├── ICSharpCode.AvalonEdit.dll │ └── ICSharpCode.AvalonEdit.xml └── repositories.config /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | *_i.c 20 | *_p.c 21 | *.ilk 22 | *.meta 23 | *.obj 24 | *.pch 25 | *.pdb 26 | *.pgc 27 | *.pgd 28 | *.rsp 29 | *.sbr 30 | *.tlb 31 | *.tli 32 | *.tlh 33 | *.tmp 34 | *.log 35 | *.vspscc 36 | *.vssscc 37 | .builds 38 | 39 | # Visual C++ cache files 40 | ipch/ 41 | *.aps 42 | *.ncb 43 | *.opensdf 44 | *.sdf 45 | 46 | # Visual Studio profiler 47 | *.psess 48 | *.vsp 49 | *.vspx 50 | 51 | # Guidance Automation Toolkit 52 | *.gpState 53 | 54 | # ReSharper is a .NET coding add-in 55 | _ReSharper* 56 | 57 | # NCrunch 58 | *.ncrunch* 59 | .*crunch*.local.xml 60 | 61 | # Installshield output folder 62 | [Ee]xpress 63 | 64 | # NuGet Packages Directory 65 | packages 66 | 67 | # Others 68 | [Bb]in 69 | [Oo]bj 70 | sql 71 | TestResults 72 | [Tt]est[Rr]esult* 73 | *.Cache 74 | ClientBin 75 | [Ss]tyle[Cc]op.* 76 | ~$* 77 | *.dbmdl 78 | Generated_Code #added for RIA/Silverlight projects 79 | 80 | # Backup & report files from converting an old project file to a newer 81 | # Visual Studio version. Backup files are not needed, because we have git ;-) 82 | _UpgradeReport_Files/ 83 | Backup*/ 84 | UpgradeLog*.XML 85 | -------------------------------------------------------------------------------- /Accessories/AbsolutePosition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.Samples.Kinect.GestureRecognizer 7 | { 8 | using System.IO; 9 | using System.Windows; 10 | using System.Windows.Media; 11 | using Microsoft.Kinect; 12 | 13 | public class AbsolutePosition : Position 14 | { 15 | 16 | 17 | public double x { get; set; } 18 | public double y { get; set; } 19 | 20 | public AbsolutePosition(double x0, double y0) 21 | { 22 | x = x0; 23 | y = y0; 24 | } 25 | 26 | public double Distance() 27 | { 28 | return Math.Sqrt(Math.Pow(x,2)+Math.Pow(y,2)); 29 | } 30 | 31 | public AbsolutePosition increment(RelativePosition p) 32 | { 33 | if(p!=null) 34 | return new AbsolutePosition(x + p.x, y + p.y); 35 | return null; 36 | } 37 | 38 | public Point getPoint() 39 | { 40 | return new Point(x, y); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Accessories/Matrix33.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BodyBasicsWPF.Accessories 8 | { 9 | class Matrix33 10 | { 11 | public Vector3 i; 12 | public Vector3 j; 13 | public Vector3 k; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Accessories/Position.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.Samples.Kinect.GestureRecognizer 7 | { 8 | 9 | interface Position 10 | { 11 | double Distance(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Accessories/RelativePosition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.Samples.Kinect.GestureRecognizer 7 | { 8 | using System.IO; 9 | using System.Windows; 10 | using System.Windows.Media; 11 | using Microsoft.Kinect; 12 | 13 | public class RelativePosition : Position 14 | { 15 | public double x { get; set; } 16 | public double y { get; set; } 17 | 18 | public RelativePosition (double x0, double y0){ 19 | x = x0; 20 | y = y0; 21 | } 22 | 23 | public double Distance() 24 | { 25 | return Math.Sqrt(Math.Pow(x,2)+Math.Pow(y,2)); 26 | } 27 | 28 | public double Difference(RelativePosition p1) 29 | { 30 | return Math.Pow(x - p1.x,2) + Math.Pow(y - p1.y,2); 31 | } 32 | 33 | public void Rotate(double degree) 34 | { 35 | x= (Math.Cos(degree) * x) - (Math.Sin(degree) * y); 36 | y= (Math.Sin(degree) * x) + (Math.Cos(degree) * y); 37 | } 38 | 39 | public void TranslateHorizontal(double dist) 40 | { 41 | x = x + dist; 42 | } 43 | 44 | public void TranslateVertical(double dist) 45 | { 46 | y = y + dist; 47 | } 48 | 49 | public void print() { 50 | Console.Write("{0},{1}", x, y); 51 | } 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Accessories/Transduction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.Samples.Kinect.GestureRecognizer 7 | { 8 | 9 | using System.Windows; 10 | using System.Windows.Media; 11 | using Microsoft.Kinect; 12 | using System.Collections.Generic; 13 | 14 | //public enum Move { 15 | // Stay, StepLeft, StepRight, LiftLeftArm2, LiftRightArm2, LiftLeftArm, LiftRightArm, LiftLeftLowerArm, LiftRightLowerArm, 16 | // DownLeftArm, DownRightArm, DownLeftLowerArm, DownRightLowerArm, CollectLeft, CollectRight 17 | //}; 18 | 19 | 20 | //public enum Move 21 | //{ 22 | // Stay, 23 | // LiftLeftArmFrontalPlane, LiftRightArmFrontalPlane, LiftLeftLowerArmFrontalPlane, LiftRightLowerArmFrontalPlane, 24 | // DownLeftArmFrontalPlane, DownRightArmFrontalPlane, DownLeftLowerArmFrontalPlane, DownRightLowerArmFrontalPlane, 25 | // LiftLeftArmSagittalPlane, LiftRightArmSagittalPlane, LiftLeftLowerArmSagittalPlane, LiftRightLowerArmSagittalPlane, 26 | // DownLeftArmSagittalPlane, DownRightArmSagittalPlane, DownLeftLowerArmSagittalPlane, DownRightLowerArmSagittalPlane, 27 | // MoveLeftLeftLowerArm, MoveLeftRightLowerArm, MoveRightLeftLowerArm, MoveRightRightLowerArm, 28 | // PointLeftArmDown, PointRightArmDown, PointNeckUp, RotateLeftNeck, RotateRightNeck 29 | //}; 30 | 31 | public enum Transduction 32 | { 33 | Stay, 34 | ToLeft, 35 | ToRight, 36 | ToUp, 37 | ToDown, 38 | ToFront, 39 | ToBack, 40 | RotFroClock, 41 | RotFroCClock, 42 | RotSagClock, 43 | RotSagCClock, 44 | RotHorClock, 45 | RotHorCClock, 46 | LeftST, 47 | RightST, 48 | ResetJT, 49 | ResetST, 50 | ResetAT, 51 | SpineShoulder, 52 | SpineBase, 53 | Hand, 54 | Neck, 55 | Shoulder, 56 | Elbow, 57 | Wrist, 58 | Hip, 59 | Knee, 60 | Head, 61 | HandTip, 62 | Thumb, 63 | Foot 64 | }; 65 | 66 | public static class TransductionUtil{ 67 | 68 | private const int THICKNESS=3; 69 | 70 | private static Pen pen = new Pen(Brushes.LightGray, THICKNESS); 71 | 72 | public static List GetAll() 73 | { 74 | List moves = Enum.GetValues(typeof(Transduction)).Cast().ToList(); 75 | moves.Remove(Transduction.Stay); 76 | return moves; 77 | } 78 | 79 | public static List Complement(Transduction m){ 80 | List moves = Enum.GetValues(typeof(Transduction)).Cast().ToList(); 81 | moves.Remove(m); 82 | moves.Remove(Transduction.Stay); 83 | return moves; 84 | } 85 | 86 | public static char ToChar(Transduction m) 87 | { 88 | List moves = Enum.GetValues(typeof(Transduction)).Cast().ToList(); 89 | return (char)(moves.IndexOf(m)+96); 90 | } 91 | 92 | public static Transduction ToMove(Char m) 93 | { 94 | List moves = Enum.GetValues(typeof(Transduction)).Cast().ToList(); 95 | return moves[((int) m)-96]; 96 | } 97 | 98 | public static Pen ToColor(Transduction m) 99 | { 100 | return pen; 101 | } 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /Accessories/Vector3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BodyBasicsWPF.Accessories 8 | { 9 | public struct Vector3 10 | { 11 | // 12 | // Summary: 13 | // The X coordinate of the vector. 14 | public double X; 15 | // 16 | // Summary: 17 | // The Y coordinate of the vector. 18 | public double Y; 19 | // 20 | // Summary: 21 | // The Z coordinate of the vector. 22 | public double Z; 23 | 24 | public Vector3(double X, double Y, double Z) 25 | { 26 | this.X = X; 27 | this.Y = Y; 28 | this.Z = Z; 29 | } 30 | 31 | public static Vector3 operator +(Vector3 v1, Vector3 v2) 32 | { 33 | return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); 34 | } 35 | public static Vector3 operator -(Vector3 v1, Vector3 v2) 36 | { 37 | return new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); 38 | } 39 | public static Vector3 operator *(Vector3 v, double scalar) 40 | { 41 | return new Vector3(v.X * scalar, v.Y * scalar, v.Z * scalar); 42 | } 43 | public static Vector3 operator /(Vector3 v, double scalar) 44 | { 45 | return new Vector3(v.X / scalar, v.Y / scalar, v.Z / scalar); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /App.xaml.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | namespace BodyBasicsWPF 8 | { 9 | using System; 10 | using System.Windows; 11 | 12 | /// 13 | /// Interaction logic for App 14 | /// 15 | public partial class App : Application 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DistanceTree/MoveSequence.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.Samples.Kinect.GestureRecognizer 7 | { 8 | using System.IO; 9 | using System.Windows; 10 | using Microsoft.Automata; 11 | using Microsoft.Automata.Internal; 12 | 13 | public class MoveSequence 14 | { 15 | 16 | public Automaton moveAutomaton; 17 | 18 | /*public int size; 19 | public List[,] moves; 20 | public List finalStates;*/ 21 | public CharSetSolver solver; 22 | 23 | public int currentState; 24 | public List deadStates; 25 | 26 | 27 | public MoveSequence(string regex) 28 | { 29 | solver = new CharSetSolver(BitWidth.BV7); 30 | moveAutomaton = solver.Convert("^(" + regex + ")$").Determinize(solver).Minimize(solver); 31 | currentState = 0; 32 | //solver.ShowGraph(moveAutomaton, "D"); 33 | //ComputeDeadStates(); 34 | 35 | } 36 | 37 | public void MakeOneStep(Transduction move) 38 | { 39 | char c = TransductionUtil.ToChar(move); 40 | IEnumerable> movesFromCurrent = moveAutomaton.GetMovesFrom(currentState); 41 | 42 | foreach (Move m in movesFromCurrent) 43 | { 44 | if (!solver.MkAnd(m.Condition, solver.MkCharConstraint(true, c)).IsEmpty) 45 | { 46 | currentState = m.TargetState; 47 | return; 48 | } 49 | } 50 | 51 | throw new Exception("Move not available"); 52 | } 53 | 54 | public List AvailableMoves() 55 | { 56 | IEnumerable> movesFromCurrent = moveAutomaton.GetMovesFrom(currentState); 57 | BvSet availableMoves = solver.MkAnd(solver.MkCharConstraint(true, '2'), solver.MkCharConstraint(true, '3')); 58 | List charl; 59 | foreach (Move m in movesFromCurrent) 60 | { 61 | charl = solver.GenerateAllCharacters(m.Condition, false).ToList(); 62 | availableMoves = solver.MkOr(m.Condition, availableMoves); 63 | } 64 | List movel = new List(); 65 | IEnumerable chare = solver.GenerateAllCharacters(availableMoves, false); 66 | //charl = chare.ToList(); 67 | foreach (Char c in chare) 68 | { 69 | movel.Add(TransductionUtil.ToMove(c)); 70 | } 71 | 72 | return movel; 73 | } 74 | 75 | 76 | public bool isFinal() 77 | { 78 | return moveAutomaton.IsFinalState(currentState); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /External/Antlr4.Runtime.v4.5.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/Antlr4.Runtime.v4.5.dll -------------------------------------------------------------------------------- /External/BigRationalLibrary.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/BigRationalLibrary.dll -------------------------------------------------------------------------------- /External/ICSharpCode.AvalonEdit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/ICSharpCode.AvalonEdit.dll -------------------------------------------------------------------------------- /External/ICSharpCode.AvalonEdit.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/ICSharpCode.AvalonEdit.pdb -------------------------------------------------------------------------------- /External/Microsoft.Automata.Z3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/Microsoft.Automata.Z3.dll -------------------------------------------------------------------------------- /External/Microsoft.Automata.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/Microsoft.Automata.dll -------------------------------------------------------------------------------- /External/Microsoft.Fast.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/Microsoft.Fast.dll -------------------------------------------------------------------------------- /External/antlr4-csharp-4.2.2-SNAPSHOT-complete.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/antlr4-csharp-4.2.2-SNAPSHOT-complete.jar -------------------------------------------------------------------------------- /External/x64/Kinect20.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x64/Kinect20.dll -------------------------------------------------------------------------------- /External/x64/Microsoft.Kinect.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x64/Microsoft.Kinect.dll -------------------------------------------------------------------------------- /External/x64/Microsoft.Z3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x64/Microsoft.Z3.dll -------------------------------------------------------------------------------- /External/x64/libz3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x64/libz3.dll -------------------------------------------------------------------------------- /External/x86/Microsoft.Z3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x86/Microsoft.Z3.dll -------------------------------------------------------------------------------- /External/x86/libz3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/External/x86/libz3.dll -------------------------------------------------------------------------------- /FastGestureRecognizer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {269A7B21-FBFE-4E7A-8BBE-C8DE2EC0D833} 8 | WinExe 9 | Properties 10 | BodyBasicsWPF 11 | BodyBasics-WPF 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | SAK 17 | SAK 18 | SAK 19 | SAK 20 | 21 | 22 | true 23 | DEBUG;TRACE 24 | full 25 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 26 | x64 27 | prompt 28 | MinimumRecommendedRules.ruleset 29 | true 30 | 31 | 32 | TRACE 33 | true 34 | pdbonly 35 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 36 | x64 37 | prompt 38 | MinimumRecommendedRules.ruleset 39 | true 40 | 41 | 42 | 43 | 44 | 45 | 46 | Images\Kinect.ico 47 | 48 | 49 | OnBuildSuccess 50 | 51 | 52 | true 53 | bin\x86\Debug\ 54 | DEBUG;TRACE 55 | full 56 | x86 57 | prompt 58 | MinimumRecommendedRules.ruleset 59 | true 60 | 61 | 62 | bin\x86\Release\ 63 | TRACE 64 | true 65 | pdbonly 66 | x86 67 | prompt 68 | MinimumRecommendedRules.ruleset 69 | true 70 | 71 | 72 | 73 | False 74 | External\Microsoft.Automata.dll 75 | 76 | 77 | External\Microsoft.Fast.dll 78 | 79 | 80 | False 81 | External\x64\Microsoft.Kinect.dll 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 4.0 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | MSBuild:Compile 100 | Designer 101 | 102 | 103 | MSBuild:Compile 104 | Designer 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | App.xaml 114 | Code 115 | 116 | 117 | 118 | 119 | 120 | MainWindow.xaml 121 | Code 122 | 123 | 124 | 125 | 126 | Code 127 | 128 | 129 | True 130 | True 131 | Resources.resx 132 | 133 | 134 | True 135 | Settings.settings 136 | True 137 | 138 | 139 | ResXFileCodeGenerator 140 | Resources.Designer.cs 141 | Designer 142 | 143 | 144 | 145 | SettingsSingleFileGenerator 146 | Settings.Designer.cs 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 168 | -------------------------------------------------------------------------------- /FastGestureRecognizer.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /GenerateCSharp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /GenerateCSharp/FastToCSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3F5F5E6A-F81C-4ADF-BE20-C7D95222EA96} 8 | Exe 9 | Properties 10 | GenerateCSharp 11 | GenerateCSharp 12 | v4.5 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | 40 | ..\External\Microsoft.Fast.dll 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 65 | -------------------------------------------------------------------------------- /GenerateCSharp/FastToCSharp.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /GenerateCSharp/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Fast; 2 | using System; 3 | 4 | namespace GenerateCSharp 5 | { 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | var input = args[0]; 11 | var output = args[1]; 12 | 13 | Console.WriteLine("CS: {0} -> {1}", input, output); 14 | 15 | var prog = Parser.ParseFromFile(input); 16 | CsharpGenerator.GenerateCode(prog, output); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GenerateCSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GenerateCSharp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GenerateCSharp")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("155f7f5b-8af2-413c-abcf-a409ae4fde17")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GestureRecognizer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreposeGestures", "Z3Experiments\Z3Experiments\PreposeGestures.csproj", "{AEB28AC8-F6AE-4689-89AF-E090B698A7E2}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreposeGestureRecognizer", "Z3GestureRecognizer\PreposeGestureRecognizer.csproj", "{CFA1F5A7-05D6-4E9D-9313-0617185F14FB}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreposeGesturesFrameReaderConsoleExample", "PreposeGesturesFrameReaderConsoleExample\PreposeGesturesFrameReaderConsoleExample.csproj", "{2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PreposeGesturesFrameReader", "PreposeGesturesFrameReader\PreposeGesturesFrameReader.csproj", "{8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A9C1724-739A-4B2B-9720-C437B6D65930}" 15 | ProjectSection(SolutionItems) = preProject 16 | AvalonEdit - OSS Use Approved.msg = AvalonEdit - OSS Use Approved.msg 17 | PrePose.pptx = PrePose.pptx 18 | README-MIT-open-source.txt = README-MIT-open-source.txt 19 | README.docx = README.docx 20 | EndProjectSection 21 | EndProject 22 | Global 23 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 24 | Debug|Any CPU = Debug|Any CPU 25 | Debug|Mixed Platforms = Debug|Mixed Platforms 26 | Debug|x64 = Debug|x64 27 | Release|Any CPU = Release|Any CPU 28 | Release|Mixed Platforms = Release|Mixed Platforms 29 | Release|x64 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 35 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|Mixed Platforms.Build.0 = Debug|x64 36 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|x64.ActiveCfg = Debug|x64 37 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Debug|x64.Build.0 = Debug|x64 38 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 41 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU 42 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2}.Release|x64.ActiveCfg = Release|Any CPU 43 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Debug|Any CPU.ActiveCfg = Debug|x64 44 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 45 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Debug|Mixed Platforms.Build.0 = Debug|x64 46 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Debug|x64.ActiveCfg = Debug|x64 47 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Debug|x64.Build.0 = Debug|x64 48 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Release|Any CPU.ActiveCfg = Release|x64 49 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Release|Mixed Platforms.ActiveCfg = Release|x64 50 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Release|Mixed Platforms.Build.0 = Release|x64 51 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Release|x64.ActiveCfg = Release|x64 52 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB}.Release|x64.Build.0 = Release|x64 53 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 54 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|Any CPU.Build.0 = Debug|Any CPU 55 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 56 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|Mixed Platforms.Build.0 = Debug|x64 57 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|x64.ActiveCfg = Debug|x64 58 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Debug|x64.Build.0 = Debug|x64 59 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Release|Any CPU.ActiveCfg = Release|Any CPU 60 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Release|Any CPU.Build.0 = Release|Any CPU 61 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 62 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Release|Mixed Platforms.Build.0 = Release|Any CPU 63 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE}.Release|x64.ActiveCfg = Release|Any CPU 64 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 67 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|Mixed Platforms.Build.0 = Debug|x64 68 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|x64.ActiveCfg = Debug|x64 69 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Debug|x64.Build.0 = Debug|x64 70 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU 73 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Release|Mixed Platforms.Build.0 = Release|Any CPU 74 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701}.Release|x64.ActiveCfg = Release|Any CPU 75 | EndGlobalSection 76 | GlobalSection(SolutionProperties) = preSolution 77 | HideSolutionNode = FALSE 78 | EndGlobalSection 79 | EndGlobal 80 | -------------------------------------------------------------------------------- /GestureRecognizer.vssscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" 10 | } 11 | -------------------------------------------------------------------------------- /Images/CheckedHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/CheckedHover.png -------------------------------------------------------------------------------- /Images/CheckedNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/CheckedNormal.png -------------------------------------------------------------------------------- /Images/Kinect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/Kinect.ico -------------------------------------------------------------------------------- /Images/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/Logo.png -------------------------------------------------------------------------------- /Images/ScreenshotHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/ScreenshotHover.png -------------------------------------------------------------------------------- /Images/ScreenshotNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/ScreenshotNormal.png -------------------------------------------------------------------------------- /Images/Status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/Status.png -------------------------------------------------------------------------------- /Images/UncheckedHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/UncheckedHover.png -------------------------------------------------------------------------------- /Images/UncheckedNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/UncheckedNormal.png -------------------------------------------------------------------------------- /Images/prepose-shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Images/prepose-shot.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Body Basics 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | (a|b|c|d|e|f|g|h|i) 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /PrePose.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/PrePose.pptx -------------------------------------------------------------------------------- /PreposeGesturesFrameReader/PreposeGesturesFrameReader.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8309A1CE-DB5E-49D6-9ED3-73FCB5BD3701} 8 | Library 9 | Properties 10 | PreposeGesturesFrameReader 11 | PreposeGesturesFrameReader 12 | v4.5 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | true 38 | bin\x64\Debug\ 39 | DEBUG;TRACE 40 | full 41 | x64 42 | prompt 43 | MinimumRecommendedRules.ruleset 44 | 45 | 46 | bin\x64\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | 54 | 55 | 56 | False 57 | ..\External\x64\Microsoft.Kinect.dll 58 | 59 | 60 | False 61 | ..\External\x64\Microsoft.Z3.dll 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {aeb28ac8-f6ae-4689-89af-e090b698a7e2} 81 | PreposeGestures 82 | 83 | 84 | 85 | 92 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReader/PreposeGesturesFrameReader.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReader/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PreposeGesturesFrameReader")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PreposeGesturesFrameReader")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("280ec387-1665-4c9f-b273-6b8e814dbf91")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/Kinect20.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/PreposeGesturesFrameReaderConsoleExample/Kinect20.dll -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/PreposeGesturesFrameReaderConsoleExample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2DF9A73B-36D5-4C58-9FE1-EC0C01A5EBEE} 8 | Exe 9 | Properties 10 | PreposeGesturesFrameReaderConsoleExample 11 | PreposeGesturesFrameReaderConsoleExample 12 | v4.5 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | 29 | 30 | AnyCPU 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | true 40 | bin\x64\Debug\ 41 | DEBUG;TRACE 42 | full 43 | x64 44 | prompt 45 | MinimumRecommendedRules.ruleset 46 | true 47 | 48 | 49 | bin\x64\Release\ 50 | TRACE 51 | true 52 | pdbonly 53 | x64 54 | prompt 55 | MinimumRecommendedRules.ruleset 56 | true 57 | 58 | 59 | 60 | False 61 | ..\External\x64\Microsoft.Kinect.dll 62 | 63 | 64 | False 65 | ..\External\x64\Microsoft.Z3.dll 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Always 83 | 84 | 85 | 86 | 87 | {8309a1ce-db5e-49d6-9ed3-73fcb5bd3701} 88 | PreposeGesturesFrameReader 89 | 90 | 91 | {aeb28ac8-f6ae-4689-89af-e090b698a7e2} 92 | PreposeGestures 93 | 94 | 95 | 96 | 97 | Always 98 | 99 | 100 | Always 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 115 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/PreposeGesturesFrameReaderConsoleExample.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Kinect; 7 | using PreposeGestures; 8 | 9 | /* This is a small console program that shows the FrameReader interface to Prepose. */ 10 | /* The FrameReader interface is intended to be as close to the existing Visual Gesture Builder interface as possible. */ 11 | /* This example is adapted from Ben Lower's VGBConsoleSample program. */ 12 | 13 | namespace PreposeGesturesFrameReaderConsoleExample 14 | { 15 | class Program 16 | { 17 | PreposeGesturesDatabase pgd; 18 | PreposeGesturesFrameSource pgfs; 19 | PreposeGesturesFrameReader pgr; 20 | Gesture gesture; 21 | KinectSensor sensor; 22 | BodyFrameReader bfr; 23 | 24 | static void Main(string[] args) 25 | { 26 | Program prog = new Program(); 27 | prog.Initialize(); 28 | Console.Read(); 29 | } 30 | 31 | private void Initialize() 32 | { 33 | sensor = KinectSensor.GetDefault(); 34 | bfr = sensor.BodyFrameSource.OpenReader(); 35 | bfr.FrameArrived += bfr_FrameArrived; 36 | pgd = new PreposeGesturesDatabase("soccer.app"); 37 | pgfs = new PreposeGesturesFrameSource(KinectSensor.GetDefault(), 0); 38 | 39 | foreach (var g in pgd.AvailableGestures) 40 | { 41 | if (g.Name.Equals("ola")) 42 | { 43 | gesture = g; 44 | pgfs.AddGesture(gesture); 45 | } 46 | } 47 | pgr = pgfs.OpenReader(); 48 | pgfs.GetIsEnabled(gesture); 49 | pgr.FrameArrived += pgr_FrameArrived; 50 | sensor.Open(); 51 | 52 | } 53 | 54 | void bfr_FrameArrived(object sender, BodyFrameArrivedEventArgs e) 55 | { 56 | //Check to see if VGB has a valid tracking id, if not find a new body to track 57 | if (!pgfs.IsTrackingIdValid) 58 | { 59 | 60 | using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame()) 61 | { 62 | if (bodyFrame != null) 63 | { 64 | Body[] bodies = new Body[6]; 65 | bodyFrame.GetAndRefreshBodyData(bodies); 66 | Body closestBody = null; 67 | //iterate through the bodies and pick the one closest to the camera 68 | foreach (Body b in bodies) 69 | { 70 | if (b.IsTracked) 71 | { 72 | if (closestBody == null) 73 | { 74 | closestBody = b; 75 | } 76 | else 77 | { 78 | Joint newHeadJoint = b.Joints[Microsoft.Kinect.JointType.Head]; 79 | Joint oldHeadJoint = closestBody.Joints[Microsoft.Kinect.JointType.Head]; 80 | if (newHeadJoint.TrackingState == TrackingState.Tracked && newHeadJoint.Position.Z < oldHeadJoint.Position.Z) 81 | { 82 | closestBody = b; 83 | } 84 | } 85 | } 86 | } 87 | 88 | //if we found a tracked body, update the trackingid for vgb 89 | if (closestBody != null) 90 | { 91 | pgfs.TrackingId = closestBody.TrackingId; 92 | } 93 | } 94 | } 95 | } 96 | } 97 | 98 | 99 | void pgr_FrameArrived(object sender, PreposeGesturesFrameArrivedEventArgs e) 100 | { 101 | 102 | using (var frame = e.FrameReference.AcquireFrame()) 103 | { 104 | if (frame != null) 105 | { 106 | //This check is almost certainly not needed for this sample, left in for debugging help 107 | if (pgfs.IsTrackingIdValid) 108 | { 109 | DiscreteGestureResult result = (DiscreteGestureResult)frame.GetDiscreteGestureResult(gesture); 110 | 111 | //If it is detected, and it this this gesture was not detected on the last frame, then call the gesture as hit 112 | //If you didn't require "FirstFrameDetected" every frame for the gesture would count as a unique instance 113 | //This case just uses "Detected" as a bool, we could tune our detection threshold by using result.Confidence and set our own min value 114 | if (result.Detected == true && result.FirstFrameDetected) 115 | { 116 | Console.WriteLine("Gesture detected!"); 117 | } 118 | } 119 | } 120 | } 121 | 122 | } 123 | 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PreposeGesturesFrameReaderConsoleExample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PreposeGesturesFrameReaderConsoleExample")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("eeb78c56-da59-4b2f-97a7-78ec21112f11")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/libz3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/PreposeGesturesFrameReaderConsoleExample/libz3.dll -------------------------------------------------------------------------------- /PreposeGesturesFrameReaderConsoleExample/soccer.app: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // Two common crowd gestures in soccer stadiums 3 | // Ola and Uuuuh 4 | ////////////////////////////////////////////////////////////////////// 5 | 6 | APP soccer: 7 | 8 | // so let's create a gesture 9 | GESTURE ola: 10 | 11 | // which is composed by poses 12 | POSE wrists_down: 13 | 14 | // point transforms and body parts 15 | point your left wrist down, 16 | point your right wrist down, 17 | 18 | // pointing down is not natural, rotation needed 19 | rotate your left wrist 30 degrees to your front, 20 | rotate your right wrist 30 degrees to your front, 21 | 22 | point your head up, 23 | 24 | // polish the gesture 25 | rotate your head 20 degrees to your front. 26 | 27 | POSE ola_middle: 28 | // groups of body parts 29 | point your wrists to your front. 30 | 31 | POSE wrists_up: 32 | //put your hands above your head. 33 | point your wrists up, 34 | point your head up. 35 | 36 | // let's test it 37 | // feedback, lines and bars 38 | EXECUTION: 39 | wrists_down, 40 | 41 | // we need more steps 42 | ola_middle, 43 | wrists_up, 44 | 45 | // complete the execution 46 | ola_middle, 47 | wrists_down. 48 | 49 | // more gestures 50 | GESTURE uuuuuh: 51 | 52 | // another pose more complex with chained rotations 53 | POSE uuuuuh_hands_on_head: 54 | //point your elbows to your front, 55 | //rotate your left elbow 45 degrees to your left, 56 | //rotate your right elbow 45 degrees to your right, 57 | //point your wrists up, 58 | //rotate your wrists 30 degrees to your back, 59 | //rotate your left wrist 30 degrees to your right, 60 | //rotate your right wrist 30 degrees to your left. 61 | // better coded with restrictions (relations) 62 | //put your hands above your head. 63 | touch your head with your right hand, 64 | touch your head with your left hand. 65 | 66 | EXECUTION: 67 | // reusing previous pose 68 | wrists_down, 69 | uuuuuh_hands_on_head. 70 | 71 | 72 | -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | using System.Resources; 10 | using System.Runtime.InteropServices; 11 | using System.Windows; 12 | 13 | // General Information about an assembly is controlled through the following 14 | // set of attributes. Change these attribute values to modify the information 15 | // associated with an assembly. 16 | [assembly: AssemblyTitle("BodyBasics-WPF")] 17 | [assembly: AssemblyDescription("")] 18 | [assembly: AssemblyConfiguration("")] 19 | [assembly: AssemblyTrademark("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | // In order to begin building localizable applications, set 27 | // CultureYouAreCodingWith in your .csproj file 28 | // inside a . For example, if you are using US english 29 | // in your source files, set the to en-US. Then uncomment 30 | // the NeutralResourceLanguage attribute below. Update the "en-US" in 31 | // the line below to match the UICulture setting in the project file. 32 | 33 | //// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 34 | 35 | [assembly: ThemeInfo( 36 | ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located 37 | // (used if a resource is not found in the page, 38 | // or application resource dictionaries) 39 | ResourceDictionaryLocation.SourceAssembly)] // where the generic resource dictionary is located 40 | // (used if a resource is not found in the page, 41 | // app, or any theme specific resource dictionaries) 42 | 43 | // Version information for an assembly consists of the following four values: 44 | // 45 | // Major Version 46 | // Minor Version 47 | // Build Number 48 | // Revision 49 | // 50 | // You can specify all the values or you can default the Build and Revision Numbers 51 | // by using the '*' as shown below: 52 | // [assembly: AssemblyVersion("1.0.*")][assembly: NeutralResourcesLanguageAttribute("en-US")] 53 | [assembly: NeutralResourcesLanguage("en-US")] 54 | [assembly: CLSCompliant(true)] 55 | -------------------------------------------------------------------------------- /Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18051 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BodyBasicsWPF.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BodyBasicsWPF.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Initializing. 65 | /// 66 | internal static string InitializingStatusTextFormat { 67 | get { 68 | return ResourceManager.GetString("InitializingStatusTextFormat", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to No ready Kinect found!. 74 | /// 75 | internal static string NoSensorStatusText { 76 | get { 77 | return ResourceManager.GetString("NoSensorStatusText", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to FPS = {0:N1} Time = {1}. 83 | /// 84 | internal static string StandardStatusTextFormat { 85 | get { 86 | return ResourceManager.GetString("StandardStatusTextFormat", resourceCulture); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Initializing 122 | 123 | 124 | No ready Kinect found! 125 | 126 | 127 | FPS = {0:N1} Time = {1} 128 | 129 | -------------------------------------------------------------------------------- /Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18051 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BodyBasicsWPF.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /README.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/README.docx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prepose 2 | ###A Scripting Language for Kinect v2 Gestures 3 | 4 | With the rise of sensors such as the Microsoft Kinect, Leap Motion, and hand motion sensors in phones such as the Samsung Galaxy S5, natural user interface (NUI) has become practical. NUI raises two key challenges for the developer: first, developers must create new code to recognize new gestures, which is a time consuming process. Second, to recognize these gestures, applications must have access to depth and video of the user, raising privacy problems. We address both problems with Prepose, a novel domainspecific language (DSL) for easily building gesture recognizers, combined with a system architecture that protects user privacy against untrusted applications by running Prepose code in a trusted core, and only interacting with applications via gesture events. 5 | 6 | Prepose lowers the cost of developing new gesture recognizers by exposing a range of primitives to developers that can capture many different gestures. Further, Prepose is designed to enable static analysis using SMT solvers, allowing the system to check security and privacy properties before running a gesture recognizer. We demonstrate that Prepose is expressive by creating novel gesture recognizers for 28 gestures in three representative domains: physical therapy, tai-chi, and ballet. We further show that matching user motions against Prepose gestures is efficient, by measuring on traces obtained from Microsoft Kinect runs. 7 | 8 | Because of the privacy-sensitive nature of alwayson Kinect sensors, we have designed the Prepose language to be analyzable: we enable security and privacy assurance through precise static analysis. In Prepose, we employ a sound static analysis that uses an SMT solver (Z3), something that works well on Prepose but would be hardly possible for a general-purpose language. We demonstrate that static analysis of Prepose code is efficient, and investigate how analysis time scales with the complexity of gestures. Our Z3-based approach scales well in practice: safety checking is under 0.5 seconds per gesture; average validity checking time is only 188 ms; lastly, for 97% of the cases, the conflict detection time is below 5 seconds, with only one query taking longer than 15 seconds. 9 | 10 | ![Prepose example](Images/prepose-shot.png) 11 | 12 | For more, please read this paper: http://research.microsoft.com/apps/pubs/default.aspx?id=232011 13 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/GestureStatistics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | 8 | 9 | namespace PreposeGestures 10 | { 11 | public class StatisticsEntryMatch 12 | { 13 | public string poseName; 14 | public string gestureName; 15 | public long timeMs; 16 | public long uid; 17 | } 18 | 19 | public class StatisticsEntrySynthesize 20 | { 21 | public string poseName; 22 | public string gestureName; 23 | public long timeMs; 24 | public long uid; 25 | } 26 | 27 | public static class GestureStatistics 28 | { 29 | public static List matchTimes; 30 | public static List synthTimes; 31 | 32 | public static void DumpStatisticsToFile(string filename) 33 | { 34 | TextWriter writer = File.CreateText(filename); 35 | 36 | writer.WriteLine("GestureName,PoseName,MatchTime,MatchUID"); 37 | 38 | foreach (var match in matchTimes) 39 | { 40 | writer.WriteLine("{0},{1},{2},{3}", match.gestureName, match.poseName, match.timeMs, match.uid); 41 | } 42 | writer.Flush(); 43 | 44 | writer.WriteLine(); 45 | writer.WriteLine("GestureName,PoseName,SynthTime,MatchUID"); 46 | 47 | foreach (var syn in synthTimes) 48 | { 49 | writer.WriteLine("{0},{1},{2},{3}", syn.gestureName, syn.poseName, syn.timeMs, syn.uid); 50 | } 51 | writer.Flush(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Analysis/Ambiguity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Z3; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | 7 | namespace PreposeGestures 8 | { 9 | public class Ambiguity 10 | { 11 | // public IList Transforms { get; private set; } 12 | 13 | // public Ambiguity(App app) 14 | // { 15 | // this.Transforms = GetTransforms(app); 16 | // } 17 | 18 | // private Ambiguity(IList transforms, IList names = null) 19 | // { 20 | // Contract.Requires(names == null || names.Count == transforms.Count); 21 | // this.Transforms = new List(transforms); 22 | // } 23 | 24 | // private static IList GetTransforms(App app) 25 | // { 26 | // throw new NotImplementedException(); 27 | // } 28 | 29 | // /// 30 | // /// Checks if the set has duplicate transforms. 31 | // /// 32 | // /// 33 | // public bool HasDuplicates(IList names = null) 34 | // { 35 | // for (int i = 0; i < this.Transforms.Count; ++i) 36 | // { 37 | // // these are ordered pairs of transforms (i,j) where i> GetPairs() { 58 | // for (int i = 0; i < this.Transforms.Count; ++i) 59 | // { 60 | // // these are ordered pairs of transforms (i,j) where i 64 | // ( 65 | // string.Format("({0},{1})",i,j), 66 | // Transforms[i].Compose(Transforms[j]) 67 | // ); 68 | // yield return result; 69 | // } 70 | // } 71 | // } 72 | 73 | // public bool HasConflictingPairs() 74 | // { 75 | // var pairs = GetPairs(); 76 | // IList transforms = pairs.Select(p => p.Value).ToList(); 77 | // IList names = pairs.Select(p => p.Key).ToList(); 78 | // var pairAmbiguity = new Ambiguity(transforms, names); 79 | // return pairAmbiguity.HasDuplicates(); 80 | // } 81 | 82 | 83 | public class AmbiguityTime 84 | { 85 | public Gesture Gesture1 { get; internal set; } 86 | public Gesture Gesture2 { get; internal set; } 87 | 88 | public long Time { get; internal set; } 89 | 90 | public bool Conflict { get; internal set; } 91 | 92 | public SolverCheckResult CheckResult { get; internal set; } 93 | } 94 | 95 | public static bool DumpZ3Constraints = true; 96 | 97 | /// 98 | /// Check for pairwise ambiguity 99 | /// 100 | /// 101 | public static bool HasPairwiseConflicts(App app, out List allExceptions, out List ambiguityTimes, int precision = 15) 102 | { 103 | List conflictGestures = (List)app.Gestures; 104 | 105 | bool result = false; 106 | allExceptions = new List(); 107 | ambiguityTimes = new List(); 108 | 109 | for (int i = 0; i < conflictGestures.Count - 1; i++) 110 | { 111 | for (int j = i + 1; j < conflictGestures.Count; j++) 112 | { 113 | var gesture1 = conflictGestures[i]; 114 | var gesture2 = conflictGestures[j]; 115 | 116 | // Create const input body 117 | var input = Z3Body.MkZ3Const(); 118 | 119 | var allJoints = EnumUtil.GetValues().ToList(); 120 | 121 | Z3Body transformed1 = null; 122 | Z3Body transformed2 = null; 123 | 124 | BoolExpr evaluation1 = Z3Math.True; 125 | BoolExpr evaluation2 = Z3Math.True; 126 | 127 | // Pass input through both gestures 128 | gesture1.FinalResult(input, out transformed1, out evaluation1); 129 | gesture2.FinalResult(input, out transformed2, out evaluation2); 130 | 131 | // Check if it is possible that both outputs are equals 132 | // This is performed by checking if is possible that all expressions are true 133 | 134 | var isNearExpr = transformed1.IsNearerThan( 135 | transformed2, precision); 136 | var expr = Z3.Context.MkAnd(isNearExpr, evaluation1, evaluation2); 137 | 138 | // If we are dumping Z3 constraints, then convert the expression to a SMTLIB formatted string 139 | // and dump it to disk. Note this is not included in the timing for the individual pair of gestures, 140 | // but it _is_ included in the timing for the app overall. 141 | if (DumpZ3Constraints) 142 | { 143 | string exprName = String.Join("X", gesture1.Name, gesture2.Name); 144 | string exprPath = exprName + ".smt2"; 145 | Z3AnalysisInterface.WriteExprToDisk(expr, exprName, exprPath); 146 | } 147 | 148 | // Check if we have an ambiguity conflict. Record the time it takes. 149 | var stopwatch = new Stopwatch(); 150 | stopwatch.Start(); 151 | var checkResult = Z3AnalysisInterface.CheckStatus(expr); 152 | stopwatch.Stop(); 153 | 154 | 155 | if (checkResult.Status == Status.SATISFIABLE) 156 | { 157 | var witness = Z3AnalysisInterface.CreateBodyWitness( 158 | input, 159 | checkResult.Model, 160 | allJoints, 161 | JointTypeHelper.CreateDefaultZ3Body()); 162 | 163 | var exception = new PairwiseConflictException( 164 | "Conflict detected between pair of gestures", 165 | gesture1, 166 | gesture2, 167 | witness); 168 | 169 | allExceptions.Add(exception); 170 | 171 | result = true; 172 | } 173 | // TODO the witness here should exist, this case shouldn't be needed 174 | else if (checkResult.Status == Status.UNKNOWN) 175 | { 176 | var witness = JointTypeHelper.CreateDefaultZ3Body(); 177 | 178 | var exception = new PairwiseConflictException( 179 | "Conflict detected between pair of gestures, the reason is unknown", 180 | gesture1, 181 | gesture2, 182 | witness); 183 | 184 | allExceptions.Add(exception); 185 | 186 | result = true; 187 | } 188 | 189 | ambiguityTimes.Add(new AmbiguityTime 190 | { 191 | Gesture1 = gesture1, 192 | Gesture2 = gesture2, 193 | Time = stopwatch.ElapsedMilliseconds, 194 | Conflict = result, 195 | CheckResult = checkResult 196 | }); 197 | 198 | 199 | } 200 | } 201 | 202 | return result; 203 | } 204 | } 205 | public class PairwiseConflictException : Exception 206 | { 207 | public Z3Body Witness { get; private set; } 208 | public Gesture Gesture1 { get; private set; } 209 | public Gesture Gesture2 { get; private set; } 210 | public PairwiseConflictException(string message) : base(message) { } 211 | public PairwiseConflictException(string message, Gesture gesture1, Gesture gesture2, Z3Body body) 212 | : base(message) 213 | { 214 | this.Witness = body; 215 | this.Gesture1 = gesture1; 216 | this.Gesture2 = gesture2; 217 | } 218 | 219 | public override string ToString() 220 | { 221 | return string.Format("Gesture 1: {0}, gesture 2: {1}, witness: {2}", 222 | this.Gesture1.Name, this.Gesture2.Name, this.Witness); 223 | } 224 | } 225 | } 226 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Analysis/Safety.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Z3; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Diagnostics.Contracts; 5 | 6 | namespace PreposeGestures 7 | { 8 | /// 9 | /// Various safety checks. 10 | /// 11 | internal class Safety 12 | { 13 | public static bool IsWithinDefaultSafetyRestrictions( 14 | App app, 15 | out List allExceptions, 16 | out List elapsedTimes) 17 | { 18 | allExceptions = new List(); 19 | elapsedTimes = new List(); 20 | var result = true; 21 | foreach (var gesture in app.Gestures) 22 | { 23 | List exceptions = null; 24 | var stopwatch = new Stopwatch(); 25 | stopwatch.Start(); 26 | if (!IsWithinDefaultSafetyRestrictions(gesture, out exceptions)) 27 | { 28 | result = false; 29 | Contract.Assert(exceptions != null); 30 | allExceptions.AddRange(exceptions); 31 | } 32 | stopwatch.Stop(); 33 | elapsedTimes.Add(stopwatch.ElapsedMilliseconds); 34 | } 35 | return result; 36 | } 37 | 38 | /// 39 | /// Checks if the pose is within default safety 40 | /// restrictions when the transform and restrictions 41 | /// are applied. 42 | /// 43 | /// True if it's safe 44 | public static bool IsWithinDefaultSafetyRestrictions(Gesture gesture, out List exceptions) 45 | { 46 | bool result = true; 47 | exceptions = new List(); 48 | foreach (var step in gesture.Steps) 49 | { 50 | var pose = step.Pose; 51 | Z3Body witness = null; 52 | if (!Safety.IsWithinSafetyRestrictions(pose, out witness)) 53 | { 54 | var exception = new PoseSafetyException( 55 | "Default safety violation", pose, witness 56 | ); 57 | exceptions.Add(exception); 58 | result = false; 59 | } 60 | } 61 | 62 | return result; 63 | } 64 | 65 | 66 | /// 67 | /// Checks if the pose is within default safety 68 | /// restrictions when the transform and restrictions 69 | /// are applied. 70 | /// 71 | /// True if it's safe 72 | public static bool IsWithinSafetyRestrictions(Pose pose, out Z3Body witness) 73 | { 74 | Z3Body input = Z3Body.MkZ3Const(); 75 | Z3Body transformed = pose.Transform.Transform(input); 76 | 77 | IBodyRestriction safe = Safety.DefaultSafetyRestriction(); 78 | 79 | BoolExpr inputSafe = safe.Evaluate(input); 80 | BoolExpr transformedRestricted = pose.Restriction.Evaluate(transformed); 81 | 82 | // Try to generate a unsafe witness using the transform 83 | BoolExpr outputUnsafe = Z3.Context.MkNot(safe.Evaluate(transformed)); 84 | 85 | // Put together all expressions and search for unsat 86 | BoolExpr expr = Z3.Context.MkAnd(inputSafe, transformedRestricted, outputUnsafe); 87 | 88 | SolverCheckResult solverResult = Z3AnalysisInterface.CheckStatus(expr); 89 | 90 | if (solverResult.Status == Status.SATISFIABLE) 91 | { 92 | //Z3Body 93 | witness = 94 | Z3AnalysisInterface.CreateBodyWitness( 95 | transformed, 96 | solverResult.Model, 97 | pose.GetAllJointTypes(), 98 | JointTypeHelper.CreateDefaultZ3Body()); 99 | 100 | return false; 101 | } 102 | else if (solverResult.Status == Status.UNKNOWN) 103 | { 104 | //Z3Body 105 | witness = JointTypeHelper.CreateDefaultZ3Body(); 106 | 107 | return false; 108 | } 109 | else 110 | { 111 | Contract.Assert(solverResult.Status == Status.UNSATISFIABLE); 112 | witness = null; 113 | return true; 114 | } 115 | } 116 | 117 | 118 | /// 119 | /// This is a basic safety check to make sure we don't break any bones. 120 | /// 121 | /// True if safe 122 | public static IBodyRestriction DefaultSafetyRestriction() 123 | { 124 | var result = new CompositeBodyRestriction(); 125 | 126 | int inclinationThreshold = 45; 127 | 128 | // Head 129 | // Make sure neck is not inclinated beyond the threshold 130 | var head = new SimpleBodyRestriction(body => 131 | { 132 | Z3Point3D up = new Z3Point3D(0, 1, 0); 133 | BoolExpr expr1 = body.Joints[JointType.Head].IsAngleBetweenLessThan(up, inclinationThreshold); 134 | BoolExpr expr2 = body.Joints[JointType.Neck].IsAngleBetweenLessThan(up, inclinationThreshold); 135 | BoolExpr expr = Z3.Context.MkAnd(expr1, expr2); 136 | 137 | return expr; 138 | }); 139 | result.And(head); 140 | 141 | // Spine 142 | // Make sure spine is not inclinated beyond the threshold 143 | var spine = new SimpleBodyRestriction(body => 144 | { 145 | Z3Point3D up = new Z3Point3D(0, 1, 0); 146 | BoolExpr expr1 = body.Joints[JointType.SpineMid].IsAngleBetweenLessThan(up, inclinationThreshold); 147 | BoolExpr expr2 = body.Joints[JointType.SpineShoulder].IsAngleBetweenLessThan(up, inclinationThreshold); 148 | BoolExpr expr3 = 149 | body.Joints[JointType.SpineMid].IsAngleBetweenLessThan( 150 | body.Joints[JointType.SpineShoulder], inclinationThreshold); 151 | BoolExpr expr = Z3.Context.MkAnd(expr1, expr2, expr3); 152 | 153 | return expr; 154 | }); 155 | result.And(spine); 156 | 157 | // Shoulders 158 | // Make sure shoulders are not bent 159 | var shoulders = new SimpleBodyRestriction(body => 160 | { 161 | BoolExpr expr = 162 | body.Joints[JointType.SpineMid].IsAngleBetweenGreaterThan( 163 | body.Joints[JointType.SpineShoulder], 120); 164 | 165 | return expr; 166 | }); 167 | result.And(shoulders); 168 | 169 | // Elbows 170 | // Make sure elbows are not behind the back 171 | // And also that they are not on the top/back sub-space 172 | var elbows = new SimpleBodyRestriction(body => 173 | { 174 | BoolExpr exprRight1 = 175 | Z3.Context.MkNot( 176 | Z3.Context.MkAnd( 177 | Z3.Context.MkLt(body.Joints[JointType.ElbowRight].Z, Z3Math.Zero), 178 | Z3.Context.MkLt(body.Joints[JointType.ElbowRight].X, Z3Math.Zero))); 179 | 180 | BoolExpr exprRight2 = 181 | Z3.Context.MkNot( 182 | Z3.Context.MkAnd( 183 | Z3.Context.MkLt(body.Joints[JointType.ElbowRight].Z, Z3Math.Zero), 184 | Z3.Context.MkGt(body.Joints[JointType.ElbowRight].Y, Z3Math.Zero))); 185 | 186 | BoolExpr exprLeft1 = 187 | Z3.Context.MkNot( 188 | Z3.Context.MkAnd( 189 | Z3.Context.MkLt(body.Joints[JointType.ElbowLeft].Z, Z3Math.Zero), 190 | Z3.Context.MkGt(body.Joints[JointType.ElbowLeft].X, Z3Math.Zero))); 191 | 192 | BoolExpr exprLeft2 = 193 | Z3.Context.MkNot( 194 | Z3.Context.MkAnd( 195 | Z3.Context.MkLt(body.Joints[JointType.ElbowLeft].Z, Z3Math.Zero), 196 | Z3.Context.MkGt(body.Joints[JointType.ElbowLeft].Y, Z3Math.Zero))); 197 | 198 | BoolExpr expr = Z3.Context.MkAnd(exprLeft1, exprLeft2, exprRight1, exprRight2); 199 | 200 | return expr; 201 | }); 202 | result.And(elbows); 203 | 204 | // Wrists 205 | // Make sure the inclination of wrists towards the back is not higher than the inclinatin of the elbows 206 | // unless elbows are up or wrists are directed to torso 207 | // TODO 208 | 209 | // Hips 210 | // Make sure hips are aligned with the shoulders or at lest within the range 211 | var hips = new SimpleBodyRestriction(body => 212 | { 213 | Z3Point3D shouldersSum = 214 | body.Joints[JointType.ShoulderLeft].GetInverted() + 215 | body.Joints[JointType.ShoulderRight]; 216 | 217 | Z3Point3D hipsSum = 218 | body.Joints[JointType.HipLeft].GetInverted() + 219 | body.Joints[JointType.HipRight]; 220 | 221 | BoolExpr expr = shouldersSum.IsAngleBetweenLessThan(hipsSum, 45); 222 | return expr; 223 | }); 224 | result.And(hips); 225 | 226 | // Legs 227 | // Make sure legs are not higher than threshold 228 | var legs = new SimpleBodyRestriction(body => 229 | { 230 | BoolExpr expr1 = Z3.Context.MkLt(body.Joints[JointType.KneeLeft].Y, Z3Math.Real(0)); 231 | BoolExpr expr2 = Z3.Context.MkLt(body.Joints[JointType.KneeRight].Y, Z3Math.Real(0)); 232 | BoolExpr expr = Z3.Context.MkAnd(expr1, expr2); 233 | 234 | return expr; 235 | }); 236 | result.And(legs); 237 | 238 | // Ankles 239 | // Make sure ankles are not inclinated up more than knees 240 | // unless ankles are pointing back 241 | // TODO 242 | 243 | return result; 244 | } 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Analysis/Validity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Z3; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Diagnostics.Contracts; 10 | 11 | namespace PreposeGestures 12 | { 13 | class Validity 14 | { 15 | 16 | public static bool IsInternallyValid( 17 | App app, 18 | out List allExceptions, 19 | out List elapsedTimes) 20 | { 21 | allExceptions = new List(); 22 | elapsedTimes = new List(); 23 | var result = true; 24 | foreach (var gesture in app.Gestures) 25 | { 26 | List exceptions = null; 27 | var stopwatch = new Stopwatch(); 28 | stopwatch.Start(); 29 | if (!Validity.IsInternallyValid(gesture, out exceptions)) 30 | { 31 | result = false; 32 | Contract.Assert(exceptions != null); 33 | allExceptions.AddRange(exceptions); 34 | } 35 | stopwatch.Stop(); 36 | elapsedTimes.Add(stopwatch.ElapsedMilliseconds); 37 | } 38 | return result; 39 | } 40 | 41 | public static bool IsInternallyValid(Gesture gesture, out List exceptions) 42 | { 43 | bool result = true; 44 | exceptions = new List(); 45 | foreach (var step in gesture.Steps) 46 | { 47 | var pose = step.Pose; 48 | Z3Body witness = null; 49 | if (!Validity.IsInternallyValid(pose)) 50 | { 51 | var exception = new PoseSafetyException( 52 | "Pose failed internal validity check!", pose, witness 53 | ); 54 | exceptions.Add(exception); 55 | result = false; 56 | } 57 | } 58 | 59 | return result; 60 | } 61 | 62 | public static bool IsInternallyValid(Pose pose) 63 | { 64 | Z3Body input = Z3Body.MkZ3Const(); 65 | Z3Body transformed = pose.Transform.Transform(input); 66 | 67 | // We have to check that the pose is within the default safety restriction 68 | IBodyRestriction safe = Safety.DefaultSafetyRestriction(); 69 | 70 | BoolExpr inputSafe = safe.Evaluate(input); 71 | BoolExpr transformedRestricted = pose.Restriction.Evaluate(transformed); 72 | 73 | // Try to generate a safe witness using the transform 74 | BoolExpr outputSafe = safe.Evaluate(transformed); 75 | 76 | // Check to see if the transform is not satisfiable -- if so, then it is not internally valid 77 | BoolExpr expr = Z3.Context.MkAnd(inputSafe, transformedRestricted, outputSafe); 78 | 79 | 80 | SolverCheckResult solverResult = Z3AnalysisInterface.CheckStatus(expr); 81 | 82 | if (solverResult.Status == Status.SATISFIABLE) 83 | { 84 | // We can create a witness - therefore the pose must be valid 85 | return true; 86 | } 87 | else if (solverResult.Status == Status.UNKNOWN) 88 | { 89 | return false; 90 | } 91 | else 92 | { 93 | Contract.Assert(solverResult.Status == Status.UNSATISFIABLE); 94 | // Pose is not internally valid and as a result there can be no witness created 95 | return false; 96 | } 97 | 98 | 99 | 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Analysis/Z3AnalysisInterface.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Z3; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.IO; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using System.Runtime.ExceptionServices; 10 | 11 | namespace PreposeGestures 12 | { 13 | /// 14 | /// Check various safety conditions using the Z3 solver. 15 | /// 16 | public static class Z3AnalysisInterface 17 | { 18 | /// 19 | /// Generates a witness body tha matches the restrictions that 20 | /// are passed in. 21 | /// 22 | /// 23 | /// 24 | public static Z3Body GenerateWitness(IBodyRestriction bodyRestriction) 25 | { 26 | var body = Z3Body.MkZ3Const(); 27 | 28 | var expr = bodyRestriction.Evaluate(body); 29 | 30 | var checkResult = CheckStatus(expr); 31 | var witness = CreateBodyWitness( 32 | body, 33 | checkResult.Model, 34 | bodyRestriction.GetJointTypes(), 35 | JointTypeHelper.CreateDefaultZ3Body()); 36 | 37 | return witness; 38 | } 39 | 40 | /// 41 | /// Returns a witness body that matches given output restrictions 42 | /// for a particular bodyTransform. 43 | /// 44 | /// 45 | /// 46 | /// 47 | public static Z3Body GenerateWitness(BodyTransform bodyTransform, CompositeBodyRestriction outputBodyRestriction) 48 | { 49 | var body = Z3Body.MkZ3Const(); 50 | var transformedBody = bodyTransform.Transform(body); 51 | 52 | var expr = outputBodyRestriction.Evaluate(transformedBody); 53 | 54 | var evaluatedJoints = 55 | JointTypeHelper.MergeJointTypeLists( 56 | bodyTransform.GetJointTypes(), 57 | outputBodyRestriction.GetJointTypes()); 58 | 59 | var checkResult = CheckStatus(expr); 60 | if (checkResult.Status == Status.SATISFIABLE) 61 | { 62 | var witness = CreateBodyWitness( 63 | body, 64 | checkResult.Model, 65 | evaluatedJoints, 66 | JointTypeHelper.CreateDefaultZ3Body()); 67 | return witness; 68 | } 69 | else 70 | { 71 | return null; 72 | } 73 | } 74 | 75 | /// 76 | /// Produces a witness body given input restrictions, output 77 | /// restrictions and a transform. 78 | /// 79 | /// 80 | /// 81 | /// 82 | /// 83 | public static Z3Body GenerateWitness( 84 | CompositeBodyRestriction inputBodyRestriction, 85 | BodyTransform bodyTransform, 86 | CompositeBodyRestriction outputBodyRestriction) 87 | { 88 | var body = Z3Body.MkZ3Const(); 89 | var transformedBody = bodyTransform.Transform(body); 90 | 91 | var expr1 = inputBodyRestriction.Evaluate(body); 92 | var expr2 = outputBodyRestriction.Evaluate(transformedBody); 93 | var expr = Z3.Context.MkAnd(expr1, expr2); 94 | 95 | var evaluatedJoints = 96 | JointTypeHelper.MergeJointTypeLists( 97 | inputBodyRestriction.GetJointTypes(), 98 | bodyTransform.GetJointTypes(), 99 | outputBodyRestriction.GetJointTypes()); 100 | 101 | var checkResult = CheckStatus(expr); 102 | if (checkResult.Status == Status.SATISFIABLE) 103 | { 104 | var witness = CreateBodyWitness( 105 | body, 106 | checkResult.Model, 107 | evaluatedJoints, 108 | JointTypeHelper.CreateDefaultZ3Body()); 109 | return witness; 110 | } 111 | else 112 | { 113 | return null; 114 | } 115 | } 116 | 117 | // Generates a body witness which satisfies two conditions 118 | // 1. It is within a range (angle threshold) of a transform from a start body 119 | // 2. It is within the considered restrictions 120 | public static Z3Target GenerateTarget( 121 | BodyTransform transform, 122 | CompositeBodyRestriction restriction, 123 | Z3Body startBody, 124 | int angleThreshold) 125 | { 126 | var z3ConstBody = Z3Body.MkZ3Const(); 127 | z3ConstBody.Norms = startBody.Norms; 128 | var transformedBody = transform.Transform(startBody); 129 | 130 | var joints = transform.GetJointTypes().Union(restriction.GetJointTypes()).ToList(); 131 | var isNearExpr = z3ConstBody.IsAngleBetweenLessThan(transformedBody, joints, angleThreshold); 132 | var evaluateExpr = restriction.Evaluate(z3ConstBody); 133 | //var normsExpr = BodyRestrictionBuilder.EvaluateNorms(startBody, z3ConstBody); 134 | 135 | //var expr = Z3.Context.MkAnd(isNearExpr, evaluateExpr, normsExpr); 136 | //var expr = Z3.Context.MkAnd(evaluateExpr, normsExpr); 137 | var expr = Z3.Context.MkAnd(evaluateExpr, isNearExpr); 138 | 139 | var checkResult = CheckStatus(expr); 140 | if (checkResult.Status == Status.SATISFIABLE) 141 | { 142 | var witness = CreateBodyWitness( 143 | z3ConstBody, 144 | checkResult.Model, 145 | restriction.GetJointTypes(), 146 | startBody); 147 | 148 | var target = new Z3Target(); 149 | target.Body = witness; 150 | target.RestrictedJoints = restriction.GetJointTypes(); 151 | target.TransformedJoints = transform.GetJointTypes(); 152 | 153 | foreach (var jointType in transform.GetJointTypes()) 154 | target.Body.Joints[jointType] = transformedBody.Joints[jointType]; 155 | 156 | return target; 157 | } 158 | else 159 | { 160 | return null; 161 | } 162 | } 163 | 164 | 165 | public static void WriteExprToDisk(BoolExpr expr, string exprName, string path) 166 | { 167 | // Convert the expr to a SMT-LIB formatted string 168 | var exprArray = new BoolExpr[0]; 169 | var output = Z3.Context.BenchmarkToSMTString(exprName, "QF_AUFLIRA", "unknown", "", exprArray, expr); 170 | 171 | if (File.Exists(path)) 172 | { 173 | // // Note that no lock is put on the 174 | // // file and the possibility exists 175 | // // that another process could do 176 | // // something with it between 177 | // // the calls to Exists and Delete. 178 | File.Delete(path); 179 | } 180 | 181 | //// Create the file. 182 | using (FileStream fs = File.Create(path)) 183 | { 184 | Byte[] info = new UTF8Encoding(true).GetBytes(output); 185 | // Write the SMT string to the file 186 | fs.Write(info, 0, info.Length); 187 | } 188 | } 189 | 190 | 191 | /// 192 | /// Checks expression status and returns expression status 193 | /// plus a model if applicable. 194 | /// 195 | /// 196 | /// 197 | [HandleProcessCorruptedStateExceptions] 198 | public static SolverCheckResult CheckStatus(BoolExpr expr) 199 | { 200 | var result = new SolverCheckResult(); 201 | var exprArray = new BoolExpr[0]; 202 | Solver solver; 203 | bool bTimedOut = false; 204 | 205 | solver = Z3.Context.MkSolver("AUFLIRA"); 206 | solver.Assert(expr); 207 | 208 | var status = solver.Check(); 209 | Statistics stats = solver.Statistics; 210 | 211 | result.Status = status; 212 | result.stats = stats; 213 | result.bTimedOut = bTimedOut; 214 | 215 | if (status == Status.SATISFIABLE) 216 | { 217 | result.Model = solver.Model; 218 | } 219 | 220 | if (status == Status.UNKNOWN) 221 | { 222 | result.ReasonUnknown = solver.ReasonUnknown; 223 | } 224 | 225 | if (bTimedOut) 226 | { 227 | result.Status = Status.UNKNOWN; 228 | } 229 | 230 | 231 | return result; 232 | } 233 | 234 | public static Z3Body CreateBodyWitness( 235 | Z3Body z3ConstCheckedBody, 236 | Model model, 237 | List evaluatedJoints, 238 | Z3Body defaultBody) 239 | { 240 | var witness = new Z3Body(); 241 | var jointTypes = EnumUtil.GetValues(); 242 | foreach (var jointType in jointTypes) 243 | { 244 | if (evaluatedJoints.Contains(jointType)) 245 | { 246 | var joint = new Z3Point3D( 247 | model.Evaluate(z3ConstCheckedBody.Joints[jointType].X, true) as ArithExpr, 248 | model.Evaluate(z3ConstCheckedBody.Joints[jointType].Y, true) as ArithExpr, 249 | model.Evaluate(z3ConstCheckedBody.Joints[jointType].Z, true) as ArithExpr); 250 | witness.Joints.Add(jointType, joint); 251 | 252 | var norm = model.Evaluate(z3ConstCheckedBody.Norms[jointType]) as ArithExpr; 253 | 254 | // Check if norm is still an app (meaning it can be anything), then set it to be the default norm 255 | if (norm.ASTKind == Z3_ast_kind.Z3_APP_AST) 256 | witness.Norms.Add(jointType, defaultBody.Norms[jointType]); 257 | else 258 | witness.Norms.Add(jointType, norm); 259 | } 260 | else 261 | { 262 | witness.Joints.Add(jointType, defaultBody.Joints[jointType]); 263 | witness.Norms.Add(jointType, defaultBody.Norms[jointType]); 264 | } 265 | } 266 | 267 | return witness; 268 | } 269 | } 270 | 271 | /// 272 | /// Wraps the result of solver computation. 273 | /// 274 | public class SolverCheckResult 275 | { 276 | public Model Model { get; internal set; } 277 | 278 | public Status Status { get; internal set; } 279 | 280 | public Statistics stats { get; internal set; } 281 | 282 | public string ReasonUnknown { get; internal set; } 283 | 284 | public bool bTimedOut { get; internal set; } 285 | } 286 | 287 | public class SafetyException : Exception 288 | { 289 | public SafetyException(string message) : base(message) { } 290 | } 291 | 292 | public class PoseSafetyException : SafetyException 293 | { 294 | public Z3Body Body { get; private set; } 295 | public Pose Pose { get; private set; } 296 | public PoseSafetyException(string message) : base(message) { } 297 | public PoseSafetyException(string message, Pose pose, Z3Body body) 298 | : base(message) 299 | { 300 | this.Body = body; 301 | this.Pose = pose; 302 | } 303 | 304 | public override string ToString() 305 | { 306 | return string.Format("{0}\n\t{1}", this.Pose, this.Body); 307 | } 308 | } 309 | } 310 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/App.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using PreposeGestures.Parser; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace PreposeGestures 7 | { 8 | /// 9 | /// Representation of the parsed code 10 | /// 11 | public class App 12 | { 13 | public IList Gestures = new List(); 14 | public App(string name) 15 | { 16 | this.Name = name; 17 | } 18 | 19 | public App(string name, IList gestures, int precision = 15) 20 | { 21 | this.Name = name; 22 | this.Gestures = gestures; 23 | } 24 | 25 | public string Name { get; private set; } 26 | 27 | public override string ToString() 28 | { 29 | return string.Format("APP {0} = \n\t{1}", Name, string.Join("\n\n\t", this.Gestures)); 30 | } 31 | 32 | public static App ReadApp(string filename) 33 | { 34 | var input = new Antlr4.Runtime.AntlrFileStream(filename); //"..\\..\\Tests\\simple.app" 35 | //var input = new Antlr4.Runtime.AntlrInputStream(inputString); //"..\\..\\Tests\\simple.app" 36 | var lexer = new PreposeGesturesLexer(input); 37 | var tokens = new CommonTokenStream(lexer); 38 | var parser = new PreposeGesturesParser(tokens); 39 | var tree = parser.app(); // parse 40 | var visitor = new AppConverter(); 41 | var app = (App)visitor.Visit(tree); 42 | 43 | return app; 44 | } 45 | 46 | public static App ReadAppText(string inputString) 47 | { 48 | //var input = new Antlr4.Runtime.AntlrFileStream(filename); //"..\\..\\Tests\\simple.app" 49 | var input = new Antlr4.Runtime.AntlrInputStream(inputString); //"..\\..\\Tests\\simple.app" 50 | var lexer = new PreposeGesturesLexer(input); 51 | var tokens = new CommonTokenStream(lexer); 52 | var parser = new PreposeGesturesParser(tokens); 53 | var tree = parser.app(); // parse 54 | var visitor = new AppConverter(); 55 | var app = (App)visitor.Visit(tree); 56 | 57 | return app; 58 | } 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/ExecutionStep.cs: -------------------------------------------------------------------------------- 1 | namespace PreposeGestures 2 | { 3 | public enum MotionRestriction 4 | { 5 | None = 0, 6 | Slowly = 1, 7 | Rapidly = 2, 8 | } 9 | 10 | public class ExecutionStep 11 | { 12 | public ExecutionStep(MotionRestriction motionRestriction, Pose pose, int holdRestriction) 13 | { 14 | this.MotionRestriction = motionRestriction; 15 | this.Pose = pose; 16 | this.HoldRestriction = holdRestriction; 17 | } 18 | 19 | public ExecutionStep(MotionRestriction motionRestriction, Pose pose) 20 | { 21 | this.MotionRestriction = motionRestriction; 22 | this.Pose = pose; 23 | this.HoldRestriction = -1; 24 | } 25 | 26 | public ExecutionStep(Pose pose, int holdRestriction) 27 | { 28 | this.MotionRestriction = MotionRestriction.None; 29 | this.Pose = pose; 30 | this.HoldRestriction = holdRestriction; 31 | } 32 | 33 | public ExecutionStep(Pose pose) 34 | { 35 | this.MotionRestriction = MotionRestriction.None; 36 | this.Pose = pose; 37 | this.HoldRestriction = -1; 38 | } 39 | 40 | public override string ToString() 41 | { 42 | if (this.MotionRestriction != PreposeGestures.MotionRestriction.None && this.HoldRestriction > 0) 43 | { 44 | return string.Format("{0} {1} and hold for {2} seconds", this.MotionRestriction, this.Pose.Name, this.HoldRestriction); 45 | } 46 | 47 | if (this.MotionRestriction != PreposeGestures.MotionRestriction.None && this.HoldRestriction > 0) 48 | { 49 | return string.Format("{0} {1} and hold for {2} seconds", this.MotionRestriction, this.Pose.Name, this.HoldRestriction); 50 | } 51 | if (this.MotionRestriction != PreposeGestures.MotionRestriction.None) 52 | { 53 | return string.Format("{0} {1}", this.MotionRestriction, this.Pose.Name); 54 | } 55 | if (this.HoldRestriction > 0) 56 | { 57 | return string.Format("{0} and hold for {1} seconds", this.Pose.Name, this.HoldRestriction); 58 | } 59 | 60 | return this.Pose.Name; 61 | } 62 | 63 | public Pose Pose { get; private set; } 64 | public MotionRestriction MotionRestriction { get; private set; } 65 | public int HoldRestriction { get; private set; } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Gestures.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Z3; 2 | using System; 3 | using System.Linq; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | 7 | namespace PreposeGestures 8 | { 9 | public class Gesture 10 | { 11 | public Gesture(string name) 12 | { 13 | this.Name = name; 14 | this.Steps = new List(); 15 | this.DeclaredPoses = new List(); 16 | } 17 | 18 | public void AddPose(Pose pose) 19 | { 20 | this.DeclaredPoses.Add(pose); 21 | } 22 | 23 | public void AddStep(ExecutionStep newStep) 24 | { 25 | this.Steps.Add(newStep); 26 | } 27 | 28 | public void FinalResult(Z3Body input, out Z3Body transformed, out BoolExpr evaluation) 29 | { 30 | transformed = input; 31 | evaluation = Z3Math.True; 32 | 33 | foreach (var step in this.Steps) 34 | { 35 | var pose = step.Pose; 36 | transformed = pose.Transform.Transform(transformed); 37 | evaluation = Z3.Context.MkAnd(evaluation, pose.Restriction.Evaluate(transformed)); 38 | } 39 | } 40 | 41 | public override string ToString() 42 | { 43 | return string.Format("GESTURE {0} = \n\t\t{1}\n\t\tEXECUTION = \n\t\t\t{2}", this.Name, 44 | string.Join("\n\t\t", this.DeclaredPoses), 45 | string.Join("\n\t\t\t", this.Steps)); 46 | } 47 | 48 | 49 | public List Steps { get; private set; } 50 | 51 | public int NegatedRestrictionCount 52 | { 53 | get { return this.DeclaredPoses.Sum(p => p.NegatedRestrictionCount); } 54 | } 55 | public int RestrictionCount 56 | { 57 | get { return this.DeclaredPoses.Sum(p => p.RestrictionCount); } 58 | } 59 | 60 | public int TransformCount 61 | { 62 | get { return this.DeclaredPoses.Sum(p => p.TransformCount); } 63 | } 64 | 65 | public int DistinctTransformedJointsCount 66 | { 67 | get 68 | { 69 | int retval = 0; 70 | 71 | List allJoints = new List(); 72 | foreach (var p in this.DeclaredPoses) 73 | { 74 | foreach (var j in p.GetTransformJointTypes()) 75 | { 76 | allJoints.Add(j); 77 | } 78 | } 79 | var distinctJoints = allJoints.Distinct(); 80 | retval = distinctJoints.Count(); 81 | return retval; 82 | } 83 | } 84 | 85 | public List DeclaredPoses { get; private set; } 86 | 87 | 88 | public string Name { get; set; } 89 | 90 | } 91 | } -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Gestures/Pose.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Z3; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace PreposeGestures 7 | { 8 | public class Pose 9 | { 10 | public Pose(string name) 11 | { 12 | this.Name = name; 13 | this.Transform = new BodyTransform(); 14 | this.Restriction = new CompositeBodyRestriction(); 15 | } 16 | 17 | public Pose(string name, BodyTransform transform) 18 | { 19 | this.Name = name; 20 | this.Transform = transform; 21 | this.Restriction = new CompositeBodyRestriction(new NoBodyRestriction()); 22 | } 23 | 24 | public int DistinctRestrictedJointsCount 25 | { 26 | get 27 | { 28 | int retval = 0; 29 | retval = this.Restriction.DistinctRestrictedJointsCount; 30 | return retval; 31 | } 32 | } 33 | 34 | public int RestrictionCount 35 | { 36 | get 37 | { 38 | return this.Restriction.GetRestrictionCount(); 39 | } 40 | } 41 | 42 | public int NegatedRestrictionCount 43 | { 44 | get 45 | { 46 | return this.Restriction.NumNegatedRestrictions; 47 | } 48 | 49 | } 50 | 51 | public int TransformCount 52 | { 53 | get 54 | { 55 | return this.Transform.TransformCount; 56 | } 57 | } 58 | 59 | public Pose(string name, BodyTransform transform, IBodyRestriction restriction) 60 | { 61 | this.Name = name; 62 | this.Transform = transform; 63 | this.Restriction = (restriction is CompositeBodyRestriction) ? 64 | (CompositeBodyRestriction)restriction : 65 | new CompositeBodyRestriction((SimpleBodyRestriction)restriction); 66 | 67 | // Check if restriction allows transform 68 | if (!this.IsTransformAcceptedByRestriction()) 69 | { 70 | throw new ArgumentException("The restriction does not allow the transform.", "restriction"); 71 | } 72 | } 73 | 74 | public bool IsTransformAcceptedByRestriction() 75 | { 76 | Z3Body body = Z3Body.MkZ3Const(); 77 | Z3Body transformedBody = this.Transform.Transform(body); 78 | BoolExpr expr = this.Restriction.Evaluate(transformedBody); 79 | 80 | SolverCheckResult checkResult = Z3AnalysisInterface.CheckStatus(expr); 81 | 82 | return (checkResult.Status != Status.UNSATISFIABLE); 83 | } 84 | 85 | 86 | 87 | public void Compose(JointType jointType, JointTransform point3DTransform) 88 | { 89 | this.Transform.Compose(jointType, point3DTransform); 90 | } 91 | 92 | public void Compose(BodyTransform newTransform) 93 | { 94 | this.Transform.Compose(newTransform); 95 | } 96 | 97 | public void Compose(IBodyRestriction newRestriction) 98 | { 99 | this.Restriction.And(newRestriction); 100 | } 101 | 102 | public bool IsBodyAccepted( 103 | Z3Body input) 104 | { 105 | bool result = this.Restriction.IsBodyAccepted(input); 106 | return result; 107 | } 108 | 109 | public bool IsTransformedBodyAccepted(Z3Body body) 110 | { 111 | bool result = false; 112 | 113 | Z3Body transformedBody = this.Transform.Transform(body); 114 | result = this.IsBodyAccepted(transformedBody); 115 | 116 | return result; 117 | } 118 | 119 | public Z3Target CalcNearestTargetBody(Z3Body startBody) 120 | { 121 | // Create binary search to look for nearest body 122 | int numSteps = 6; 123 | int angleThreshold = 90; 124 | int angleIncrement = 90; 125 | Z3Target target = null; 126 | for (int i = 0; i < numSteps; ++i) 127 | { 128 | // Ask for a witness which is within the range 129 | target = Z3AnalysisInterface.GenerateTarget( 130 | this.Transform, 131 | this.Restriction, 132 | startBody, 133 | angleThreshold); 134 | 135 | // Update angle threshold 136 | angleIncrement /= 2; 137 | 138 | if (target != null) 139 | { 140 | angleThreshold -= angleIncrement; 141 | } 142 | else 143 | { 144 | angleThreshold += angleIncrement; 145 | } 146 | } 147 | 148 | // If target still null it probably means Z3 was unable to solve the restrictions 149 | // This way we generate a target using onlye the transforms 150 | if(target == null) 151 | { 152 | target = new Z3Target(); 153 | target.Body = this.Transform.Transform(startBody); 154 | target.TransformedJoints = this.Transform.GetJointTypes(); 155 | } 156 | 157 | // If target still null assing a new body as an error proof policy 158 | if(target == null) 159 | { 160 | target = new Z3Target(); 161 | target.Body = startBody; 162 | } 163 | 164 | return target; 165 | } 166 | 167 | public List GetAllJointTypes() 168 | { 169 | return Transform.GetJointTypes().Union(Restriction.GetJointTypes()).ToList(); 170 | } 171 | 172 | public List GetRestrictionJointTypes() 173 | { 174 | return this.Restriction.GetJointTypes(); 175 | } 176 | 177 | public List GetTransformJointTypes() 178 | { 179 | return this.Transform.GetJointTypes(); 180 | } 181 | 182 | internal BodyTransform Transform { get; private set; } 183 | 184 | internal CompositeBodyRestriction Restriction { get; private set; } 185 | public string Name { get; set; } 186 | 187 | public override string ToString() 188 | { 189 | return string.Format("POSE {0} : {1}", this.Name, this.Restriction); 190 | } 191 | 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Parser/PreposeGestures.g4: -------------------------------------------------------------------------------- 1 | grammar PreposeGestures; 2 | 3 | app : 4 | 'APP' ID ':' (gesture '.')+ EOF; 5 | gesture : 6 | 'GESTURE' ID ':' 7 | pose+ // declaring the poses 8 | execution; // defining an order + repeatitions 9 | pose : 10 | 'POSE' ID ':' statement (',' statement)* '.'; 11 | 12 | statement : 13 | transform | restriction; 14 | 15 | transform : 16 | point_to_transform 17 | | rotate_plane_transform 18 | | rotate_direction_transform; 19 | 20 | rotate_plane_transform : 21 | 'rotate' 'your' body_part ((',' 'your'? body_part)* 'and' 'your'? body_part)? NUMBER 'degrees' angular_direction 'on' 'the' ? reference_plane; 22 | 23 | rotate_direction_transform : 24 | 'rotate' 'your' body_part ((',' 'your'? body_part)* 'and' 'your'? body_part)? NUMBER 'degrees' ('to' | 'to' 'your')? direction; 25 | 26 | point_to_transform : 27 | 'point' 'your'? body_part ((',' 'your'? body_part)* 'and' 'your'? body_part)? ('to' | 'to' 'your')? direction; 28 | 29 | body_part : 30 | joint | 31 | arm | 32 | leg | 33 | spine | 34 | back | 35 | arms | 36 | legs | 37 | shoulders | 38 | wrists | 39 | elbows | 40 | hands | 41 | hands_tips | 42 | thumbs | 43 | hips | 44 | knees | 45 | ankles | 46 | feet | 47 | you ; 48 | 49 | arm : side 'arm'; 50 | leg : side 'leg'; 51 | spine : 'spine'; 52 | back : 'back'; 53 | arms : 'arms'; 54 | legs : 'legs'; 55 | shoulders : 'shoulders'; 56 | wrists : 'wrists'; 57 | elbows : 'elbows'; 58 | hands : 'hands'; 59 | hands_tips : 'hands' 'tips'; 60 | thumbs : 'thumbs'; 61 | hips : 'hips'; 62 | knees : 'knees'; 63 | ankles : 'ankles'; 64 | feet : 'feet'; 65 | you : 'you'; 66 | 67 | //arm and leg should be functions that return the 68 | //corresponding set of joints 69 | 70 | joint : 71 | center_joint | 72 | side sided_joint; 73 | 74 | center_joint : 75 | 'neck' | 76 | 'head' | 77 | 'spine' 'mid' | 78 | 'spine' 'base' | 79 | 'spine' 'shoulder'; // todo: add more 80 | 81 | side : 82 | 'left' | 83 | 'right'; 84 | 85 | sided_joint : 86 | 'shoulder' | 87 | 'elbow' | 88 | 'wrist' | 89 | 'hand' | 90 | 'hand' 'tip' | 91 | 'thumb' | 92 | 'hip' | 93 | 'knee' | 94 | 'ankle' | 95 | 'foot'; 96 | 97 | direction : 98 | 'up' 99 | | 'down' 100 | | 'front' 101 | | 'back' 102 | | side; 103 | 104 | angular_direction : 105 | 'clockwise' | 106 | 'counter' 'clockwise'; 107 | 108 | reference_plane : 109 | 'frontal' 'plane' | 110 | 'sagittal' 'plane' | 111 | 'horizontal' 'plane'; 112 | 113 | restriction : 114 | dont? touch_restriction 115 | | dont? put_restriction 116 | | dont? align_restriction; 117 | 118 | dont: 119 | 'don\'t'; 120 | 121 | touch_restriction : 122 | 'touch' 'your'? body_part 'with' 'your'? side 'hand'; 123 | 124 | put_restriction : 125 | 'put' 'your'? body_part ((',' 'your'? body_part)* 'and' 'your'? body_part)? relative_direction body_part; 126 | 127 | align_restriction : 128 | 'align' 'your'? body_part ((',' 'your'? body_part)* 'and' 'your'? body_part)?; 129 | 130 | relative_direction : 131 | 'in' 'front' 'of' 'your' | 132 | 'behind' 'your' | 133 | (('on' 'top' 'of') | 'above') 'your' | 134 | 'below' 'your' | 135 | 'to' 'the' side 'of' 'your'; 136 | 137 | execution : 138 | 'EXECUTION' ':' 139 | ( 140 | repeat 'the' 'following' 'steps' NUMBER execution_step (',' execution_step)* 141 | | execution_step (',' execution_step)* 142 | ); 143 | 144 | execution_step : 145 | motion_constraint? ID ('and' hold_constraint)?; // pose ID 146 | 147 | motion_constraint : 148 | 'slowly' | 'rapidly'; 149 | 150 | hold_constraint : 151 | 'hold' 'for' NUMBER 'seconds'; 152 | 153 | repeat : 154 | 'repeat' NUMBER 'times'; 155 | 156 | NUMBER : DIGIT+; 157 | 158 | DIGIT : '0'..'9'; 159 | 160 | COMMENT : ( 161 | ('#'| '//') ~[\r\n]* '\r'? '\n' 162 | | '/*' .*? '*/' 163 | ) -> skip ; 164 | 165 | ID 166 | : ('a'..'z' | 'A'..'Z' | '_' | '-' | 'a'..'z' | 'A'..'Z' | '$' | DIGIT)+ 167 | ; 168 | 169 | WS 170 | : [ \r\n\t] -> skip 171 | ; 172 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Parser/PreposeParserException.cs: -------------------------------------------------------------------------------- 1 | using Antlr4.Runtime; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace PreposeGestures 9 | { 10 | public class PreposeParserException : Exception 11 | { 12 | private readonly int startLineNumber; 13 | private readonly int startColumnNumber; 14 | 15 | private readonly int endLineNumber; 16 | private readonly int endColumnNumber; 17 | 18 | public int StartLineNumber 19 | { 20 | get { return this.startLineNumber; } 21 | } 22 | 23 | public int StartColumnNumber 24 | { 25 | get { return this.startColumnNumber; } 26 | } 27 | 28 | public int EndLineNumber 29 | { 30 | get { return this.endLineNumber; } 31 | } 32 | 33 | public int EndColumnNumber 34 | { 35 | get { return this.endColumnNumber; } 36 | } 37 | 38 | public PreposeParserException(string message, ParserRuleContext currentContext) 39 | : base(message) 40 | { 41 | this.startLineNumber = currentContext.start.Line; 42 | this.startColumnNumber = currentContext.start.Column; 43 | 44 | this.endLineNumber = currentContext.stop.Line; 45 | this.endColumnNumber = currentContext.stop.Column; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/PreposeGestures.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AEB28AC8-F6AE-4689-89AF-E090B698A7E2} 8 | Exe 9 | Properties 10 | PreposeGestures 11 | PreposeGestures 12 | v4.5 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | dd33cbc6 20 | 21 | 22 | x64 23 | true 24 | full 25 | false 26 | bin\Debug\ 27 | DEBUG;TRACE 28 | prompt 29 | 4 30 | false 31 | 32 | 33 | x64 34 | pdbonly 35 | true 36 | bin\Release\ 37 | TRACE 38 | prompt 39 | 4 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | true 48 | bin\x64\Debug\ 49 | DEBUG;TRACE 50 | full 51 | x64 52 | prompt 53 | MinimumRecommendedRules.ruleset 54 | true 55 | 56 | 57 | bin\x64\Release\ 58 | TRACE 59 | true 60 | pdbonly 61 | x64 62 | prompt 63 | MinimumRecommendedRules.ruleset 64 | 65 | 66 | true 67 | bin\x86\Debug\ 68 | DEBUG;TRACE 69 | full 70 | x86 71 | prompt 72 | MinimumRecommendedRules.ruleset 73 | 74 | 75 | bin\x86\Release\ 76 | TRACE 77 | true 78 | pdbonly 79 | x86 80 | prompt 81 | MinimumRecommendedRules.ruleset 82 | 83 | 84 | 85 | False 86 | ..\..\External\Antlr4.Runtime.v4.5.dll 87 | 88 | 89 | ..\..\External\BigRationalLibrary.dll 90 | 91 | 92 | 93 | False 94 | ..\..\External\x64\Microsoft.Z3.dll 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | MSBuild:Compile 133 | FastGestures.Parser 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | copy "$(SolutionDir)External\x64\libz3.dll" "$(ProjectDir)$(OutDir)libz3.dll" 150 | 151 | 158 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/PreposeGestures.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Z3Gestures")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Z3Gestures")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0eb40c83-8b90-4400-8c06-ce3e0a924679")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Z3Experiments/Z3Experiments/Tests.zip -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests/ballet.app: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // Initial Ballet gestures of the Cecchetti Method 3 | // Gestures described based on the book 4 | // Technical Manual and Dictionary of Classical Ballet 5 | // By Gail Grant 6 | // From Dover Publications 7 | // This particular set can be found in the following picture: 8 | // http://mysylph.files.wordpress.com/2013/05/cecchetti-port-de-bra.jpg 9 | ////////////////////////////////////////////////////////////////////// 10 | 11 | APP ballet: 12 | 13 | GESTURE first-position: 14 | POSE stand-straight: 15 | point your spine, neck and head up. 16 | 17 | POSE point-feet-out: 18 | point your right foot right, 19 | point your left foot left. 20 | 21 | POSE stretch-legs: 22 | align your left leg, 23 | align your right leg. 24 | 25 | //POSE put-ankles-together: 26 | //connect your right ankle to your left ankle. 27 | 28 | POSE low-arc-arms: 29 | point your arms down, 30 | rotate your elbows 15 degrees up, 31 | rotate your left wrist 5 degrees to your right, 32 | rotate your right wrist 5 degrees to your left. 33 | 34 | //POSE first-position-composed: 35 | //stand-straight, 36 | //point-feet-out, 37 | //stretch-legs, 38 | ////put-ankles-together, 39 | //low-arc-arms. 40 | 41 | EXECUTION: 42 | //first-position-composed, 43 | stand-straight, 44 | point-feet-out, 45 | stretch-legs, 46 | //put-ankles-together, 47 | low-arc-arms. 48 | 49 | GESTURE second-position: 50 | POSE mid-arc-arms: 51 | point your arms down, 52 | rotate your elbows 30 degrees up, 53 | rotate your wrists 20 degrees up. 54 | 55 | POSE high-arc-arms: 56 | point your arms down, 57 | rotate your arms 70 degrees up. 58 | 59 | POSE open-legs-frontal-plane: 60 | point your legs down, 61 | rotate your right leg 10 degrees to right, 62 | rotate your left leg 10 degrees to left. 63 | 64 | //POSE second-position-initial: 65 | //compose 66 | //stand-straight, 67 | //point-feet-out, 68 | //stretch-legs, 69 | //open-legs-frontal-plane, 70 | //mid-arc-arms. 71 | 72 | EXECUTION: 73 | //second-position-initial 74 | stand-straight, 75 | point-feet-out, 76 | stretch-legs, 77 | open-legs-frontal-plane, 78 | mid-arc-arms, 79 | high-arc-arms. 80 | 81 | GESTURE third-position: 82 | //POSE pair-ankles-one-behind-the-other: 83 | //put your left ankle behind your right ankle, 84 | //connect your ankles. 85 | 86 | POSE mid-arc-arms-to-right: 87 | point your arms down, 88 | rotate your right elbow 30 degrees up, 89 | rotate your right wrist 20 degrees up, 90 | rotate your left elbow 10 degrees to your left, 91 | rotate your left wrist 10 degrees to your right. 92 | 93 | //POSE third-position-composed: 94 | //compose 95 | //stand-straight, 96 | //point-feet-out, 97 | //stretch-legs, 98 | ////pair-ankles-one-behind-the-other, 99 | //mid-arc-arms-to-right. 100 | 101 | EXECUTION: 102 | //third-position-composed 103 | stand-straight, 104 | point-feet-out, 105 | stretch-legs, 106 | //pair-ankles-one-behind-the-other, 107 | mid-arc-arms-to-right. 108 | 109 | GESTURE fourth-position-en-avant: 110 | POSE cross-legs-one-behind-the-other: 111 | put your left ankle behind your right ankle, 112 | put your left ankle to the right of your right ankle. 113 | //don't connect your ankles. 114 | 115 | POSE high-arc-arms-to-right: 116 | point your arms down, 117 | rotate your right arm 70 degrees up, 118 | rotate your left elbow 20 degrees to your left, 119 | rotate your left wrist 25 degrees to your right. 120 | 121 | //POSE fourth-position-en-avant-composed: 122 | //compose 123 | //stand-straight, 124 | //point-feet-out, 125 | //stretch-legs, 126 | //cross-legs-one-behind-the-other, 127 | //high-arc-arms-to-right. 128 | 129 | EXECUTION: 130 | //fourth-position-en-avant-composed 131 | stand-straight, 132 | point-feet-out, 133 | stretch-legs, 134 | cross-legs-one-behind-the-other, 135 | high-arc-arms-to-right. 136 | 137 | GESTURE fourth-position-en-haunt: 138 | POSE high-arc-arms-to-right-and-up: 139 | point your right arm down, 140 | rotate your right arm 70 degrees up, 141 | point your left arm up, 142 | rotate your left elbow 15 degrees to your left, 143 | rotate your left wrist 5 degrees to your right. 144 | 145 | //POSE fourth-position-en-haunt-composed: 146 | //compose 147 | //stand-straight, 148 | //point-feet-out, 149 | //stretch-legs, 150 | //cross-legs-one-behind-the-other, 151 | //high-arc-arms-to-right-and-up. 152 | 153 | EXECUTION: 154 | //fourth-position-composed 155 | stand-straight, 156 | point-feet-out, 157 | stretch-legs, 158 | cross-legs-one-behind-the-other, 159 | high-arc-arms-to-right-and-up. 160 | 161 | GESTURE fifth-position-en-avant: 162 | //POSE cross-ankles: 163 | //put your left ankle behind your right ankle, 164 | //put your left ankle to the right of your right ankle, 165 | //connect your left ankle with your right foot, 166 | //connect your right ankle with your left foot. 167 | 168 | POSE inner-arc-arms: 169 | point your arms down, 170 | rotate your right elbow 20 degrees to your right, 171 | rotate your right wrist 25 degrees to your left, 172 | rotate your left elbow 20 degrees to your left, 173 | rotate your left wrist 25 degrees to your right. 174 | 175 | //POSE fifth-position-en-avant-composed: 176 | //compose 177 | //stand-straight, 178 | //point-feet-out, 179 | //stretch-legs, 180 | ////cross-ankles, 181 | //inner-arc-arms. 182 | 183 | EXECUTION: 184 | //fifth-position-en-avant-composed 185 | stand-straight, 186 | point-feet-out, 187 | stretch-legs, 188 | //cross-ankles, 189 | inner-arc-arms. 190 | 191 | // Grammar does not allows yet to have gestures with no declared poses 192 | //GESTURE fifth-position-en-bas: 193 | // //POSE fifth-position-en-bas-composed: 194 | // //compose 195 | // //stand-straight, 196 | // //point-feet-out, 197 | // //stretch-legs, 198 | // ////cross-ankles, 199 | // //low-arc-arms. 200 | // 201 | // EXECUTION: 202 | // //fifth-position-en-bas-composed 203 | // stand-straight, 204 | // point-feet-out, 205 | // stretch-legs, 206 | // //cross-ankles, 207 | // low-arc-arms. 208 | 209 | GESTURE fifth-position-en-haunt: 210 | POSE arc-arms-up: 211 | point your arms up, 212 | rotate your right elbow 15 degrees to your right, 213 | rotate your right wrist 5 degrees to your left, 214 | rotate your left elbow 15 degrees to your left, 215 | rotate your left wrist 5 degrees to your right. 216 | 217 | //POSE fifth-position-en-haunt-composed: 218 | //compose 219 | //stand-straight, 220 | //point-feet-out, 221 | //stretch-legs, 222 | ////cross-ankles, 223 | //arc-arms-up. 224 | 225 | EXECUTION: 226 | //fifth-position-en-haunt-composed 227 | stand-straight, 228 | point-feet-out, 229 | stretch-legs, 230 | //cross-ankles, 231 | arc-arms-up. 232 | 233 | GESTURE a-la-quatrieme-devant: 234 | POSE quatrieme-devant-legs: 235 | put your right leg in front of your left leg, 236 | //align your right leg and your right foot, 237 | point your left leg down, 238 | point your left foot left. 239 | 240 | EXECUTION: 241 | stand-straight, 242 | point-feet-out, 243 | quatrieme-devant-legs, 244 | high-arc-arms. 245 | 246 | GESTURE a-la-quatrieme-derriere: 247 | POSE quatrieme-derriere-legs: 248 | put your right leg behind your left leg, 249 | //align your right leg and your right foot, 250 | point your left leg down, 251 | point your left foot left. 252 | 253 | EXECUTION: 254 | stand-straight, 255 | point-feet-out, 256 | quatrieme-derriere-legs, 257 | high-arc-arms. 258 | 259 | GESTURE a-la-seconde: 260 | POSE seconde-legs: 261 | point your legs down, 262 | point your left foot left, 263 | rotate your right leg 20 degrees to your right. 264 | //align your right leg and your right foot. 265 | 266 | EXECUTION: 267 | stand-straight, 268 | point-feet-out, 269 | seconde-legs, 270 | high-arc-arms. -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests/simple.app: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // hello world with the punch gesture 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | APP simple: 6 | GESTURE generic-left-punch : 7 | POSE prepare-punch : 8 | put your left elbow behind your neck. 9 | 10 | POSE execute-left-punch : 11 | put your left elbow in front of your neck. 12 | 13 | EXECUTION : 14 | prepare-punch, 15 | rapidly execute-left-punch. 16 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests/soccer.app: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // Two common crowd gestures in soccer stadiums 3 | // Ola and Uuuuh 4 | ////////////////////////////////////////////////////////////////////// 5 | 6 | APP soccer: 7 | 8 | // so let's create a gesture 9 | GESTURE ola: 10 | 11 | // which is composed by poses 12 | POSE wrists_down: 13 | 14 | // point transforms and body parts 15 | point your left wrist down, 16 | point your right wrist down, 17 | 18 | // pointing down is not natural, rotation needed 19 | rotate your left wrist 30 degrees to your front, 20 | rotate your right wrist 30 degrees to your front, 21 | 22 | point your head up, 23 | 24 | // polish the gesture 25 | rotate your head 20 degrees to your front. 26 | 27 | POSE ola_middle: 28 | // groups of body parts 29 | point your wrists to your front. 30 | 31 | POSE wrists_up: 32 | //put your hands above your head. 33 | point your wrists up, 34 | point your head up. 35 | 36 | // let's test it 37 | // feedback, lines and bars 38 | EXECUTION: 39 | wrists_down, 40 | 41 | // we need more steps 42 | ola_middle, 43 | wrists_up, 44 | 45 | // complete the execution 46 | ola_middle, 47 | wrists_down. 48 | 49 | // more gestures 50 | GESTURE uuuuuh: 51 | 52 | // another pose more complex with chained rotations 53 | POSE uuuuuh_hands_on_head: 54 | //point your elbows to your front, 55 | //rotate your left elbow 45 degrees to your left, 56 | //rotate your right elbow 45 degrees to your right, 57 | //point your wrists up, 58 | //rotate your wrists 30 degrees to your back, 59 | //rotate your left wrist 30 degrees to your right, 60 | //rotate your right wrist 30 degrees to your left. 61 | // better coded with restrictions (relations) 62 | //put your hands above your head. 63 | touch your head with your right hand, 64 | touch your head with your left hand. 65 | 66 | EXECUTION: 67 | // reusing previous pose 68 | wrists_down, 69 | uuuuuh_hands_on_head. 70 | 71 | 72 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests/test.app: -------------------------------------------------------------------------------- 1 | // this takes too long to synthesize the next 2 | // pose and needs debugging with Z3 3 | APP sample-gesture-app: 4 | GESTURE sample-gesture: 5 | POSE handoh: 6 | put your right hand above your head. 7 | 8 | POSE righthf: 9 | put your right wrist in front of your left wrist. 10 | 11 | POSE lefthf: 12 | put your left wrist in front of your right wrist. 13 | 14 | EXECUTION: 15 | handoh, 16 | righthf, 17 | lefthf, 18 | righthf, 19 | lefthf, 20 | righthf, 21 | lefthf, 22 | righthf, 23 | lefthf, 24 | righthf, 25 | lefthf, 26 | righthf, 27 | lefthf, 28 | righthf, 29 | lefthf. 30 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/Tests/therapy.app: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////// 2 | // Gestures described based on conditioning programs 3 | // providade by American Acadmey of Orthipaedic Surgeons (AAOS) 4 | // http://orthoinfo.aaos.org/topic.cfm?topic=A00672 5 | ////////////////////////////////////////////////////////////////////// 6 | 7 | 8 | APP therapy: 9 | 10 | // for this gesture the user needs to have a support table 11 | // placing the other hand over the table to help the balance 12 | GESTURE pendulum: 13 | POSE stand-straight: 14 | point your spine, neck and head up. 15 | 16 | POSE lean-forward: 17 | rotate your spine, neck and head 30 degrees to your front, 18 | don't align your legs, 19 | align your back. 20 | 21 | POSE swing-forward: 22 | point your left arm down, 23 | rotate your left arm 30 degrees to your front. 24 | 25 | POSE swing-back: 26 | point your left arm down, 27 | rotate your left arm 30 degrees to your back. 28 | 29 | POSE swing-left: 30 | point your left arm down, 31 | rotate your left arm 30 degrees to your left. 32 | 33 | POSE swing-right: 34 | point your left arm down, 35 | rotate your left arm 30 degrees to your right. 36 | 37 | EXECUTION: 38 | stand-straight, 39 | lean-forward, 40 | slowly swing-forward, 41 | slowly swing-back, 42 | slowly swing-left, 43 | slowly swing-right, 44 | slowly swing-forward, 45 | slowly swing-left, 46 | slowly swing-back, 47 | slowly swing-right. 48 | 49 | GESTURE crossover-left-arm-stretch: 50 | POSE relax-arms: 51 | point your left arm down, 52 | point your right arm down. 53 | 54 | POSE stretch: 55 | rotate your left arm 90 degrees counter clockwise on the frontal plane, 56 | touch your left elbow with your right hand. 57 | 58 | EXECUTION: 59 | relax-arms, 60 | slowly stretch and hold for 30 seconds. 61 | 62 | GESTURE crossover-right-arm-stretch: 63 | POSE stretch-reverse: 64 | rotate your right arm 90 degrees counter clockwise on the frontal plane, 65 | touch your right elbow with your left hand. 66 | 67 | EXECUTION: 68 | relax-arms, 69 | slowly stretch-reverse and hold for 30 seconds. 70 | 71 | //GESTURE = MIRROR crossover-left-arm-stretch; 72 | 73 | GESTURE passive-external-rotation: 74 | POSE left-wrist-to-the-left: 75 | point your elbows down, 76 | point your wrists to your front, 77 | rotate your left wrist 45 degrees counter clockwise on the horizontal plane. 78 | 79 | POSE right-wrist-to-the-right: 80 | point your elbows down, 81 | point your wrists to your front, 82 | rotate your right wrist 45 degrees counter clockwise on the horizontal plane. 83 | 84 | EXECUTION: 85 | left-wrist-to-the-left and hold for 30 seconds, 86 | right-wrist-to-the-right and hold for 30 seconds, 87 | left-wrist-to-the-left and hold for 30 seconds, 88 | right-wrist-to-the-right and hold for 30 seconds. 89 | 90 | GESTURE elbows-flexion: 91 | POSE flex-left-elbow: 92 | rotate your left wrist 180 degrees clockwise on the sagittal plane, 93 | point your left elbow down. 94 | 95 | POSE flex-right-elbow : 96 | rotate your right wrist 180 degrees clockwise on the sagittal plane, 97 | point your right elbow down. 98 | 99 | EXECUTION: 100 | relax-arms, 101 | slowly flex-left-elbow and hold for 2 seconds, 102 | relax-arms, 103 | slowly flex-right-elbow and hold for 2 seconds. 104 | 105 | GESTURE elbows-extension: 106 | POSE stretch-arm-up: 107 | point your left elbow up, 108 | point your right arm up, 109 | touch your right elbow with your left hand, 110 | align your spine. 111 | 112 | POSE flex-arm-back: 113 | point your elbows up, 114 | point your right wrist back, 115 | touch your right elbow with your left hand, 116 | align your spine. 117 | 118 | EXECUTION: 119 | stand-straight, 120 | flex-arm-back, 121 | slowly stretch-arm-up and hold for 2 seconds, 122 | slowly flex-arm-back. 123 | 124 | GESTURE head-rolls: 125 | POSE head-to-left: 126 | point your head up, 127 | rotate your head 20 degrees clockwise on the frontal plane. 128 | 129 | POSE head-to-right: 130 | point your head up, 131 | rotate your head 20 degrees counter clockwise on the frontal plane. 132 | 133 | POSE head-to-front: 134 | point your head up, 135 | rotate your head 20 degrees clockwise on the sagittal plane. 136 | 137 | POSE head-to-back : 138 | point your head up, 139 | rotate your head 20 degrees counter clockwise on the sagittal plane. 140 | 141 | EXECUTION : 142 | head-to-front, 143 | head-to-right and hold for 5 seconds, 144 | head-to-front, 145 | slowly head-to-left and hold for 5 seconds, 146 | slowly head-to-back, 147 | slowly head-to-right, 148 | slowly head-to-front, 149 | slowly head-to-left, 150 | slowly head-to-back, 151 | slowly head-to-right, 152 | slowly head-to-front, 153 | slowly head-to-left. 154 | 155 | GESTURE standing-quadriceps-stretch: 156 | POSE lift-ankle: 157 | point your legs down, 158 | rotate your right ankle 90 degrees to your back, 159 | align your spine. 160 | 161 | POSE catch-ankle: 162 | touch your right ankle with your right hand, 163 | align your spine. 164 | 165 | POSE bend-leg: 166 | touch your right ankle with your right hand, 167 | rotate your right ankle 15 degrees to up, 168 | align your spine. 169 | 170 | EXECUTION: 171 | stand-straight, 172 | lift-ankle, 173 | catch-ankle, 174 | slowly bend-leg and hold for 30 seconds. 175 | 176 | GESTURE half-squats: 177 | POSE up-squat: 178 | point your legs down, 179 | point your arms to your front, 180 | point your spine up. 181 | 182 | POSE down-squat: 183 | point your arms to your front, 184 | rotate your knees 20 degrees to up, 185 | point your spine up. 186 | 187 | EXECUTION: 188 | up-squat, 189 | down-squat and hold for 5 seconds, 190 | up-squat, 191 | down-squat and hold for 5 seconds. 192 | 193 | GESTURE shoulder-abduction: 194 | POSE arm-down: 195 | point your right arm down, 196 | rotate your right arm 20 degrees to your right. 197 | 198 | // poses as pure transformations from previous state 199 | POSE rot-up: 200 | rotate your right arm 20 degrees up. 201 | 202 | POSE rot-down: 203 | rotate your right arm 20 degrees down. 204 | 205 | EXECUTION: 206 | arm-down, 207 | //using repetitions to get further 208 | rot-up, 209 | rot-up, 210 | rot-up, 211 | rot-up, 212 | rot-up, 213 | rot-down, 214 | rot-down, 215 | rot-down, 216 | rot-down, 217 | rot-down. 218 | 219 | GESTURE shoulder-adduction: 220 | POSE arm-down-add: 221 | point your right arm down, 222 | rotate your right arm 30 degrees to your front. 223 | 224 | EXECUTION: 225 | arm-down, 226 | //using repetitions to get further 227 | rot-up, 228 | rot-up, 229 | rot-up, 230 | rot-up, 231 | rot-up, 232 | rot-down, 233 | rot-down, 234 | rot-down, 235 | rot-down, 236 | rot-down. 237 | 238 | //GESTURE standing-iliotibial-band-stretch: 239 | // POSE cross-legs: 240 | // point your right leg down, 241 | // put your left foot behind your right foot, 242 | // put your left foot to the right of your right foot. 243 | // 244 | // EXECUTION: 245 | // stand-straight, 246 | // cross-legs and hold for 30 seconds. 247 | 248 | // ((half-squats x 3) | standing-quadriceps-stretch ) x 20 249 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/TupleTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | 9 | namespace Z3Experiments 10 | { 11 | [TestMethod] 12 | public void TestBitVectorOps() 13 | { 14 | Context z3 = new Context(); 15 | var bv16 = z3.MkBitVecSort(16); 16 | var c = (BitVecExpr)z3.MkConst("c",bv16); 17 | var _3 = (BitVecExpr)z3.MkNumeral(3, bv16); 18 | var _7 = (BitVecExpr)z3.MkNumeral(7, bv16); 19 | var _1 = (BitVecExpr)z3.MkNumeral(1, bv16); 20 | var c_and_7 = z3.MkBVAND(c, _7); 21 | //((1 + (c & 7)) & 3) 22 | var t = z3.MkBVAND(z3.MkBVAdd(_1, c_and_7), _3); 23 | var s = t.Simplify(); //comes out as: (1 + (c & 3)) 24 | var t_neq_s = z3.MkNot(z3.MkEq(t, s)); 25 | var solv =z3.MkSolver(); 26 | solv.Assert(t_neq_s); 27 | Assert.AreEqual(Status.UNSATISFIABLE, solv.Check()); 28 | } 29 | 30 | [TestMethod] 31 | public void TupleTest() 32 | { 33 | Z3Provider z3p = new Z3Provider(); 34 | //create the tuple sort for mouth 35 | FuncDecl mouth; 36 | FuncDecl[] mouth_accessors; 37 | var MOUTH = z3p.MkTupleSort("MOUTH", new string[] { "open", "teeth" }, new Sort[] { z3p.BoolSort, z3p.IntSort }, out mouth, out mouth_accessors); 38 | Func mk_mouth = ((o,t) => z3p.MkApp(mouth, o, t)); 39 | Func get_open = (m => z3p.MkApp(mouth_accessors[0], m)); 40 | Func get_teeth = (m => z3p.MkApp(mouth_accessors[1], m)); 41 | //create the tuple sort for nose 42 | FuncDecl nose; 43 | FuncDecl[] nose_accessors; 44 | var NOSE = z3p.MkTupleSort("NOSE", new string[] { "size" }, new Sort[] { z3p.IntSort }, out nose, out nose_accessors); 45 | Func mk_nose = (s => z3p.MkApp(nose, s)); 46 | Func get_size = (n => z3p.MkApp(nose_accessors[0], n)); 47 | //create the tuple sort for head 48 | FuncDecl head; 49 | FuncDecl[] head_accessors; 50 | var HEAD = z3p.MkTupleSort("HEAD", new string[] { "bald", "nose", "mouth" }, new Sort[] { z3p.BoolSort, NOSE, MOUTH }, out head, out head_accessors); 51 | Func mk_head = ((b,n,m) => z3p.MkApp(head, b,n,m)); 52 | Func get_bald = (h => z3p.MkApp(head_accessors[0], h)); 53 | Func get_nose = (h => z3p.MkApp(head_accessors[1], h)); 54 | Func get_mouth = (h => z3p.MkApp(head_accessors[2], h)); 55 | //------------------------ 56 | // create a transformation "punch" from HEAD tp HEAD that removes k teeth, k is the second parameter of the transformation 57 | var punch = z3p.MkFuncDecl("punch", new Sort[]{HEAD, z3p.IntSort}, HEAD); 58 | var x = z3p.MkBound(0, HEAD); // <-- bound variable with deBrujn index 0, this is the input HEAD 59 | var y = z3p.MkBound(1, z3p.IntSort); // <-- bound variable with deBrujn index 1, this is the n parameter 60 | //this is the actual transformation of x that removes one tooth 61 | var new_mouth = mk_mouth(get_open(get_mouth(x)), z3p.MkSub(get_teeth(get_mouth(x)), y)); 62 | var old_nose = get_nose(x); 63 | var old_bald = get_bald(x); 64 | var punch_def = mk_head(old_bald, old_nose,new_mouth); 65 | var punch_axiom = z3p.MkEqForall(z3p.MkApp(punch, x , y), punch_def, x, y); 66 | Func punch_app = ((h,k) => z3p.MkApp(punch, h,k)); 67 | z3p.AssertCnstr(punch_axiom); 68 | //------------------------ 69 | // create a transformation "hit" from HEAD tp HEAD that doubles the size of the nose 70 | var hit = z3p.MkFuncDecl("hit", HEAD, HEAD); 71 | var hit_def = mk_head(get_bald(x), mk_nose(z3p.MkMul(z3p.MkInt(2),get_size(get_nose(x)))), get_mouth(x)); 72 | var hit_axiom = z3p.MkEqForall(z3p.MkApp(hit, x), hit_def, x); 73 | Func hit_app = (h => z3p.MkApp(hit, h)); 74 | z3p.AssertCnstr(hit_axiom); 75 | //------------------------------- 76 | // Analysis 77 | var H = z3p.MkConst("H", HEAD); 78 | var N = z3p.MkConst("N", z3p.IntSort); 79 | // check that hit and punch commute 80 | z3p.Push(); 81 | z3p.AssertCnstr(z3p.MkNeq(punch_app(hit_app(H), N), hit_app(punch_app(H, N)))); 82 | Status status = z3p.Check(); //here status must be UNSATISFIABLE 83 | z3p.Pop(); //remove the temporary context 84 | //check that hit is not idempotent 85 | z3p.Push(); 86 | z3p.AssertCnstr(z3p.MkNeq(hit_app(hit_app(H)), hit_app(H))); 87 | status = z3p.Check(); //here status must not be UNSATISFIABLE (it is UNKNOWN due to use of axioms) 88 | var model1 = z3p.Z3S.Model; 89 | var witness1 = model1.Evaluate(H, true); //a concrete instance of HEAD that shows when hitting twice is not the same as hitting once 90 | z3p.Pop(); 91 | //but it is possible that hitting twice does no harm (when nose has size 0) 92 | z3p.Push(); 93 | z3p.AssertCnstr(z3p.MkEq(hit_app(hit_app(H)), hit_app(H))); 94 | status = z3p.Check(); 95 | var model2 = z3p.Z3S.Model; 96 | var witness2 = model2.Evaluate(H, true); 97 | z3p.Pop(); 98 | } 99 | } 100 | 101 | 102 | public class MyExpr 103 | { 104 | public Expr expr; 105 | Context z3; 106 | 107 | public MyExpr(Expr expr, Context z3) 108 | { 109 | this.z3 = z3; 110 | this.expr = expr; 111 | } 112 | 113 | public static MyExpr operator +(MyExpr expr1, MyExpr expr2) 114 | { 115 | if (expr1.z3 != expr2.z3) 116 | throw new Exception("Context mismatch"); 117 | if (expr1.expr.Sort.Equals(expr2.expr.Sort)) 118 | throw new Exception("Sort mismatch"); 119 | var sort = expr1.expr.Sort; 120 | var z3 = expr1.z3; 121 | if (sort.SortKind == Z3_sort_kind.Z3_INT_SORT || sort.SortKind == Z3_sort_kind.Z3_REAL_SORT) 122 | { 123 | if (!(expr1.expr is ArithExpr)) 124 | throw new Exception("Not arithmetic expression"); 125 | if (!(expr2.expr is ArithExpr)) 126 | throw new Exception("Not arithmetic expression"); 127 | return new MyExpr(z3.MkAdd((ArithExpr)expr1.expr, (ArithExpr)expr2.expr), z3); 128 | } 129 | if (sort.SortKind == Z3_sort_kind.Z3_BV_SORT) 130 | { 131 | if (!(expr1.expr is BitVecExpr)) 132 | throw new Exception("Not bitvector expression"); 133 | if (!(expr1.expr is BitVecExpr)) 134 | throw new Exception("Not bitvector expression"); 135 | return new MyExpr(z3.MkBVAdd((BitVecExpr)expr1.expr, (BitVecExpr)expr2.expr), z3); 136 | } 137 | throw new NotImplementedException("operator '+' is not implemented for " + sort.ToString()); 138 | } 139 | 140 | public static MyExpr operator <(MyExpr expr1, MyExpr expr2) 141 | { 142 | if (expr1.z3 != expr2.z3) 143 | throw new Exception("Context mismatch"); 144 | if (expr1.expr.Sort.Equals(expr2.expr.Sort)) 145 | throw new Exception("Sort mismatch"); 146 | var sort = expr1.expr.Sort; 147 | var z3 = expr1.z3; 148 | if (sort.SortKind == Z3_sort_kind.Z3_INT_SORT || sort.SortKind == Z3_sort_kind.Z3_REAL_SORT) 149 | { 150 | if (!(expr1.expr is ArithExpr)) 151 | throw new Exception("Not arithmetic expression"); 152 | if (!(expr2.expr is ArithExpr)) 153 | throw new Exception("Not arithmetic expression"); 154 | return new MyExpr(z3.MkLt((ArithExpr)expr1.expr, (ArithExpr)expr2.expr), z3); 155 | } 156 | if (sort.SortKind == Z3_sort_kind.Z3_BV_SORT) 157 | { 158 | if (!(expr1.expr is BitVecExpr)) 159 | throw new Exception("Not bitvector expression"); 160 | if (!(expr1.expr is BitVecExpr)) 161 | throw new Exception("Not bitvector expression"); 162 | return new MyExpr(z3.MkBVSLT((BitVecExpr)expr1.expr, (BitVecExpr)expr2.expr), z3); 163 | } 164 | throw new NotImplementedException("operator '<' is not implemented for " + sort.ToString()); 165 | } 166 | } 167 | 168 | public class Head 169 | { 170 | Z3Provider z3p; 171 | TupleSort HEAD; 172 | TupleSort MOUTH; 173 | TupleSort NOSE; 174 | Expr head; 175 | 176 | Expr bald; 177 | Mouth mouth; 178 | Nose nose; 179 | 180 | public Head(Z3Provider z3p, Expr head, TupleSort HEAD, TupleSort MOUTH, TupleSort NOSE) 181 | { 182 | if (!(head.Sort.Equals(HEAD))) 183 | throw new Exception("Wrong sort"); 184 | 185 | this.z3p = z3p; 186 | 187 | this.head = head; 188 | this.HEAD = HEAD; 189 | this.MOUTH = MOUTH; 190 | this.NOSE = NOSE; 191 | } 192 | 193 | public Expr Expr { 194 | get {return head;} 195 | } 196 | 197 | public Expr Bald 198 | { 199 | get 200 | { 201 | return z3p.MkApp(HEAD.FieldDecls[0],head); 202 | } 203 | } 204 | 205 | public Mouth Mouth 206 | { 207 | } 208 | 209 | } 210 | 211 | public class Mouth 212 | { 213 | public bool open; 214 | public int teeth; 215 | } 216 | 217 | public class Nose 218 | { 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /Z3Experiments/Z3Experiments/build.bat: -------------------------------------------------------------------------------- 1 | REM this is for building the C# files from the ANTLR4 .g4 file called PreposeGestures.g4 2 | 3 | @echo off 4 | 5 | REM create absolute classpath 6 | SET oldClasspath=%CLASSPATH% 7 | SET AROS_BASE=D:\work\SurroundWeb\private\AROS\GestureRecognizerKinectV2\ 8 | REM F:\MSRWorkspaces\XCGExp\AR_Authoring\private\AROS\GestureRecognizerKinectV2 9 | SET cp=%AROS_BASE%\External\antlr4-csharp-4.2.2-SNAPSHOT-complete.jar 10 | REM SET cp=%AROS_BASE%\External\antlr4-csharp-4.2.2-SNAPSHOT-complete.jar 11 | SET CLASSPATH=.;%cp%;%CLASSPATH% 12 | 13 | echo Generating C# Parser in Parser... 14 | 15 | java org.antlr.v4.Tool -o Parser -Dlanguage=CSharp_v4_5 -visitor -package PreposeGestures %AROS_BASE%\Z3Experiments\Z3Experiments\Parser\PreposeGestures.g4 16 | 17 | SET CLASSPATH=%oldClasspath% -------------------------------------------------------------------------------- /Z3GestureRecognizer/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/App.xaml.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | namespace BodyBasicsWPF 8 | { 9 | using System; 10 | using System.Windows; 11 | 12 | /// 13 | /// Interaction logic for App 14 | /// 15 | public partial class App : Application 16 | { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/BodyMatching.cs: -------------------------------------------------------------------------------- 1 | using PreposeGestures; 2 | using System.Collections.Generic; 3 | 4 | namespace PreposeGestureRecognizer 5 | { 6 | internal class BodyMatching 7 | { 8 | 9 | 10 | /// 11 | /// Matches a Kinect body to a set of gestures within the app. 12 | /// 13 | /// Body representation 14 | /// synthesizes a new body in correct position if true 15 | /// 16 | public static List TestBody(BodyMatcher matcher, 17 | IReadOnlyDictionary kinectJoints, 19 | bool jumpToNextPose = false) 20 | { 21 | // convert Kinect.Body to Z3Body 22 | var body = new Z3Body(); 23 | if (!jumpToNextPose) 24 | { 25 | body = Z3KinectConverter.CreateZ3Body(kinectJoints); 26 | } 27 | else 28 | { 29 | //body = GetCopiedBodyValues(this.Gestures[this.GetMostAdvancedGesturesIDs()[0]].GetTarget().Body); 30 | var firstGestureBody = matcher.GetLastGestureTarget().Body; 31 | body = new Z3Body(firstGestureBody); 32 | } 33 | 34 | return matcher.TestBody(body); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/CustomHighlighting.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | " 13 | " 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | point 23 | rotate 24 | 25 | 26 | 27 | 28 | 29 | put 30 | touch 31 | align 32 | don't 33 | 34 | 35 | 36 | 37 | 38 | your neck 39 | your head 40 | your spine mid 41 | your spine base 42 | your spine shoulder 43 | your left shoulder 44 | your left elbow 45 | your left wrist 46 | your left hand 47 | your left hand tip 48 | your left thumb 49 | your left hip 50 | your left knee 51 | your left ankle 52 | your left foot 53 | your right shoulder 54 | your right elbow 55 | your right wrist 56 | your right hand 57 | your right hand tip 58 | your right thumb 59 | your right hip 60 | your right knee 61 | your right ankle 62 | your right foot 63 | your left arm 64 | your left leg 65 | your right arm 66 | your right leg 67 | your spine 68 | your back 69 | your arms 70 | your legs 71 | your shoulders 72 | your wrists 73 | your elbows 74 | your hands 75 | your hands tips 76 | your thumbs 77 | your hips 78 | your knees 79 | your ankles 80 | your feet 81 | you 82 | 83 | 84 | 85 | 86 | up 87 | down 88 | to your front 89 | to your back 90 | to your left 91 | to your right 92 | in front of 93 | behind 94 | above 95 | on top of 96 | below 97 | to the left of 98 | to the right of 99 | 100 | 101 | 102 | 103 | POSE 104 | EXECUTION 105 | GESTURE 106 | APP 107 | 108 | 109 | 110 | 111 | degrees 112 | 113 | 114 | 115 | AvalonEdit 116 | 117 | 118 | 119 | 120 | \b0[xX][0-9a-fA-F]+ # hex number 121 | | \b 122 | ( \d+(\.[0-9]+)? #number with optional floating point 123 | | \.[0-9]+ #or just starting with floating point 124 | ) 125 | ([eE][+-]?[0-9]+)? # optional exponent 126 | 127 | 128 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Images/Kinect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Z3GestureRecognizer/Images/Kinect.ico -------------------------------------------------------------------------------- /Z3GestureRecognizer/Images/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Z3GestureRecognizer/Images/Logo.png -------------------------------------------------------------------------------- /Z3GestureRecognizer/Images/Status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/Z3GestureRecognizer/Images/Status.png -------------------------------------------------------------------------------- /Z3GestureRecognizer/PreposeGestureRecognizer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CFA1F5A7-05D6-4E9D-9313-0617185F14FB} 8 | WinExe 9 | Properties 10 | PreposeGestureRecognizer 11 | PreposeGestureRecognizer 12 | v4.5 13 | 512 14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15 | 4 16 | SAK 17 | SAK 18 | SAK 19 | SAK 20 | 21 | 22 | true 23 | DEBUG;TRACE 24 | full 25 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 26 | x64 27 | prompt 28 | MinimumRecommendedRules.ruleset 29 | true 30 | 31 | 32 | TRACE 33 | true 34 | pdbonly 35 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 36 | x64 37 | prompt 38 | MinimumRecommendedRules.ruleset 39 | true 40 | 41 | 42 | PreposeGestureRecognizer.App 43 | 44 | 45 | Images\Kinect.ico 46 | 47 | 48 | OnBuildSuccess 49 | 50 | 51 | 52 | ..\External\BigRationalLibrary.dll 53 | 54 | 55 | False 56 | ..\External\ICSharpCode.AvalonEdit.dll 57 | 58 | 59 | False 60 | ..\External\x64\Microsoft.Kinect.dll 61 | 62 | 63 | False 64 | ..\External\x64\Microsoft.Z3.dll 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 4.0 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | MSBuild:Compile 84 | Designer 85 | 86 | 87 | 88 | 89 | 90 | MSBuild:Compile 91 | Designer 92 | 93 | 94 | App.xaml 95 | 96 | 97 | MainWindow.xaml 98 | Code 99 | 100 | 101 | 102 | 103 | Code 104 | 105 | 106 | True 107 | True 108 | Resources.resx 109 | 110 | 111 | True 112 | Settings.settings 113 | True 114 | 115 | 116 | ResXFileCodeGenerator 117 | Resources.Designer.cs 118 | Designer 119 | 120 | 121 | 122 | SettingsSingleFileGenerator 123 | Settings.Designer.cs 124 | 125 | 126 | 127 | 128 | 129 | Designer 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | {aeb28ac8-f6ae-4689-89af-e090b698a7e2} 140 | PreposeGestures 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | copy "$(SolutionDir)External\x64\libz3.dll" "$(OutDir)libz3.dll" 149 | copy "$(SolutionDir)External\x64\Kinect20.dll" "$(OutDir)Kinect20.dll" 150 | 151 | 158 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/PreposeGestureRecognizer.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/PreposeSyntaxCompletionData.cs: -------------------------------------------------------------------------------- 1 | using ICSharpCode.AvalonEdit.CodeCompletion; 2 | using ICSharpCode.AvalonEdit.Document; 3 | using ICSharpCode.AvalonEdit.Editing; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace PreposeGestureRecognizer 10 | { 11 | /// 12 | /// Implements AvalonEdit ICompletionData interface 13 | /// to provide the entries in the 14 | /// completion drop down. 15 | /// 16 | public class PreposeSyntaxCompletionData : ICompletionData 17 | { 18 | public PreposeSyntaxCompletionData(string text) 19 | { 20 | this.Text = text; 21 | } 22 | 23 | public System.Windows.Media.ImageSource Image 24 | { 25 | get { return null; } 26 | } 27 | 28 | public string Text { get; private set; } 29 | 30 | public double Priority { get { return 0; } } 31 | 32 | // Use this property if you want to show a fancy UIElement in the list. 33 | public object Content 34 | { 35 | get { return this.Text; } 36 | } 37 | 38 | public object Description 39 | { 40 | get { return this.Text; } 41 | } 42 | 43 | public void Complete(TextArea textArea, ISegment completionSegment, 44 | EventArgs insertionRequestEventArgs) 45 | { 46 | textArea.Document.Replace(completionSegment, this.Text); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | //------------------------------------------------------------------------------ 6 | 7 | using System; 8 | using System.Reflection; 9 | using System.Resources; 10 | using System.Runtime.InteropServices; 11 | using System.Windows; 12 | 13 | // General Information about an assembly is controlled through the following 14 | // set of attributes. Change these attribute values to modify the information 15 | // associated with an assembly. 16 | [assembly: AssemblyTitle("Prepose UI")] 17 | [assembly: AssemblyDescription("")] 18 | [assembly: AssemblyConfiguration("")] 19 | [assembly: AssemblyTrademark("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | // In order to begin building localizable applications, set 27 | // CultureYouAreCodingWith in your .csproj file 28 | // inside a . For example, if you are using US english 29 | // in your source files, set the to en-US. Then uncomment 30 | // the NeutralResourceLanguage attribute below. Update the "en-US" in 31 | // the line below to match the UICulture setting in the project file. 32 | 33 | //// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 34 | 35 | [assembly: ThemeInfo( 36 | ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located 37 | // (used if a resource is not found in the page, 38 | // or application resource dictionaries) 39 | ResourceDictionaryLocation.SourceAssembly)] // where the generic resource dictionary is located 40 | // (used if a resource is not found in the page, 41 | // app, or any theme specific resource dictionaries) 42 | 43 | // Version information for an assembly consists of the following four values: 44 | // 45 | // Major Version 46 | // Minor Version 47 | // Build Number 48 | // Revision 49 | // 50 | // You can specify all the values or you can default the Build and Revision Numbers 51 | // by using the '*' as shown below: 52 | // [assembly: AssemblyVersion("1.0.*")][assembly: NeutralResourcesLanguageAttribute("en-US")] 53 | [assembly: NeutralResourcesLanguage("en-US")] 54 | [assembly: CLSCompliant(true)] 55 | [assembly: AssemblyProductAttribute("Prepose UI")] 56 | [assembly: AssemblyCopyrightAttribute("Microsoft Research")] 57 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PreposeGestureRecognizer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PreposeGestureRecognizer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Initializing. 65 | /// 66 | internal static string InitializingStatusTextFormat { 67 | get { 68 | return ResourceManager.GetString("InitializingStatusTextFormat", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to No ready Kinect found!. 74 | /// 75 | internal static string NoSensorStatusText { 76 | get { 77 | return ResourceManager.GetString("NoSensorStatusText", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to FPS = {0:N1} Time = {1}. 83 | /// 84 | internal static string StandardStatusTextFormat { 85 | get { 86 | return ResourceManager.GetString("StandardStatusTextFormat", resourceCulture); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Initializing 122 | 123 | 124 | No ready Kinect found! 125 | 126 | 127 | FPS = {0:N1} Time = {1} 128 | 129 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PreposeGestureRecognizer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Z3GestureRecognizer/UpdatingNotes.txt: -------------------------------------------------------------------------------- 1 | - PreposeGestureRecognizer - UI application based on a Kinect sample 2 | - requires BigRationalLibrary for Z3 manipulation 3 | - requires ICSharpCode.AvalonEdit for UI color highlighting and completion of Repose text (open source library) 4 | - Microsoft.Z3 5 | - also as part of the build, native DLLs are copied 6 | - copy "$(SolutionDir)External\x64\libz3.dll" "$(OutDir)libz3.dll" 7 | - copy "$(SolutionDir)External\x64\Kinect20.dll" "$(OutDir)Kinect20.dll" // TODO 8 | - CustomHighlighting.xshd contains highlighting for Repose 9 | - Can hit an exception parsing XAML if you're lacking the rigth Kinect SDK 10 | 11 | - PreposeGestures - library for parsing, Z3 compilation and for safety testing and static analysis and runtime support 12 | 13 | - To regenerate the grammar, update the hard-coded path in build.bat and run it. You'll need to have Java JRE installed on you machine, because ANTLR depends on it. 14 | 15 | - public partial class PreposeGesturesParser : Antlr4.Runtime.Parser { -------------------------------------------------------------------------------- /Z3GestureRecognizer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /packages/AvalonEdit.4.4.2.9744/AvalonEdit.4.4.2.9744.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/packages/AvalonEdit.4.4.2.9744/AvalonEdit.4.4.2.9744.nupkg -------------------------------------------------------------------------------- /packages/AvalonEdit.4.4.2.9744/AvalonEdit.4.4.2.9744.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AvalonEdit 5 | 4.4.2.9744 6 | Daniel Grunwald 7 | Daniel Grunwald 8 | http://www.opensource.org/licenses/lgpl-2.1.php 9 | http://www.avalonedit.net/ 10 | http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png 11 | true 12 | AvalonEdit is the WPF-based text editor used in SharpDevelop. There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and one that targets .NET 3.5. 13 | AvalonEdit is the WPF-based text editor used in SharpDevelop 14 | AvalonEdit 4.4 changes the Home/End keys to only act on the current TextLine when word-wrapping is enabled. It also removes the caret stop in the middle of surrogate pairs, making characters outside the basic multilingual plane work as expected. 15 | en-US 16 | WPF Text Editor SharpDevelop AvalonEdit 17 | 18 | -------------------------------------------------------------------------------- /packages/AvalonEdit.4.4.2.9744/lib/Net35/ICSharpCode.AvalonEdit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/packages/AvalonEdit.4.4.2.9744/lib/Net35/ICSharpCode.AvalonEdit.dll -------------------------------------------------------------------------------- /packages/AvalonEdit.4.4.2.9744/lib/Net40/ICSharpCode.AvalonEdit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/prepose/6f558109d325bcea69c948077683e0ec3fbf91c4/packages/AvalonEdit.4.4.2.9744/lib/Net40/ICSharpCode.AvalonEdit.dll -------------------------------------------------------------------------------- /packages/repositories.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------