void Start()
    {
        trackingIDs = new trackedBody[6];
        for(int y = 0; y < trackingIDs.Length; y++) {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }
        coordinateCalibration = FindObjectOfType(typeof(RUISCoordinateCalibration)) as RUISCoordinateCalibration;

        _SourceManager = SourceManager.GetComponent<Kinect2SourceManager>();
        _Sensor = _SourceManager.GetSensor();
        if(_Sensor != null) {
            imageWidth = _Sensor.DepthFrameSource.FrameDescription.Width;
            imageHeight = _Sensor.DepthFrameSource.FrameDescription.Height;
            texture = new Texture2D(imageWidth / _DownsampleSize, imageHeight / _DownsampleSize);
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        trackingIDs = new trackedBody[6];
        for (int y = 0; y < trackingIDs.Length; y++)
        {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }
        coordinateCalibration = FindObjectOfType(typeof(RUISCoordinateCalibration)) as RUISCoordinateCalibration;

        _SourceManager = SourceManager.GetComponent <Kinect2SourceManager>();
        _Sensor        = _SourceManager.GetSensor();
        if (_Sensor != null)
        {
            imageWidth  = _Sensor.DepthFrameSource.FrameDescription.Width;
            imageHeight = _Sensor.DepthFrameSource.FrameDescription.Height;
            texture     = new Texture2D(imageWidth / _DownsampleSize, imageHeight / _DownsampleSize);
        }
    }
Exemplo n.º 3
0
    public RUISKinectToOculusDK2CalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Oculus_DK2;
        this.inputDevice2 = RUISDevice.Kinect_1;

        this.numberOfSamplesToTake    = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;

        trackingIDs = new trackedBody[6];
        for (int y = 0; y < trackingIDs.Length; y++)
        {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }

        inputManager     = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        kinectSelection  = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
        settingsManager  = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;

        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples   = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if (this.timeBetweenSamples < 0.1f)
        {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List <GameObject>();

        samples_Kinect1   = new List <Vector3>();
        samples_OculusDK2 = new List <Vector3>();

        this.calibrationCube               = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere             = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects       = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects   = calibrationSettings.depthViewObjects;
        this.iconObjects        = calibrationSettings.iconObjects;


        if (GameObject.Find("PSMoveWand") != null)
        {
            GameObject.Find("PSMoveWand").SetActive(false);
        }

        // Models
        this.oculusDK2CameraObject = GameObject.Find("OculusDK2Camera");
        this.kinect1ModelObject    = GameObject.Find("KinectCamera");
        this.oculusRiftModel       = GameObject.Find("OculusRift");

        FixedFollowTransform followTransform = Component.FindObjectOfType <FixedFollowTransform>();

        if (followTransform && this.oculusRiftModel)
        {
            followTransform.transformToFollow = this.oculusRiftModel.transform;
        }

        // Depth view
        this.depthView = GameObject.Find("KinectDepthView");

        // Icons
        this.oculusDK2Icon = GameObject.Find("OculusDK2 Icon");
        this.kinectIcon    = GameObject.Find("Kinect Icon");

        this.floorPlane = GameObject.Find("Floor");

        if (this.oculusDK2Icon && this.oculusDK2Icon.GetComponent <GUITexture>())
        {
            this.oculusDK2Icon.GetComponent <GUITexture>().pixelInset = new Rect(5.1f, 10.0f, 70.0f, 70.0f);
        }

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if (this.oculusDK2CameraObject)
        {
            this.oculusDK2CameraObject.SetActive(true);
        }
        if (this.kinect1ModelObject)
        {
            this.kinect1ModelObject.SetActive(true);
        }
        if (this.oculusRiftModel)
        {
            this.oculusRiftModel.SetActive(true);
        }
        if (this.oculusDK2Icon)
        {
            this.oculusDK2Icon.SetActive(true);
        }
        if (this.kinectIcon)
        {
            this.kinectIcon.SetActive(true);
        }
        if (this.calibrationPhaseObjects)
        {
            this.calibrationPhaseObjects.SetActive(true);
        }
        if (this.calibrationResultPhaseObjects)
        {
            this.calibrationResultPhaseObjects.SetActive(false);
        }
        if (this.depthView)
        {
            this.depthView.SetActive(true);
        }
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
	public RUISKinect2ToKinectCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		this.inputDevice1 = RUISDevice.Kinect_2;
		this.inputDevice2 = RUISDevice.Kinect_1;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		trackingIDs = new trackedBody[6]; 
		for(int y = 0; y < trackingIDs.Length; y++) {
			trackingIDs[y] = new trackedBody(-1, false, 1);
		}
		
		kinectSelection = MonoBehaviour.FindObjectOfType(typeof(NIPlayerManagerCOMSelection)) as NIPlayerManagerCOMSelection;
		settingsManager = MonoBehaviour.FindObjectOfType(typeof(OpenNISettingsManager)) as OpenNISettingsManager;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_Kinect1 = new List<Vector3>();
		samples_Kinect2 = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		if(GameObject.Find ("PSMoveWand") != null)
			GameObject.Find ("PSMoveWand").SetActive(false);
		
		// Models
		this.kinect1ModelObject = GameObject.Find ("KinectCamera");
		this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");
		
		RUISSkeletonController skeletonController = Component.FindObjectOfType<RUISSkeletonController>();
		Transform rightHand = null;
		if(skeletonController)
			rightHand = skeletonController.rightHand;
		FixedFollowTransform followTransform = Component.FindObjectOfType<FixedFollowTransform>();
		if(followTransform && rightHand)
			followTransform.transformToFollow = rightHand;
		
		// Depth view
		this.depthView = GameObject.Find ("KinectDepthView");
		this.depthView2 = GameObject.Find ("Kinect2DepthView");
		// Icons
		this.Kinect1Icon = GameObject.Find ("Kinect Icon");
		this.Kinect2Icon = GameObject.Find ("Kinect2 Icon");

		this.floorPlane = GameObject.Find ("Floor");

		if(this.Kinect1Icon && this.Kinect1Icon.GetComponent<GUITexture>())
			this.Kinect1Icon.GetComponent<GUITexture>().pixelInset = new Rect(5.1f, 10.0f, 70.0f, 70.0f);
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.kinect1ModelObject)
			this.kinect1ModelObject.SetActive(true);
		if(this.kinect2ModelObject)
			this.kinect2ModelObject.SetActive(true);
		if(this.Kinect1Icon)
			this.Kinect1Icon.SetActive(true);
		if(this.Kinect2Icon)
			this.Kinect2Icon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		if(this.depthView)
			this.depthView.SetActive(true);
		if(this.depthView2)
			this.depthView2.SetActive(true);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}
    public RUISKinect2ToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings)
    {
        this.inputDevice1 = RUISDevice.Kinect_2;
        this.inputDevice2 = RUISDevice.PS_Move;

        this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
        this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;

        trackingIDs = new trackedBody[6];
        for(int y = 0; y < trackingIDs.Length; y++) {
            trackingIDs[y] = new trackedBody(-1, false, 1);
        }

        psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
        inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
        coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
        kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;

        this.timeSinceScriptStart = 0;
        this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;

        // Limit sample rate
        if(this.timeBetweenSamples < 0.1f) {
            this.timeBetweenSamples = 0.1f;
        }

        calibrationSpheres = new List<GameObject>();

        samples_PSMove = new List<Vector3>();
        samples_Kinect2 = new List<Vector3>();

        this.calibrationCube = calibrationSettings.calibrationCubePrefab;
        this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
        this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
        this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;

        this.deviceModelObjects = calibrationSettings.deviceModelObjects;
        this.depthViewObjects = calibrationSettings.depthViewObjects;
        this.iconObjects = calibrationSettings.iconObjects;

        this.PSMoveWandObject = GameObject.Find ("PSMoveWand");

        // Models
        this.psEyeModelObject = GameObject.Find ("PS Eye");
        this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");

        // Depth view
        this.depthView = GameObject.Find ("Kinect2DepthView");

        // Icons
        this.psMoveIcon = GameObject.Find ("PS Move Icon");
        this.KinectIcon = GameObject.Find ("Kinect2 Icon");

        this.floorPlane = GameObject.Find ("Floor");

        foreach (Transform child in this.deviceModelObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.depthViewObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        foreach (Transform child in this.iconObjects.transform)
        {
            child.gameObject.SetActive(false);
        }

        if(this.psEyeModelObject)
            this.psEyeModelObject.SetActive(true);
        if(this.PSMoveWandObject)
            this.PSMoveWandObject.SetActive(true);
        if(this.kinect2ModelObject)
            this.kinect2ModelObject.SetActive(true);
        if(this.psMoveIcon)
            this.psMoveIcon.SetActive(true);
        if(this.KinectIcon)
            this.KinectIcon.SetActive(true);
        if(this.calibrationPhaseObjects)
            this.calibrationPhaseObjects.SetActive(true);
        if(this.calibrationResultPhaseObjects)
            this.calibrationResultPhaseObjects.SetActive(false);
        if(this.depthView)
            this.depthView.SetActive(true);
        this.xmlFilename = calibrationSettings.xmlFilename;
    }
Exemplo n.º 6
0
	public RUISKinect2ToPSMoveCalibrationProcess(RUISCalibrationProcessSettings calibrationSettings) {
		
		this.inputDevice1 = RUISDevice.Kinect_2;
		this.inputDevice2 = RUISDevice.PS_Move;
		
		this.numberOfSamplesToTake = calibrationSettings.numberOfSamplesToTake;
		this.numberOfSamplesPerSecond = calibrationSettings.numberOfSamplesPerSecond;
		
		trackingIDs = new trackedBody[6]; 
		for(int y = 0; y < trackingIDs.Length; y++) {
			trackingIDs[y] = new trackedBody(-1, false, 1);
		}
		
		psMoveWrapper = MonoBehaviour.FindObjectOfType(typeof(PSMoveWrapper)) as PSMoveWrapper;
		inputManager = MonoBehaviour.FindObjectOfType(typeof(RUISInputManager)) as RUISInputManager;
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		kinect2SourceManager = MonoBehaviour.FindObjectOfType(typeof(Kinect2SourceManager)) as Kinect2SourceManager;
		
		this.timeSinceScriptStart = 0;
		this.timeBetweenSamples = 1 / (float)numberOfSamplesPerSecond;
		
		// Limit sample rate
		if(this.timeBetweenSamples < 0.1f) {
			this.timeBetweenSamples = 0.1f;
		}
		
		calibrationSpheres = new List<GameObject>();
		
		samples_PSMove = new List<Vector3>();
		samples_Kinect2 = new List<Vector3>();
		
		this.calibrationCube = calibrationSettings.calibrationCubePrefab;
		this.calibrationSphere = calibrationSettings.calibrationSpherePrefab;
		this.calibrationPhaseObjects = calibrationSettings.calibrationPhaseObjects;
		this.calibrationResultPhaseObjects = calibrationSettings.calibrationResultPhaseObjects;
		
		this.deviceModelObjects = calibrationSettings.deviceModelObjects;
		this.depthViewObjects = calibrationSettings.depthViewObjects;
		this.iconObjects = calibrationSettings.iconObjects;
		
		this.PSMoveWandObject = GameObject.Find ("PSMoveWand");
		
		// Models
		this.psEyeModelObject = GameObject.Find ("PS Eye");
		this.kinect2ModelObject = GameObject.Find ("Kinect2Camera");
		
		// Depth view
		this.depthView = GameObject.Find ("Kinect2DepthView");
		
		// Icons
		this.psMoveIcon = GameObject.Find ("PS Move Icon");
		this.KinectIcon = GameObject.Find ("Kinect2 Icon");
		
		this.floorPlane = GameObject.Find ("Floor");
		
		foreach (Transform child in this.deviceModelObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.depthViewObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		foreach (Transform child in this.iconObjects.transform)
		{
			child.gameObject.SetActive(false);
		}
		
		if(this.psEyeModelObject)
			this.psEyeModelObject.SetActive(true);
		if(this.PSMoveWandObject)
			this.PSMoveWandObject.SetActive(true);
		if(this.kinect2ModelObject)
			this.kinect2ModelObject.SetActive(true);
		if(this.psMoveIcon)
			this.psMoveIcon.SetActive(true);
		if(this.KinectIcon)
			this.KinectIcon.SetActive(true);
		if(this.calibrationPhaseObjects)
			this.calibrationPhaseObjects.SetActive(true);
		if(this.calibrationResultPhaseObjects)
			this.calibrationResultPhaseObjects.SetActive(false);
		if(this.depthView)
			this.depthView.SetActive(true);
		this.xmlFilename = calibrationSettings.xmlFilename;
	}