Example #1
0
	// Use this for initialization
	void Start () {
		kinect = devOrEmu.getKinect();
		//tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
		tex = new Texture2D(320,240,TextureFormat.ARGB32,false);
		GetComponent<Renderer>().material.mainTexture = tex;
		
	}
Example #2
0
 // Use this for initialization
 void Start()
 {
     //get an instance of the Kinect device
     kinect = devOrEmu.getKinect();
     //get an instance of the Kinect mesh controller script
     kinectCtlr = KinectModelControllerV2.instance;
 }
	// Use this for initialization
	void Start () {
		kinect = devOrEmu.getKinect();
		players = new Kinect.NuiSkeletonTrackingState[Kinect.Constants.NuiSkeletonCount];
		trackedPlayers = new int[Kinect.Constants.NuiSkeletonMaxTracked];
		trackedPlayers[0] = -1;
		trackedPlayers[1] = -1;
		bonePos = new Vector3[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		boneVel = new Vector3[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		boneState = new Kinect.NuiSkeletonPositionTrackingState[2,(int)Kinect.NuiSkeletonPositionIndex.Count];
		
		//create the transform matrix that converts from kinect-space to world-space
		Matrix4x4 trans = new Matrix4x4();
		trans.SetTRS( new Vector3(-kinect.getKinectCenter().x,
		                          kinect.getSensorHeight()-kinect.getKinectCenter().y,
		                          -kinect.getKinectCenter().z),
		             Quaternion.identity, Vector3.one );
		Matrix4x4 rot = new Matrix4x4();
		Quaternion quat = new Quaternion();
		double theta = Mathf.Atan((kinect.getLookAt().y+kinect.getKinectCenter().y-kinect.getSensorHeight()) / (kinect.getLookAt().z + kinect.getKinectCenter().z));
		float kinectAngle = (float)(theta * (180 / Mathf.PI));
		quat.eulerAngles = new Vector3(-kinectAngle, 0, 0);
		rot.SetTRS( Vector3.zero, quat, Vector3.one );
		Matrix4x4 flip = Matrix4x4.identity;
		flip[2,2] = -1;
		//final transform matrix offsets the rotation of the kinect, then translates to a new center
		kinectToWorld = flip*trans*rot;
	}
Example #4
0
 // Use this for initialization
 void Start()
 {
     kinect = devOrEmu.getKinect();
     //tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
     tex = new Texture2D(320, 240, TextureFormat.ARGB32, false);
     renderer.material.mainTexture = tex;
 }
 // Use this for initialization
 void Start()
 {
     kinect = devOrEmu.getKinect();
     //tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
     tex = new Texture2D(320, 240, TextureFormat.ARGB32, false);
     gameObject.GetComponent <Renderer>().material.mainTexture = tex;
 }
 // Use this for initialization
 void Start()
 {
     kinect = (Component.FindObjectOfType(typeof(DeviceOrEmulator)) as DeviceOrEmulator).getKinect();// devOrEmu.getKinect();
     //tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
     tex = new Texture2D(320,240,TextureFormat.ARGB32,false);
     renderer.material.mainTexture = tex;
 }
Example #7
0
 void Start()
 {
     sw = new SkeletonWrapper();
     openconnection();
     kinect = devOrEmu.getKinect();
     StartCoroutine("SetGuard");
     tex = new Texture2D(320, 240, TextureFormat.ARGB32, false);
     GetComponent <Renderer>().material.mainTexture = tex;
 }
Example #8
0
    // Use this for initialization
    void Start()
    {
        kinect       = devOrEmu.getKinect();
        video_width  = Kinect.NativeMethods.qfKinectGetVideoWidth();
        video_height = Kinect.NativeMethods.qfKinectGetVideoHeight();

        tex = new Texture2D(video_width, video_height, TextureFormat.ARGB32, false);
        GetComponent <Renderer>().material.mainTexture = tex;
    }
Example #9
0
 // Use this for initialization
 void Start()
 {
     GameObject obj = GameObject.Find ("KinectPrefab");
     devOrEmu = obj.GetComponent<DeviceOrEmulator> ();
     kinect = devOrEmu.getKinect();
     //tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
     tex = new Texture2D(320,240,TextureFormat.ARGB32,false);
     GetComponent<Renderer>().material.mainTexture = tex;
 }
Example #10
0
    // Use this for initialization
    void Start()
    {
        kinect = devOrEmu.getKinect();
        //tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
        tex = new Texture2D(320, 240, TextureFormat.ARGB32, false);
        GetComponent <Renderer>().material.mainTexture = tex;


        // Get a reference to the storage service, using the default Firebase App
        fbStorage = FirebaseStorage.DefaultInstance;
    }
Example #11
0
	// Use this for initialization
	void Start () {
		kinect = devOrEmu.getKinect();
		//allocate space to store the data of storedFrames frames.
		frameQueue = new Queue(storedFrames);
		for(int ii = 0; ii < storedFrames; ii++){	
			frameData frame = new frameData();
			frame.depthImg = new short[320 * 240];
			frame.players = new bool[Kinect.Constants.NuiSkeletonCount];
			frame.segmentation = new bool[Kinect.Constants.NuiSkeletonCount,320*240];
			frame.bounds = new int[Kinect.Constants.NuiSkeletonCount,4];
			frameQueue.Enqueue(frame);
		}
	}
Example #12
0
    // Use this for initialization
    void Start()
    {
        kinect = GameObject.Find("/KinectPrefab").GetComponent <DeviceOrEmulator>().getKinect();

        usersClrTex = new Texture2D(ColorWidth, ColorHeight); // new Texture2D(ColorWidth , ColorHeight, TextureFormat.ARGB32, false); //

        //usersClrRect = new Rect(Screen.width, Screen.height - usersClrTex.height / 2, -usersClrTex.width / 2, usersClrTex.height / 2);

        usersClrRect = new Rect((Screen.width + DisplayWidth) / 2,
                                (Screen.height - DisplayHeight) / 2,
                                -DisplayWidth,
                                DisplayHeight);
    }
Example #13
0
    // Use this for initialization
    void Start()
    {
        kinect = devOrEmu.getKinect();

        _bones = new GameObject[(int)Kinect.NuiSkeletonPositionIndex.Count] {
            Hip_Center, Spine, Shoulder_Center, Head,
            Shoulder_Left, Elbow_Left, Wrist_Left, Hand_Left,
            Shoulder_Right, Elbow_Right, Wrist_Right, Hand_Right,
            Hip_Left, Knee_Left, Ankle_Left, Foot_Left,
            Hip_Right, Knee_Right, Ankle_Right, Foot_Right
        };

        m_skl_InColorPoint = new Vector3[(int)Kinect.NuiSkeletonPositionIndex.Count];
    }
Example #14
0
    void Start()
    {
        kinect = device.getKinect();
        var resolution = kinect.DepthResolution;

        var width = resolution == Kinect.NuiImageResolution.resolution320x240 ? 320 : 640;
        var height = resolution == Kinect.NuiImageResolution.resolution320x240 ? 240 : 480;

        texture = new Texture2D(width, height, TextureFormat.ARGB32, false, true);

        size = width * height;
        buffer = new Color32[size];

        thread = new Thread(() => {

            List<short[]> last = new List<short[]>();
            for (int i = 0; i < 10; ++i) {
                last.Add(new short[size]);
            }
            while (true) {
                if (kinect.pollDepth()) {
                    var depths = kinect.getDepth();
                    Color32[] writeTo = new Color32[size];
                    for (int i = 0; i < size; ++i) {
                        var s = depths[i];

                        //check for sudden 0-depth pixels, replace with old value
                        for (int j = 0; s == 0 && j < lookBack; ++j) {
                            s = last[j][i];
                        }
                        //make unknown depth far, instead of near
                        if (s == 0) {
                            s = unchecked((short)0xFFFF);
                        }
                        writeTo[i].r = (byte)((s >> 0) & 0xffff);
                        writeTo[i].g = (byte)((s >> 8) & 0xffff);
                    }

                    buffer = writeTo;
                    last.RemoveAt(last.Count - 1);
                    last.Insert(0, depths);
                }
                Thread.Sleep(1);
            }
        });
        thread.Start();

        backgroudDepth = RenderTexture.GetTemporary(width, height);
    }
Example #15
0
    // Use this for initialization
    void Start()
    {
        kinect = GameObject.Find("/KinectPrefab").GetComponent <DeviceOrEmulator>().getKinect();

        //kinect = devOrEmu.getKinect();

        // Initialize depth & label map related stuff
        usersMapSize = DepthWidth * DepthHeight;
        usersLblTex  = new Texture2D(DepthWidth, DepthHeight);
        usersMapRect = new Rect((Screen.width + DisplayWidth) / 2,
                                10,
                                -DisplayWidth,
                                DisplayHeight);

        usersMapColors    = new Color[usersMapSize];
        usersHistogramMap = new float[5000];
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        kinect = devOrEmu.getKinect();

        depth_width  = Kinect.NativeMethods.qfKinectGetDepthWidth();
        depth_height = Kinect.NativeMethods.qfKinectGetDepthHeight();

        //allocate space to store the data of storedFrames frames.
        frameQueue = new Queue(storedFrames);
        for (int ii = 0; ii < storedFrames; ii++)
        {
            frameData frame = new frameData();
            frame.depthImg     = new short[depth_width * depth_height];
            frame.players      = new bool[Kinect.Constants.NuiSkeletonCount];
            frame.segmentation = new bool[Kinect.Constants.NuiSkeletonCount, depth_width *depth_height];
            frame.bounds       = new int[Kinect.Constants.NuiSkeletonCount, 4];
            frameQueue.Enqueue(frame);
        }
    }
Example #17
0
    // Update is called once per frame
    void Update()
    {
        kinect = devOrEmu.getKinect();
        if (kinect.pollColor() == true)
        {
            Color32[] colorKinect = kinect.getColor();

            for (int i = 0; i < 640; i++)
            {
                for (int j = 0; j < 480; j++)
                {
                    int index = i * 480 + j;
                    int a     = colorKinect[index].a;
                    int r     = colorKinect[index].r;
                    int g     = colorKinect[index].g;
                    int b     = colorKinect[index].b;
                    bitmapTest.SetPixel(i, j, System.Drawing.Color.FromArgb(a, r, g, b));
                }
            }

            image = UnmanagedImage.FromManagedImage(bitmapTest);
            //var bitmap = image.ToManagedImage();

            if (image.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
            {
                grayImage = image;
            }
            else
            {
                if (grayImage != null)
                {
                    grayImage.Dispose();
                }
                grayImage = UnmanagedImage.Create(image.Width, image.Height,
                                                  System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
                Grayscale.CommonAlgorithms.BT709.Apply(image, grayImage);
            }
            scan_code();
        }
    }
Example #18
0
  // Use this for initialization
  void Start()
  {
    kinect = devOrEmu.getKinect();
    //allocate space to store the data of storedFrames frames.
    frameQueue = new Queue(storedFrames);
    //rollingVariance = new float[320 * 240];
    for (int ii = 0; ii < storedFrames; ii++)
    {
      frameData frame = new frameData();
      frame.depthImg = new float[320 * 240];
      frame.depthImgNormalized = new float[320 * 240];
      frame.rollingVariance = new float[320 * 240];
      frame.OriginalImage = new float[320 * 240];
      frame.rollingVarianceNormalized = new float[320 * 240];
      frame.rollingVarianceNormalizedLastFrame = new float[320 * 240];
      frame.depthImgNormalizedSmooth = new float[320 * 240];
      frame.segmentation = new bool[Kinect.Constants.NuiSkeletonCount, 320 * 240];
      frame.bounds = new int[Kinect.Constants.NuiSkeletonCount, 4];
      frameQueue.Enqueue(frame);

    }
    pollDepth();
  }
Example #19
0
    void Start()
    {
        devOrEmu = GameObject.Find("KinectPrefab(Clone)").GetComponent <DeviceOrEmulator>();
        PointCloudSlowDistance = 6.0f;
        kinect = devOrEmu.getKinect();
        //	tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
        tex = new Texture2D(80, 60, TextureFormat.ARGB32, false);
//		tex = new Texture2D(160, 120,TextureFormat.ARGB32, false);
//		tex = new Texture2D(80, 60,TextureFormat.ARGB32, false);
//		renderer.material.mainTexture = tex;
        thePixels         = new GameObject[length, width];
        originalPositions = new GameObject[length, width];
        numPixels         = length * width;
        //int middlePointx = 0;
        //int middlePointy = 0;
        for (int i = 0; i < length; i++)
        {
            for (int x = 0; x < width; x++)
            {
                thePixels[i, x]                          = (GameObject)GameObject.Instantiate(pointCloudPixel, new Vector3((float)-i / 4, (float)-x / 4, 0), Quaternion.identity);
                originalPositions[i, x]                  = (GameObject)GameObject.Instantiate(positionHolder, new Vector3((float)-i / 4, (float)-x / 4, 0), Quaternion.identity);
                thePixels[i, x].transform.parent         = PointCloudParent.transform;
                originalPositions[i, x].transform.parent = PointCloudParent.transform;
                thePixels[i, x].renderer.material.color  = Color.white;

                //		if(x == width/2 && i == length/2)
                //		{
                //			middlePointx = x;
                //			middlePointy = i;
                //		}
                //Add Particle System?
            }
        }
        PointCloudParent.transform.Rotate(new Vector3(0, 0, 90));
        //middlePoint = thePixels[middlePointx, middlePointy].transform.position;
    }
Example #20
0
    void Start()
    {
        devOrEmu = GameObject.Find ("KinectPrefab(Clone)").GetComponent<DeviceOrEmulator>();
        PointCloudSlowDistance = 6.0f;
        kinect = devOrEmu.getKinect();
        //	tex = new Texture2D(640,480,TextureFormat.ARGB32,false);
        tex = new Texture2D(80,60,TextureFormat.ARGB32,false);
        //		tex = new Texture2D(160, 120,TextureFormat.ARGB32, false);
        //		tex = new Texture2D(80, 60,TextureFormat.ARGB32, false);
        //		renderer.material.mainTexture = tex;
        thePixels = new GameObject[length, width];
        originalPositions = new GameObject[length, width];
        numPixels = length * width;
        //int middlePointx = 0;
        //int middlePointy = 0;
        for(int i = 0; i < length; i++)
        {
            for(int x = 0; x < width; x++)
            {
                thePixels[i,x] = (GameObject)GameObject.Instantiate (pointCloudPixel, new Vector3((float)-i/4, (float)-x/4, 0), Quaternion.identity);
                originalPositions[i,x] = (GameObject)GameObject.Instantiate (positionHolder, new Vector3((float)-i/4, (float)-x/4, 0), Quaternion.identity);
                thePixels[i,x].transform.parent = PointCloudParent.transform;
                originalPositions[i,x].transform.parent = PointCloudParent.transform;
                thePixels[i,x].renderer.material.color = Color.white;

        //		if(x == width/2 && i == length/2)
        //		{
        //			middlePointx = x;
        //			middlePointy = i;
        //		}
                //Add Particle System?
            }
        }
        PointCloudParent.transform.Rotate (new Vector3(0,0,90));
        //middlePoint = thePixels[middlePointx, middlePointy].transform.position;
    }
Example #21
0
 // Use this for initialization
 void Start()
 {
     kinect = devOrEmu.getKinect();
 }
    // Use this for initialization
    void Start()
    {
        kinect = devOrEmu.getKinect();
        //allocate space to store the data of storedFrames frames.
        frameQueue = new Queue(storedFrames);
        for(int ii = 0; ii < storedFrames; ii++){
            frameData frame = new frameData();
            frame.depthImg = new short[320 * 240];
            frame.players = new bool[Kinect.Constants.NuiSkeletonCount];
            frame.segmentation = new bool[Kinect.Constants.NuiSkeletonCount,320*240];
            frame.bounds = new int[Kinect.Constants.NuiSkeletonCount,4];
            frameQueue.Enqueue(frame);
        }

        if (target == null) {
            target = renderer;
        }
        textureSize = ResolutionData.FromZigResolution(TextureSize);
        texture = new Texture2D(textureSize.Width, textureSize.Height);
        texture.wrapMode = TextureWrapMode.Clamp;
        depthHistogramMap = new float[MaxDepth];
        depthToColor = new Color32[MaxDepth];
        outputPixels = new Color32[textureSize.Width * textureSize.Height];

        if (null != target) {
            target.material.mainTexture = texture;
        }
    }