public MainWindow() { InitializeComponent(); this.context = new Context(SAMPLE_XML_FILE); this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depth == null) { throw new Exception("Viewer must have a depth node!"); } this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = new SkeletonCapability(this.userGenerator); this.poseDetectionCapability = new PoseDetectionCapability(this.userGenerator); this.calibPose = this.skeletonCapbility.GetCalibrationPose(); this.userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); this.userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapbility_CalibrationEnd); this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.joints = new Dictionary<uint,Dictionary<SkeletonJoint,SkeletonJointPosition>>(); this.userGenerator.StartGenerating(); this.histogram = new int[this.depth.GetDeviceMaxDepth()]; MapOutputMode mapMode = this.depth.GetMapOutputMode(); this.bitmap = new Bitmap((int)mapMode.nXRes, (int)mapMode.nYRes/*, System.Drawing.Imaging.PixelFormat.Format24bppRgb*/); this.shouldRun = true; this.readerThread = new Thread(ReaderThread); this.readerThread.Start(); }
void Initialize() { this.context = new Context("SamplesConfig.xml"); this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depth == null) { throw new Exception("Viewer must have a depth node!"); } this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = new SkeletonCapability(this.userGenerator); this.poseDetectionCapability = new PoseDetectionCapability(this.userGenerator); this.calibPose = this.skeletonCapbility.GetCalibrationPose(); this.userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); this.userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapbility_CalibrationEnd); this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.userGenerator.StartGenerating(); App.ViewModel.Status = "Waiting to acquire user"; this.ShouldRun = true; this.readerThread = new Thread(ReaderThread); this.readerThread.Start(); }
public void initKinect() { kinectStarted = true; FMessage[0] = "Init OpenNI Node"; this.context = new Context(SAMPLE_XML_FILE); this.depth = context.FindExistingNode(xn.NodeType.Depth) as DepthGenerator; if (this.depth == null) { //throw new Exception("Viewer must have a depth node!"); FLogger.Log(LogType.Debug, "non ci siamo eh"); } else { FLogger.Log(LogType.Debug, "Ecchime sono un Primesense attivato e running....:P"); } this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = new SkeletonCapability(this.userGenerator); this.poseDetectionCapability = new PoseDetectionCapability(this.userGenerator); this.calibPose = this.skeletonCapbility.GetCalibrationPose(); this.userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); this.userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapbility_CalibrationEnd); this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.joints = new Dictionary<uint, Dictionary<SkeletonJoint, SkeletonJointPosition>>(); this.userGenerator.StartGenerating(); FMessage[0] = "OpenNI Node registered"; this.histogram = new int[this.depth.GetDeviceMaxDepth()]; MapOutputMode mapMode = this.depth.GetMapOutputMode(); texW = (int)mapMode.nXRes; texH = (int)mapMode.nYRes; FLogger.Log(LogType.Debug, "Winit: " + texW + "Hinit: " + texH); FLogger.Log(LogType.Debug, "kinectStarted = " + kinectStarted); this.bitmap = new System.Drawing.Bitmap((int)mapMode.nXRes, (int)mapMode.nYRes, System.Drawing.Imaging.PixelFormat.Format32bppArgb); this.shouldRun = true; this.readerThread = new Thread(ReaderThread); this.readerThread.Start(); FMessage[0] = "OpenNI Thread Started "; }
void Start() { /*really unity? do you do that for real? */ InitializeCharacter(); this.context = new Context(SAMPLE_XML_FILE); this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depth == null) { throw new Exception("Viewer must have a depth node!"); } this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = new SkeletonCapability(this.userGenerator); this.poseDetectionCapability = new PoseDetectionCapability(this.userGenerator); this.calibPose = this.skeletonCapbility.GetCalibrationPose(); this.userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); this.userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapbility_CalibrationEnd); this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.joints = new Dictionary<uint,Dictionary<SkeletonJoint,SkeletonJointPosition>>(); this.userGenerator.StartGenerating(); this.histogram = new int[this.depth.GetDeviceMaxDepth()]; MapOutputMode mapMode = this.depth.GetMapOutputMode(); // this.bitmap = new Bitmap((int)mapMode.nXRes, (int)mapMode.nYRes/*, System.Drawing.Imaging.PixelFormat.Format24bppRgb*/); usersLblTex = new Texture2D((int)mapMode.nXRes, (int)mapMode.nYRes); Debug.Log("usersLblTex = w: "+ usersLblTex.width + " h: " + usersLblTex.height ); usersMapSize = mapMode.nXRes * mapMode.nYRes; usersMapColors = new Color[usersMapSize]; usersMapRect = new Rect(Screen.width - usersLblTex.width / 2, Screen.height - usersLblTex.height / 2, usersLblTex.width / 2, usersLblTex.height / 2); usersLabelMap = new short[usersMapSize]; usersDepthMap = new short[usersMapSize]; usersHistogramMap = new float[5000]; //DepthMetaData depthMD = new DepthMetaData(); this.shouldRun = true; //this.readerThread = new Thread(ReaderThread); // this.readerThread.Start(); }
void Start() { texture = new Texture2D (640, 480, TextureFormat.RGB24, false); rgbMaterial.mainTextureScale = new Vector2 (0.62f, 0.93f); // fixes weird scaling problem rgbMaterial.mainTexture = texture; context = new Context (XML_FILE); depth = context.FindExistingNode (NodeType.Depth) as DepthGenerator; if (depth == null) { Debug.LogError ("Viewer must have a depth node!"); return; } imageGenerator = context.FindExistingNode (NodeType.Image) as ImageGenerator; if (imageGenerator == null) { Debug.LogError ("Viewer must have an image generator!"); return; } depth.GetAlternativeViewPointCap ().SetViewPoint (imageGenerator); //handsGenerator = context.FindExistingNode(NodeType.Hands) as HandsGenerator; //if (handsGenerator == null) { // Debug.LogError("Viewer must have a hands generator!"); // return; //} //handsGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); //gestureGenerator = context.FindExistingNode (NodeType.Gesture) as GestureGenerator; //if (gestureGenerator == null) { // Debug.LogError ("Viewer must have a gesture node!"); //} //gestureGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); userGenerator = new UserGenerator (context); skeletonCapability = new SkeletonCapability (userGenerator); poseDetectionCapability = new PoseDetectionCapability (userGenerator); calibPose = skeletonCapability.GetCalibrationPose (); userGenerator.NewUser += new UserGenerator.NewUserHandler (userGenerator_NewUser); userGenerator.LostUser += new UserGenerator.LostUserHandler (userGenerator_LostUser); poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler (poseDetectionCapability_PoseDetected); skeletonCapability.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler (skeletonCapability_CalibrationEnd); skeletonCapability.SetSkeletonProfile (SkeletonProfile.All); userGenerator.StartGenerating (); imageGenerator.StartGenerating (); //handsGenerator.HandCreate += new HandsGenerator.HandCreateHandler (hands_HandCreate); //handsGenerator.HandUpdate += new HandsGenerator.HandUpdateHandler (hands_HandUpdate); //handsGenerator.HandDestroy += new HandsGenerator.HandDestroyHandler (hands_HandDestroy); //gestureGenerator.AddGesture ("Wave"); //gestureGenerator.GestureRecognized += new GestureGenerator.GestureRecognizedHandler (gestures_GestureRecognized); //gestureGenerator.StartGenerating(); if (drawSkeleton) { GameObject o = new GameObject ("User"); mainUser = o.transform; mainUser.position = new Vector3 (0, 0, 0); mainUser.parent = transform; GameObject obj = Instantiate (o, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject; center = obj.transform; //center.parent = mainUser; obj.name = "Center"; createDefaultLineRenderer (center); obj = Instantiate (o, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject; leftArm = obj.transform; //leftArm.parent = mainUser; obj.name = "L Arm"; createDefaultLineRenderer (leftArm); obj = Instantiate (o, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject; rightArm = obj.transform; //rightArm.parent = mainUser; obj.name = "R Arm"; createDefaultLineRenderer (rightArm); obj = Instantiate (o, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject; leftLeg = obj.transform; //leftLeg.parent = mainUser; obj.name = "L Leg"; createDefaultLineRenderer (leftLeg); obj = Instantiate (o, new Vector3 (0, 0, 0), Quaternion.identity) as GameObject; rightLeg = obj.transform; //rightLeg.parent = mainUser; obj.name = "R Leg"; createDefaultLineRenderer (rightLeg); } }
/// <summary> /// OpenNIスレッドの起動 /// /// </summary> private void StartOpenNI() { try { context = new Context(Application.StartupPath + Settings.OPENNI_CONFIG); } catch(GeneralException ge){ Console.WriteLine(ge.Message); this.Close(); return; } depthGenerator = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depthGenerator == null) { throw new Exception("Viewer must have a depth node!"); } userGenerator = new UserGenerator(context); userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); userGenerator.StartGenerating(); imageGenerator = context.FindExistingNode(NodeType.Image) as ImageGenerator; imageGenerator.StartGenerating(); poseDetectionCapability = new PoseDetectionCapability(userGenerator); poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); skeletonCapability = new SkeletonCapability(userGenerator); skeletonCapability.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapability_CalibrationEnd); skeletonCapability.SetSkeletonProfile(SkeletonProfile.All); depthGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); histogram = new int[depthGenerator.GetDeviceMaxDepth()]; // 出力モード //this.mapMode = depthGenerator.GetMapOutputMode(); this.mapMode = imageGenerator.GetMapOutputMode(); bitmap = new Bitmap((int)mapMode.nXRes, (int)mapMode.nYRes/*, System.Drawing.Imaging.PixelFormat.Format24bppRgb*/); shouldRun = true; openNiThread = new Thread(ReaderThread); openNiThread.Start(); }
void Start() { this.context = new Context(SAMPLE_XML_FILE); this.depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (this.depth == null) { throw new Exception("Viewer must have a depth node!"); } this.userGenerator = new UserGenerator(this.context); this.skeletonCapbility = new SkeletonCapability(this.userGenerator); this.poseDetectionCapability = new PoseDetectionCapability(this.userGenerator); this.calibPose = this.skeletonCapbility.GetCalibrationPose(); this.userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); this.userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapbility_CalibrationEnd); this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.userGenerator.StartGenerating(); MapOutputMode mapMode = this.depth.GetMapOutputMode(); this.shouldRun = true; }
public void Run() { this.context = new Context (SAMPLE_XML_FILE); var ges = context.FindExistingNode (NodeType.Gesture) as GestureGenerator; if (ges == null) throw new Exception ("Viewer must have a gesture node!"); //foreach (var ggs in ges.EnumerateAllGestures ()) Console.Error.WriteLine (ggs); return; this.depth = context.FindExistingNode (NodeType.Depth) as DepthGenerator; if (this.depth == null) throw new Exception ("Viewer must have a depth node!"); user_gen = new UserGenerator (context); skel_cap = new SkeletonCapability (user_gen); pose_cap = new PoseDetectionCapability (user_gen); calib_pose = skel_cap.GetCalibrationPose (); user_gen.NewUser += delegate (ProductionNode node, uint id) { if (user_count++ > 0) Console.Error.WriteLine ("WARNING: this application does not recognize more than 1 person"); else pose_cap.StartPoseDetection (calib_pose, id); }; user_gen.LostUser += delegate (ProductionNode node, uint id) { user_count--; joints.Remove (id); }; pose_cap.PoseDetected += delegate (ProductionNode node, string pose, uint id) { pose_cap.StopPoseDetection (id); skel_cap.RequestCalibration (id, true); }; skel_cap.CalibrationEnd += delegate (ProductionNode node, uint id, bool success) { if (success) { skel_cap.StartTracking (id); joints.Add (id, new Dictionary<SkeletonJoint, SkeletonJointPosition>()); } else { pose_cap.StartPoseDetection (calib_pose, id); } }; skel_cap.SetSkeletonProfile (SkeletonProfile.All); joints = new Dictionary<uint,Dictionary<SkeletonJoint,SkeletonJointPosition>> (); user_gen.StartGenerating (); histogram = new int [this.depth.GetDeviceMaxDepth ()]; MapOutputMode mapMode = this.depth.GetMapOutputMode (); tcp_client = new TcpClient (); tcp_client.Connect ("localhost", 9801); tcp_writer = new StreamWriter (tcp_client.GetStream ()); // bitmap = new Bitmap ((int) mapMode.nXRes, (int) mapMode.nYRes/*, System.Drawing.Imaging.PixelFormat.Format24bppRgb*/); should_run = true; readerThread = new Thread (ReaderThread); readerThread.Start (); shouldPrintState = false; Console.WriteLine ("Type [CR] to stop"); Console.ReadLine (); should_run = false; }
void Start() { context = new Context(XML_FILE); depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (depth == null) { Debug.LogError("Viewer must have a depth node!"); return; } imageGenerator = context.FindExistingNode(NodeType.Image) as ImageGenerator; if (imageGenerator == null) { Debug.LogError("Viewer must have an image generator!"); return; } userGenerator = new UserGenerator(context); skeletonCapability = new SkeletonCapability(userGenerator); poseDetectionCapability = new PoseDetectionCapability(userGenerator); calibPose = skeletonCapability.GetCalibrationPose(); userGenerator.NewUser += new UserGenerator.NewUserHandler(userGenerator_NewUser); userGenerator.LostUser += new UserGenerator.LostUserHandler(userGenerator_LostUser); poseDetectionCapability.PoseDetected += new PoseDetectionCapability.PoseDetectedHandler(poseDetectionCapability_PoseDetected); skeletonCapability.CalibrationEnd += new SkeletonCapability.CalibrationEndHandler(skeletonCapability_CalibrationEnd); skeletonCapability.SetSkeletonProfile(SkeletonProfile.All); userGenerator.StartGenerating(); MapOutputMode mapMode = depth.GetMapOutputMode(); GameObject o = new GameObject("User"); mainUser = o.transform; mainUser.position = new Vector3(0,0,0); mainUser.parent = transform; GameObject obj = Instantiate(o, new Vector3(0,0,0), Quaternion.identity) as GameObject; center = obj.transform; //center.parent = mainUser; obj.name = "Center"; createDefaultLineRenderer(center); obj = Instantiate(o, new Vector3(0,0,0), Quaternion.identity) as GameObject; leftArm = obj.transform; //leftArm.parent = mainUser; obj.name = "L Arm"; createDefaultLineRenderer(leftArm); obj = Instantiate(o, new Vector3(0,0,0), Quaternion.identity) as GameObject; rightArm = obj.transform; //rightArm.parent = mainUser; obj.name = "R Arm"; createDefaultLineRenderer(rightArm); obj = Instantiate(o, new Vector3(0,0,0), Quaternion.identity) as GameObject; leftLeg = obj.transform; //leftLeg.parent = mainUser; obj.name = "L Leg"; createDefaultLineRenderer(leftLeg); obj = Instantiate(o, new Vector3(0,0,0), Quaternion.identity) as GameObject; rightLeg = obj.transform; //rightLeg.parent = mainUser; obj.name = "R Leg"; createDefaultLineRenderer(rightLeg); }