예제 #1
0
    /// <summary>
    /// Begin process of Image Capturing and send To Azure
    /// Computer Vision service.
    /// </summary>
    private void ExecuteImageCaptureAndAnalysis()
    {
        // Set the camera resolution to be the highest possible
        Resolution cameraResolution = UnityEngine.Windows.WebCam.PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

        Texture2D targetTexture = new Texture2D(cameraResolution.width, cameraResolution.height);

        // Begin capture process, set the image format
        UnityEngine.Windows.WebCam.PhotoCapture.CreateAsync(false, delegate(UnityEngine.Windows.WebCam.PhotoCapture captureObject)
        {
            photoCaptureObject = captureObject;
            UnityEngine.Windows.WebCam.CameraParameters camParameters = new UnityEngine.Windows.WebCam.CameraParameters();
            camParameters.hologramOpacity        = 0.0f;
            camParameters.cameraResolutionWidth  = targetTexture.width;
            camParameters.cameraResolutionHeight = targetTexture.height;
            camParameters.pixelFormat            = UnityEngine.Windows.WebCam.CapturePixelFormat.BGRA32;

            // Capture the image from the camera and save it in the App internal folder
            captureObject.StartPhotoModeAsync(camParameters, delegate(UnityEngine.Windows.WebCam.PhotoCapture.PhotoCaptureResult result)
            {
                string filename = string.Format(@"CapturedImage{0}.jpg", tapsCount);

                string filePath = Path.Combine(Application.persistentDataPath, filename);

                VisionManager.instance.imagePath = filePath;

                photoCaptureObject.TakePhotoAsync(filePath, UnityEngine.Windows.WebCam.PhotoCaptureFileOutputFormat.JPG, OnCapturedPhotoToDisk);

                currentlyCapturing = false;
            });
        });
    }
예제 #2
0
        public Task <bool> StartCapture()
        {
            if (FrameHeight == 0 && FrameWidth == 0)
            {
                Debug.LogError("StartCapture() invoked before camera initialized.");
                return(Task.FromResult(false));
            }
            PhotoCapture.CreateAsync(false, delegate(PhotoCapture captureObject)
            {
                _photoCaptureObject = captureObject;
                UnityEngine.Windows.WebCam.CameraParameters cameraParameters = new UnityEngine.Windows.WebCam.CameraParameters
                {
                    hologramOpacity        = 0.0f,
                    cameraResolutionWidth  = FrameWidth,
                    cameraResolutionHeight = FrameHeight,
                    pixelFormat            = CapturePixelFormat.NV12
                };

                _photoCaptureObject?.StartPhotoModeAsync(cameraParameters, delegate
                {
                    _photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
                });
            });
            return(Task.FromResult(true));
        }
예제 #3
0
    void OnPhotoCaptureCreated(UnityEngine.Windows.WebCam.PhotoCapture captureObject)
    {
        photoCapture = captureObject;

        Resolution cameraResolution = UnityEngine.Windows.WebCam.PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

        UnityEngine.Windows.WebCam.CameraParameters c = new UnityEngine.Windows.WebCam.CameraParameters();
        c.hologramOpacity        = 0.0f;
        c.cameraResolutionWidth  = cameraResolution.width;
        c.cameraResolutionHeight = cameraResolution.height;
        c.pixelFormat            = UnityEngine.Windows.WebCam.CapturePixelFormat.JPEG;

        captureObject.StartPhotoModeAsync(c, OnPhotoModeStarted);
    }
 private extern void StartVideoMode_Internal(CameraParameters cameraParameters, AudioState audioState, OnVideoModeStartedCallback onVideoModeStartedCallback);
예제 #5
0
 private extern void StartPhotoMode_Internal(CameraParameters setupParams, OnPhotoModeStartedCallback onPhotoModeStartedCallback);
예제 #6
0
 private extern void StartVideoMode_Internal_Injected(ref CameraParameters cameraParameters, VideoCapture.AudioState audioState, VideoCapture.OnVideoModeStartedCallback onVideoModeStartedCallback);
예제 #7
0
 private void StartVideoMode_Internal(CameraParameters cameraParameters, VideoCapture.AudioState audioState, VideoCapture.OnVideoModeStartedCallback onVideoModeStartedCallback)
 {
     this.StartVideoMode_Internal_Injected(ref cameraParameters, audioState, onVideoModeStartedCallback);
 }
예제 #8
0
 private extern void StartPhotoMode_Internal_Injected(ref CameraParameters setupParams, PhotoCapture.OnPhotoModeStartedCallback onPhotoModeStartedCallback);
예제 #9
0
 private void StartPhotoMode_Internal(CameraParameters setupParams, PhotoCapture.OnPhotoModeStartedCallback onPhotoModeStartedCallback)
 {
     this.StartPhotoMode_Internal_Injected(ref setupParams, onPhotoModeStartedCallback);
 }