void Start() { calibratedUsers = new List <int>(); calibratingUsers = new List <int>(); allUsers = new List <int>(); this.userGenerator = OpenNIContext.OpenNode(NodeType.User) as UserGenerator; //new UserGenerator(this.Context.context); this.skeletonCapbility = this.userGenerator.SkeletonCapability; this.poseDetectionCapability = this.userGenerator.PoseDetectionCapability; this.calibPose = this.skeletonCapbility.CalibrationPose; this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.userGenerator.NewUser += new EventHandler <NewUserEventArgs>(userGenerator_NewUser); this.userGenerator.LostUser += new EventHandler <UserLostEventArgs>(userGenerator_LostUser); this.poseDetectionCapability.PoseDetected += new EventHandler <PoseDetectedEventArgs>(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new EventHandler <CalibrationEndEventArgs>(skeletonCapbility_CalibrationEnd); }
// Use this for initialization void Start() { // Make sure we have a valid OpenNIContext Context = OpenNIContext.Instance; if (null == Context) { print("OpenNI not inited"); return; } // init session manager sessionManager = new SessionManager(Context.context, "Click", "RaiseHand"); sessionManager.SessionStart += new System.EventHandler <PositionEventArgs>(sessionManager_SessionStart); sessionManager.SessionEnd += new System.EventHandler(sessionManager_SessionEnd); sessionManager.AddListener(broadcaster); }
// Use this for initialization void Start() { Context = OpenNIContext.Instance; // init texture MapOutputMode mom = Context.Depth.MapOutputMode; factor = mom.XRes / 160; YRes = mom.YRes; XRes = mom.XRes; depthMapTexture = new Texture2D((int)(mom.XRes / factor), (int)(mom.YRes / factor)); // depthmap data rawDepthMap = new short[(int)(mom.XRes * mom.YRes)]; depthMapPixels = new Color[(int)((mom.XRes / factor) * (mom.YRes / factor))]; // histogram stuff int maxDepth = (int)Context.Depth.DeviceMaxDepth; depthHistogramMap = new float[maxDepth]; }
void Start() { Image = OpenNIContext.OpenNode(NodeType.Image) as ImageGenerator; inputSize = new Vector2(Image.MapOutputMode.XRes, Image.MapOutputMode.YRes); outputSize = (null != target) ? new Vector2(Mathf.NextPowerOfTwo((int)inputSize.x), Mathf.NextPowerOfTwo((int)inputSize.y)) : new Vector2(inputSize.x, inputSize.y); imageMapTexture = new Texture2D((int)outputSize.x, (int)outputSize.y, TextureFormat.RGB24, false); rawImageMap = new byte[Image.GetMetaData().BytesPerPixel *Image.MapOutputMode.XRes *Image.MapOutputMode.YRes]; imageMapPixels = new Color32[(int)(outputSize.x * outputSize.y)]; if (null != target) { float uScale = inputSize.x / outputSize.x; float vScale = inputSize.y / outputSize.y; target.material.SetTextureScale("_MainTex", new Vector2(uScale, -vScale)); target.material.SetTextureOffset("_MainTex", new Vector2(0.0f, vScale - 1.0f)); target.material.mainTexture = imageMapTexture; } openGl = SystemInfo.graphicsDeviceVersion.Contains("OpenGL"); }
void Start() { // Make sure we have a valid OpenNIContext Context = OpenNIContext.Instance; if (null == Context) { print("OpenNI not inited"); return; } calibratedUsers = new List <int>(); calibratingUsers = new List <int>(); allUsers = new List <int>(); this.userGenerator = new UserGenerator(this.Context.context); this.skeletonCapbility = this.userGenerator.SkeletonCapability; this.poseDetectionCapability = this.userGenerator.PoseDetectionCapability; this.calibPose = this.skeletonCapbility.CalibrationPose; this.skeletonCapbility.SetSkeletonProfile(SkeletonProfile.All); this.userGenerator.NewUser += new EventHandler <NewUserEventArgs>(userGenerator_NewUser); this.userGenerator.LostUser += new EventHandler <UserLostEventArgs>(userGenerator_LostUser); // this.poseDetectionCapability.PoseDetected += new EventHandler<PoseDetectedEventArgs>(poseDetectionCapability_PoseDetected); this.skeletonCapbility.CalibrationEnd += new EventHandler <CalibrationEndEventArgs>(skeletonCapbility_CalibrationEnd); }
public void OnApplicationQuit() { if (null == context) return; if (!LoadFromRecording) { context.StopGeneratingAll(); } // shutdown is deprecated, but Release doesn't do the job context.Shutdown(); context = null; OpenNIContext.instance = null; }
public void OnApplicationQuit() { context.StopGeneratingAll(); OpenNIContext.instance = null; }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FPinInContext[0] != FContext) { FContext = FPinInContext[0]; } if (FContext == null) { FRunning = false; return; } if (FContext.running && !FRunning && FContext.context != null) { try { FImageGenerator = FContext.context.FindExistingNode(global::OpenNI.NodeType.Image) as ImageGenerator; FDepthGenerator = FContext.context.FindExistingNode(global::OpenNI.NodeType.Depth) as DepthGenerator; FDepthGenerator.AlternativeViewpointCapability.SetViewpoint(FImageGenerator); FImageRGB = new ImageRGB(); FImageDepth = new ImageL16(); FImageWorld = new ImageRGB32F(); Size size = new Size(640, 480); FImageRGBBuffer = new Image<Bgr, byte>(size); FImageDepthBuffer = new Image<Gray,ushort>(size); FImageWorldBuffer = new Image<Rgb, float>(size); FPinOutRGB[0] = FImageRGB; FPinOutDepth[0] = FImageDepth; FPinOutWorld[0] = FImageWorld; FThread = new Thread(fnThread); FRunning = true; FThread.Start(); FPinOutStatus[0] = "OK"; } catch (StatusException e) { FRunning = false; FPinOutStatus[0] = e.Message; } } }
void sessionManager_OnContextShutdown(object sender, System.EventArgs e) { print("Context gone"); sessionManager.Dispose(); Context = null; }