Esempio n. 1
0
        void OnVideoCaptureCreated(VideoCapture videoCapture)
        {
            if (videoCapture == null)
            {
                Debug.LogError("Did not find a video capture object. You may not be using the HoloLens.");
                return;
            }

            this._videoCapture = videoCapture;

            //Request the spatial coordinate ptr if you want fetch the camera and set it if you need to
            CameraStreamHelper.Instance.SetNativeISpatialCoordinateSystemPtr(_spatialCoordinateSystemPtr);

            _resolution = CameraStreamHelper.Instance.GetLowestResolution();
            float frameRate = CameraStreamHelper.Instance.GetHighestFrameRate(_resolution);

            videoCapture.FrameSampleAcquired += OnFrameSampleAcquired;

            //You don't need to set all of these params.
            //I'm just adding them to show you that they exist.
            CameraParameters cameraParams = new CameraParameters();

            cameraParams.cameraResolutionHeight = _resolution.height;
            cameraParams.cameraResolutionWidth  = _resolution.width;
            cameraParams.frameRate             = Mathf.RoundToInt(frameRate);
            cameraParams.pixelFormat           = CapturePixelFormat.BGRA32;
            cameraParams.rotateImage180Degrees = true; //If your image is upside down, remove this line.
            cameraParams.enableHolograms       = false;

            _videoPanelUI.ResolutionInit(_resolution.width, _resolution.height);

            videoCapture.StartVideoModeAsync(cameraParams, OnVideoModeStarted);
        }