Esempio n. 1
0
    private void OnVideoCaptureCreated(VideoCapture videoCapture)
    {
        if (videoCapture != null)
        {
            _videoCapture = videoCapture;
            CameraParameters cameraParameters = new CameraParameters();
            cameraParameters.hologramOpacity        = 0.0f;
            cameraParameters.frameRate              = _cameraFramerate;
            cameraParameters.cameraResolutionWidth  = _cameraResolution.width;
            cameraParameters.cameraResolutionHeight = _cameraResolution.height;
            cameraParameters.pixelFormat            = CapturePixelFormat.BGRA32;

            _cameraBorderController.SetRecordingMaterial();
            _cameraBorderController.Instruction.text = CameraInstructionTextStop;
            _startRecordingTime = DateTime.Now;

            if (!Directory.Exists(_mediaPath))
            {
                Directory.CreateDirectory(_mediaPath);
            }


            _videoCapture.StartVideoModeAsync(cameraParameters,
                                              VideoCapture.AudioState.ApplicationAndMicAudio,
                                              OnStartedVideoCaptureMode);
        }
        else
        {
            Debug.LogError("Failed to create VideoCapture Instance!");
            OnVideoFinished?.Invoke("Error");
        }
    }
    public void TakePicture()
    {
        // Create a PhotoCapture object
        PhotoCapture.CreateAsync(false, delegate(PhotoCapture captureObject)
        {
            if (captureObject != null)
            {
                _photoCaptureObject = captureObject;
                CameraParameters cameraParameters       = new CameraParameters();
                cameraParameters.hologramOpacity        = 0.0f;
                cameraParameters.cameraResolutionWidth  = _cameraResolution.width;
                cameraParameters.cameraResolutionHeight = _cameraResolution.height;
                cameraParameters.pixelFormat            = CapturePixelFormat.BGRA32;

                if (!Directory.Exists(_mediaPath))
                {
                    Directory.CreateDirectory(_mediaPath);
                }

                _fileName         = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".jpg";
                _fullPathFileName = Path.Combine(_mediaPath, _fileName);

                _cameraBorderController.SetRecordingMaterial();
                // Activate the camera
                _photoCaptureObject.StartPhotoModeAsync(cameraParameters, delegate(PhotoCapture.PhotoCaptureResult result)
                {
                    // Take a picture
                    _photoCaptureObject.TakePhotoAsync(_fullPathFileName, PhotoCaptureFileOutputFormat.JPG, OnCapturedPhotoToDisk);
                });
            }
            else
            {
                Debug.LogError("Failed to create PhotoCapture Instance!");
                OnPhotoFinished?.Invoke("Error");
            }
        });
    }