public KinectInterop.SensorData OpenDefaultSensor(KinectInterop.FrameSource dwFlags, float sensorAngle, bool bUseMultiSource)
    {
        KinectInterop.SensorData sensorData = new KinectInterop.SensorData();
        sensorFlags = dwFlags;

        kinectSensor = KinectSensor.GetDefault();
        if(kinectSensor == null)
            return null;

        coordMapper = kinectSensor.CoordinateMapper;

        this.bodyCount = kinectSensor.BodyFrameSource.BodyCount;
        sensorData.bodyCount = this.bodyCount;
        sensorData.jointCount = 25;

        sensorData.depthCameraFOV = 60f;
        sensorData.colorCameraFOV = 53.8f;
        sensorData.depthCameraOffset = -0.05f;
        sensorData.faceOverlayOffset = -0.04f;

        if((dwFlags & KinectInterop.FrameSource.TypeBody) != 0)
        {
            if(!bUseMultiSource)
                bodyFrameReader = kinectSensor.BodyFrameSource.OpenReader();

            bodyData = new Body[sensorData.bodyCount];
        }

        var frameDesc = kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
        sensorData.colorImageWidth = frameDesc.Width;
        sensorData.colorImageHeight = frameDesc.Height;

        if((dwFlags & KinectInterop.FrameSource.TypeColor) != 0)
        {
            if(!bUseMultiSource)
                colorFrameReader = kinectSensor.ColorFrameSource.OpenReader();

            sensorData.colorImage = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels];
        }

        sensorData.depthImageWidth = kinectSensor.DepthFrameSource.FrameDescription.Width;
        sensorData.depthImageHeight = kinectSensor.DepthFrameSource.FrameDescription.Height;

        if((dwFlags & KinectInterop.FrameSource.TypeDepth) != 0)
        {
            if(!bUseMultiSource)
                depthFrameReader = kinectSensor.DepthFrameSource.OpenReader();

            sensorData.depthImage = new ushort[kinectSensor.DepthFrameSource.FrameDescription.LengthInPixels];
        }

        if((dwFlags & KinectInterop.FrameSource.TypeBodyIndex) != 0)
        {
            if(!bUseMultiSource)
                bodyIndexFrameReader = kinectSensor.BodyIndexFrameSource.OpenReader();

            sensorData.bodyIndexImage = new byte[kinectSensor.BodyIndexFrameSource.FrameDescription.LengthInPixels];
        }

        if((dwFlags & KinectInterop.FrameSource.TypeInfrared) != 0)
        {
            if(!bUseMultiSource)
                infraredFrameReader = kinectSensor.InfraredFrameSource.OpenReader();

            sensorData.infraredImage = new ushort[kinectSensor.InfraredFrameSource.FrameDescription.LengthInPixels];
        }

        //if(!kinectSensor.IsOpen)
        {
            //Debug.Log("Opening sensor, available: " + kinectSensor.IsAvailable);
            kinectSensor.Open();
        }

        float fWaitTime = Time.realtimeSinceStartup + 3f;
        while(!kinectSensor.IsAvailable && Time.realtimeSinceStartup < fWaitTime)
        {
            // wait for sensor to open
        }

        Debug.Log("K2-sensor " + (kinectSensor.IsOpen ? "opened" : "closed") +
                  ", available: " + kinectSensor.IsAvailable);

        if(bUseMultiSource && dwFlags != KinectInterop.FrameSource.TypeNone && kinectSensor.IsOpen)
        {
            multiSourceFrameReader = kinectSensor.OpenMultiSourceFrameReader((FrameSourceTypes)((int)dwFlags & 0x3F));
        }

        return sensorData;
    }
    public void CloseSensor(KinectInterop.SensorData sensorData)
    {
        if(coordMapper != null)
        {
            coordMapper = null;
        }

        if(bodyFrameReader != null)
        {
            bodyFrameReader.Dispose();
            bodyFrameReader = null;
        }

        if(bodyIndexFrameReader != null)
        {
            bodyIndexFrameReader.Dispose();
            bodyIndexFrameReader = null;
        }

        if(colorFrameReader != null)
        {
            colorFrameReader.Dispose();
            colorFrameReader = null;
        }

        if(depthFrameReader != null)
        {
            depthFrameReader.Dispose();
            depthFrameReader = null;
        }

        if(infraredFrameReader != null)
        {
            infraredFrameReader.Dispose();
            infraredFrameReader = null;
        }

        if(multiSourceFrameReader != null)
        {
            multiSourceFrameReader.Dispose();
            multiSourceFrameReader = null;
        }

        if(kinectSensor != null)
        {
            if (kinectSensor.IsOpen)
            {
                kinectSensor.Close();
            }

            kinectSensor = null;
        }
    }
 void Start()
 {
     depthFrameDesc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription;
     depthWidth = depthFrameDesc.Width;
     depthHeight = depthFrameDesc.Height;
     // buffer for points mapped to camera space coordinate.
     mapper = KinectSensor.GetDefault().CoordinateMapper;
     cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight];
     depthSourceManagerScript = depthSourceManager.GetComponent<DepthSourceManager>();
     colorSourceManagerScript = colorSourceManager.GetComponent<ColorSourceManager>();
     particles = new ParticleSystem.Particle[depthWidth * depthHeight];
     color_reader = KinectSensor.GetDefault().ColorFrameSource.OpenReader();
     colorFrameDesc = KinectSensor.GetDefault().ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
     colorSpacePoints = new ColorSpacePoint[depthWidth * depthHeight];
     color_array = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels];
 }
Example #4
0
    void OnApplicationQuit()
    {
        if(_Reader != null)
        {
            _Reader.Dispose();
            _Reader = null;
        }

        if(_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }
            _Sensor = null;
        }
    }
Example #5
0
        // Token: 0x06002BC9 RID: 11209 RVA: 0x000DB998 File Offset: 0x000D9D98
        private void __EventCleanup()
        {
            ColorFrameReader.Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks.TryAddDefault(this._pNative);
            List <EventHandler <ColorFrameArrivedEventArgs> > list = ColorFrameReader.Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_callbacks[this._pNative];
            object obj = list;

            lock (obj)
            {
                if (list.Count > 0)
                {
                    list.Clear();
                    if (this._pNative != IntPtr.Zero)
                    {
                        IntPtr pNative = this._pNative;
                        if (ColorFrameReader.f__mg2 == null)
                        {
                            ColorFrameReader.f__mg2 = new ColorFrameReader._Windows_Kinect_ColorFrameArrivedEventArgs_Delegate(ColorFrameReader.Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handler);
                        }
                        ColorFrameReader.Windows_Kinect_ColorFrameReader_add_FrameArrived(pNative, ColorFrameReader.f__mg2, true);
                    }
                    ColorFrameReader._Windows_Kinect_ColorFrameArrivedEventArgs_Delegate_Handle.Free();
                }
            }
            ColorFrameReader.Windows_Data_PropertyChangedEventArgs_Delegate_callbacks.TryAddDefault(this._pNative);
            List <EventHandler <PropertyChangedEventArgs> > list2 = ColorFrameReader.Windows_Data_PropertyChangedEventArgs_Delegate_callbacks[this._pNative];
            object obj2 = list2;

            lock (obj2)
            {
                if (list2.Count > 0)
                {
                    list2.Clear();
                    if (this._pNative != IntPtr.Zero)
                    {
                        IntPtr pNative2 = this._pNative;
                        if (ColorFrameReader.f__mg3 == null)
                        {
                            ColorFrameReader.f__mg3 = new ColorFrameReader._Windows_Data_PropertyChangedEventArgs_Delegate(ColorFrameReader.Windows_Data_PropertyChangedEventArgs_Delegate_Handler);
                        }
                        ColorFrameReader.Windows_Kinect_ColorFrameReader_add_PropertyChanged(pNative2, ColorFrameReader.f__mg3, true);
                    }
                    ColorFrameReader._Windows_Data_PropertyChangedEventArgs_Delegate_Handle.Free();
                }
            }
        }
    //關閉的時候會將Sensor關閉。
    public void Shutdown()
    {
        if (_Reader != null)
        {
            _Reader.Dispose();
            _Reader = null;
        }

        if (_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }

            _Sensor = null;
        }
    }
    // Use this for initialization
    void Start()
    {
        turnScript = Player.GetComponent<Turning>();
        // get the sensor object
        
        this.kinectSensor = KinectSensor.GetDefault();

        if (this.kinectSensor != null)
        {
            this.bodyCount = this.kinectSensor.BodyFrameSource.BodyCount;

            // color reader
            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();

            // create buffer from RGBA frame description
            var desc = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);


            // body data
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // body frame to use
            this.bodies = new Body[this.bodyCount];

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();
            for (int bodyIndex = 0; bodyIndex < this.bodyCount; bodyIndex++)
            {
                //PUT UPDATED UI STUFF HERE FOR NO GESTURE
                GestureTextGameObject.text = "none";
                //this.bodyText[bodyIndex] = "none";
                this.gestureDetectorList.Add(new GestureDetector(this.kinectSensor));
            }

            // start getting data from runtime
            this.kinectSensor.Open();
        }
        else
        {
            //kinect sensor not connected
        }
    }
    private void Start()
    {
        _Sensor = Kinect.KinectSensor.GetDefault();

        if (_Sensor != null)
        {
            _ColorReader = _Sensor.ColorFrameSource.OpenReader();
            _DepthReader = _Sensor.DepthFrameSource.OpenReader();

            var colorFrameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(Kinect.ColorImageFormat.Rgba);
            var depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription;

            if (!_Sensor.IsOpen)
            {
                _Sensor.Open();
            }
        }

        bodySourceManager = gameObject.AddComponent <BodySourceManager>();
    }
    //初始化Sensor,開啟彩色畫面的讀取器,建立新的影像編碼描述。
    void Start()
    {
        _Sensor = KinectSensor.GetDefault();

        if (_Sensor != null)
        {
            _Reader = _Sensor.ColorFrameSource.OpenReader();

            var frameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
            ColorWidth = frameDesc.Width;
            ColorHeight = frameDesc.Height;
            //建立貼圖物件,建立像素儲存的陣列。
            _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.RGBA32, false);
            _Data = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels];
            //若Sensor還沒開起,將Sensor開啟。
            if (!_Sensor.IsOpen)
            {
                _Sensor.Open();
            }
        }
    }
    private void OnApplicationQuit()
    {
        if (_ColorReader != null)
        {
            _ColorReader.Dispose();
            _ColorReader = null;
        }

        if (_DepthReader != null)
        {
            _DepthReader.Dispose();
            _DepthReader = null;
        }

        if (_Sensor != null)
        {
            if (_Sensor.IsOpen)
            {
                _Sensor.Close();
            }

            _Sensor = null;
        }
    }
Example #11
0
    //    void OnGUI()
    //    {
    //        GUI.skin.box.fontSize = 11;
    //        const int NumColumns = 2;
    //        for (int i = 0; i < this.bodyCount; i++)
    //        {
    //            GUI.contentColor = this.bodyColors[i];
    //            GUI.Box(new Rect(10 + ((i % NumColumns) * 145), 20 + ((i / NumColumns) * 145), 140, 140), this.bodyText[i]);
    //        }
    //    }
    void OnApplicationQuit()
    {
        if (this.colorFrameReader != null)
        {
            this.colorFrameReader.Dispose();
            this.colorFrameReader = null;
        }

        if (this.bodyFrameReader != null)
        {
            this.bodyFrameReader.Dispose();
            this.bodyFrameReader = null;
        }

        if (this.kinectSensor != null)
        {
            if (this.kinectSensor.IsOpen)
            {
                this.kinectSensor.Close();
            }

            this.kinectSensor = null;
        }
    }
Example #12
0
 // Token: 0x06002BB1 RID: 11185 RVA: 0x000DB365 File Offset: 0x000D9765
 internal ColorFrameReader(IntPtr pNative)
 {
     this._pNative = pNative;
     ColorFrameReader.Windows_Kinect_ColorFrameReader_AddRefObject(ref this._pNative);
 }
	void OnApplicationQuit ()
	{
		if (reader != null) {
			reader.Dispose ();
			reader = null;
		}
		
		if (sensor != null) {
			if (sensor.IsOpen) {
				sensor.Close ();
			}
			
			sensor = null;
		}
	}
    public KinectInterop.SensorData OpenDefaultSensor(KinectInterop.FrameSource dwFlags, float sensorAngle, bool bUseMultiSource)
    {
        KinectInterop.SensorData sensorData = new KinectInterop.SensorData();
        //sensorFlags = dwFlags;

        kinectSensor = KinectSensor.GetDefault();
        if(kinectSensor == null)
            return null;

        coordMapper = kinectSensor.CoordinateMapper;

        this.bodyCount = kinectSensor.BodyFrameSource.BodyCount;
        sensorData.bodyCount = this.bodyCount;
        sensorData.jointCount = 25;

        sensorData.depthCameraFOV = 60f;
        sensorData.colorCameraFOV = 53.8f;
        sensorData.depthCameraOffset = -0.03f;

        if((dwFlags & KinectInterop.FrameSource.TypeBody) != 0)
        {
            if(!bUseMultiSource)
                bodyFrameReader = kinectSensor.BodyFrameSource.OpenReader();

            bodyData = new Body[sensorData.bodyCount];
        }

        var frameDesc = kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
        sensorData.colorImageWidth = frameDesc.Width;
        sensorData.colorImageHeight = frameDesc.Height;

        if((dwFlags & KinectInterop.FrameSource.TypeColor) != 0)
        {
            if(!bUseMultiSource)
                colorFrameReader = kinectSensor.ColorFrameSource.OpenReader();

            sensorData.colorImage = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels];
        }

        sensorData.depthImageWidth = kinectSensor.DepthFrameSource.FrameDescription.Width;
        sensorData.depthImageHeight = kinectSensor.DepthFrameSource.FrameDescription.Height;

        if((dwFlags & KinectInterop.FrameSource.TypeDepth) != 0)
        {
            if(!bUseMultiSource)
                depthFrameReader = kinectSensor.DepthFrameSource.OpenReader();

            sensorData.depthImage = new ushort[kinectSensor.DepthFrameSource.FrameDescription.LengthInPixels];
        }

        if((dwFlags & KinectInterop.FrameSource.TypeBodyIndex) != 0)
        {
            if(!bUseMultiSource)
                bodyIndexFrameReader = kinectSensor.BodyIndexFrameSource.OpenReader();

            sensorData.bodyIndexImage = new byte[kinectSensor.BodyIndexFrameSource.FrameDescription.LengthInPixels];
        }

        if((dwFlags & KinectInterop.FrameSource.TypeInfrared) != 0)
        {
            if(!bUseMultiSource)
                infraredFrameReader = kinectSensor.InfraredFrameSource.OpenReader();

            sensorData.infraredImage = new ushort[kinectSensor.InfraredFrameSource.FrameDescription.LengthInPixels];
        }

        if(!kinectSensor.IsOpen)
        {
            kinectSensor.Open();
        }

        if(bUseMultiSource && dwFlags != KinectInterop.FrameSource.TypeNone && kinectSensor.IsOpen)
        {
            multiSourceFrameReader = kinectSensor.OpenMultiSourceFrameReader((FrameSourceTypes)dwFlags);
        }

        return sensorData;
    }
Example #15
0
    // Use this for initialization
    void Start()
    {
        AddTag("realtime01");
        AddTag("Body_Replay");

        lineMat       = new Material(Shader.Find("Diffuse"));
        lineMat.color = Color.yellow;
        GameObject temp = GameObject.CreatePrimitive(PrimitiveType.Capsule);

        cylinderMesh = temp.GetComponent <MeshFilter> ().sharedMesh;
        GameObject.Destroy(temp);
        radius      = 0.03f;
        sensitive   = 1.0f;
        body_scale  = 1.0f;
        bone_scale  = 0.02f;
        joint_scale = 0.04f;

        skeletonlist = new GameObject[] {
            skeleton_spinebased
            , skeleton_hipleft
            , skeleton_hipright
            , skeleton_spinemid
            , skeleton_kneeleft
            , skeleton_ankleleft
            , skeleton_kneeright
            , skeleton_ankleright
            , skeleton_spineshoulder
            , skeleton_neck
            , skeleton_shoulderleft
            , skeleton_head
            , skeleton_shoulderright
            , skeleton_elbowleft
            , skeleton_wristleft
            , skeleton_handleft
            , skeleton_elbowright
            , skeleton_wristright
            , skeleton_handright
        };

        canvash = ((RectTransform)canvas.transform).rect.height / 2.0f;
        canvasw = ((RectTransform)canvas.transform).rect.width / 2.0f;
        lefthand.SetActive(false);
        realtime_relation = GameObject.Find("realtime_relation");
        //turnScript = Player.GetComponent<Turning>();
        // get the sensor object

        this.kinectSensor = Kinect.KinectSensor.GetDefault();

        if (this.kinectSensor != null)
        {
            this.bodyCount = this.kinectSensor.BodyFrameSource.BodyCount;

            // color reader
            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();

            // create buffer from RGBA frame description
            var desc = this.kinectSensor.ColorFrameSource.CreateFrameDescription(Kinect.ColorImageFormat.Rgba);


            // body data
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // body frame to use
            this.bodies = new Kinect.Body[this.bodyCount];

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List <GestureDetector>();


            //real_time_skeleton_init ();
            for (int bodyIndex = 0; bodyIndex < this.bodyCount; bodyIndex++)
            {
                //PUT UPDATED UI STUFF HERE FOR NO GESTURE
                //GestureTextGameObject.text = "none";
                //this.bodyText[bodyIndex] = "none";
                this.gestureDetectorList.Add(new GestureDetector(this.kinectSensor));
            }

            // start getting data from runtime
            this.kinectSensor.Open();
        }
        else
        {
            //kinect sensor not connected
        }
    }
    public void CloseSensor(KinectInterop.SensorData sensorData)
    {
        if(coordMapper != null)
        {
            coordMapper = null;
        }

        if(bodyFrameReader != null)
        {
            bodyFrameReader.Dispose();
            bodyFrameReader = null;
        }

        if(bodyIndexFrameReader != null)
        {
            bodyIndexFrameReader.Dispose();
            bodyIndexFrameReader = null;
        }

        if(colorFrameReader != null)
        {
            colorFrameReader.Dispose();
            colorFrameReader = null;
        }

        if(depthFrameReader != null)
        {
            depthFrameReader.Dispose();
            depthFrameReader = null;
        }

        if(infraredFrameReader != null)
        {
            infraredFrameReader.Dispose();
            infraredFrameReader = null;
        }

        if(multiSourceFrameReader != null)
        {
            multiSourceFrameReader.Dispose();
            multiSourceFrameReader = null;
        }

        if(kinectSensor != null)
        {
            //if (kinectSensor.IsOpen)
            {
                //Debug.Log("Closing sensor, available: " + kinectSensor.IsAvailable);
                kinectSensor.Close();
            }

            float fWaitTime = Time.realtimeSinceStartup + 3f;
            while(kinectSensor.IsOpen && Time.realtimeSinceStartup < fWaitTime)
            {
                // wait for sensor to close
            }

            Debug.Log("K2-sensor " + (kinectSensor.IsOpen ? "opened" : "closed") +
                      ", available: " + kinectSensor.IsAvailable);

            kinectSensor = null;
        }
    }
Example #17
0
    // Use this for initialization
    void Start()
    {
        //_effects.Add (_lightening);

        // GUI color and text objects
        this.bodyColors = new UnityEngine.Color[] {
            UnityEngine.Color.red,
            UnityEngine.Color.yellow,
            UnityEngine.Color.green,
            UnityEngine.Color.blue,
            UnityEngine.Color.cyan,
            UnityEngine.Color.magenta
        };

        this.bodyText = new string[this.bodyColors.Length];

        // get the sensor object
        this.kinectSensor = KinectSensor.GetDefault();

        if (this.kinectSensor != null)
        {
            this.bodyCount = this.kinectSensor.BodyFrameSource.BodyCount;

            // color reader
            this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();

            // create buffer from RGBA frame description
            var desc = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
            this.colorData = new byte[desc.BytesPerPixel * desc.LengthInPixels];

            this.colorTexture = new Texture2D(desc.Width, desc.Height, TextureFormat.RGBA32, false);

            // body data
            this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();

            // body frame to use
            this.bodies = new Body[this.bodyCount];

            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List<GestureDetector>();
            for (int bodyIndex = 0; bodyIndex < this.bodyCount; bodyIndex++)
            {
                this.bodyText[bodyIndex] = "none";
                this.gestureDetectorList.Add(new GestureDetector(this.kinectSensor, this));
            }

            // start getting data from runtime
            this.kinectSensor.Open();
        }
    }
	GestureBuilderDetector() {
		KinectSensor sensor = KinectSensor.GetDefault ();
		colorFrameReader = sensor.ColorFrameSource.OpenReader();
	}
Example #19
0
    void Start()
    {
        //Socket
        Connect ("127.0.0.1", "Hej");
        //SOCKET: data ska vara koordinater
        //byte[] data = System.Text.Encoding.ASCII.GetBytes("hej3");
        //stream.Write(data, 0, data.Length);
        _Sensor = KinectSensor.GetDefault();

        if (_Sensor != null)
        {
            prevX = -1;
            prevY = -1;
            offsetX = -250;
            offsetY = -250;

            _Reader = _Sensor.ColorFrameSource.OpenReader();
            lineRenderer = gameObject.AddComponent<LineRenderer>();
            var frameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
            ColorWidth = frameDesc.Width;
            ColorHeight = frameDesc.Height;

            _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.RGBA32, false);
            _Data = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels];

            if (!_Sensor.IsOpen)
            {
                _Sensor.Open();
            }
        }
    }
	void Start ()
	{
		sensor = KinectSensor.GetDefault ();
		
		if (sensor != null) {
			reader = sensor.ColorFrameSource.OpenReader ();
			
			FrameDescription frameDesc = sensor.ColorFrameSource.CreateFrameDescription (ColorImageFormat.Rgba);

			
			texture = new Texture2D (frameDesc.Width, frameDesc.Height, TextureFormat.RGBA32, false);
			data = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels];
			
			if (!sensor.IsOpen) {
				sensor.Open ();
			}


			rgbaMat = new Mat (texture.height, texture.width, CvType.CV_8UC4);
			
			Debug.Log ("rgbaMat " + rgbaMat.ToString ());
			
			gameObject.transform.localScale = new Vector3 (texture.width, texture.height, 1);
			
			gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
			
			Camera.main.orthographicSize = texture.height / 2;
			
			
			// sepia
			sepiaKernel = new Mat (4, 4, CvType.CV_32F);
			sepiaKernel.put (0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
			sepiaKernel.put (1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
			sepiaKernel.put (2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
			sepiaKernel.put (3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
			
			
			// pixelize
			pixelizeIntermediateMat = new Mat ();
			pixelizeSize0 = new Size ();
			
			
			//comic
			comicGrayMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
			comicLineMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
			comicMaskMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
			
			//create a striped background.
			comicBgMat = new Mat (texture.height, texture.width, CvType.CV_8UC1, new Scalar (255));
			for (int i = 0; i < comicBgMat.rows ()*2.5f; i=i+4) {
				Core.line (comicBgMat, new Point (0, 0 + i), new Point (comicBgMat.cols (), -comicBgMat.cols () + i), new Scalar (0), 1);
			}
			
			comicDstMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
			
			comicGrayPixels = new byte[comicGrayMat.cols () * comicGrayMat.rows () * comicGrayMat.channels ()];
			comicMaskPixels = new byte[comicMaskMat.cols () * comicMaskMat.rows () * comicMaskMat.channels ()];
		} else {
			UnityEngine.Debug.LogError ("No ready Kinect found!");
		}


	}