예제 #1
0
    /// <summary>
    /// Use the start function to start the picture capturing process
    /// </summary>
    void Start()
    {
        //Get the highest resolution
        m_cameraResolution = UnityEngine.XR.WSA.WebCam.PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

        UnityEngine.XR.WSA.WebCam.PhotoCapture.CreateAsync(false, delegate(UnityEngine.XR.WSA.WebCam.PhotoCapture captureObject)
        {
            //Assign capture object
            m_photoCapture = captureObject;

            //Configure camera
            UnityEngine.XR.WSA.WebCam.CameraParameters cameraParameters = new UnityEngine.XR.WSA.WebCam.CameraParameters();
            cameraParameters.hologramOpacity        = 0.0f;
            cameraParameters.cameraResolutionWidth  = m_cameraResolution.width;
            cameraParameters.cameraResolutionHeight = m_cameraResolution.height;
            cameraParameters.pixelFormat            = UnityEngine.XR.WSA.WebCam.CapturePixelFormat.JPEG;

            //Start the photo mode and start taking pictures
            m_photoCapture.StartPhotoModeAsync(cameraParameters, delegate(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result)
            {
                Debug.Log("Photo Mode started");
                InvokeRepeating("ExecutePictureProcess", 0, m_pictureInterval);
            });
        });
    }
예제 #2
0
 /// <summary>
 /// Clean up on destroty
 /// </summary>
 void OnDestroy()
 {
     m_photoCapture.StopPhotoModeAsync(
         delegate(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult res)
     {
         m_photoCapture.Dispose();
         m_photoCapture = null;
         Debug.Log("Photo Mode stopped");
     }
         );
 }
예제 #3
0
    // Quand une photo est prise
    void OnPhotoCaptureCreated(UnityEngine.XR.WSA.WebCam.PhotoCapture captureObject)
    {
        photo_capture_     = captureObject;
        camera_resolution_ = UnityEngine.XR.WSA.WebCam.PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

        UnityEngine.XR.WSA.WebCam.CameraParameters c = new UnityEngine.XR.WSA.WebCam.CameraParameters();
        c.hologramOpacity        = 0.0f;
        c.cameraResolutionWidth  = camera_resolution_.width;
        c.cameraResolutionHeight = camera_resolution_.height;
        c.pixelFormat            = UnityEngine.XR.WSA.WebCam.CapturePixelFormat.PNG;

        captureObject.StartPhotoModeAsync(c, OnPhotoModeStarted);
    }
예제 #4
0
    public void CapturePhotoAsync(OnCaptured _callback)
    {
        callback = _callback;

        UnityEngine.XR.WSA.WebCam.PhotoCapture.CreateAsync(false, (_photoCapture) => {
            Debug.Log("PhotoInput start");
            this.photoCapture           = _photoCapture;
            Resolution cameraResolution = UnityEngine.XR.WSA.WebCam.PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();

            UnityEngine.XR.WSA.WebCam.CameraParameters c = new UnityEngine.XR.WSA.WebCam.CameraParameters();
            c.hologramOpacity        = 0.0f;
            c.cameraResolutionWidth  = cameraResolution.width;
            c.cameraResolutionHeight = cameraResolution.height;
            c.pixelFormat            = UnityEngine.XR.WSA.WebCam.CapturePixelFormat.BGRA32;
            c.hologramOpacity        = 0;
            this.cameraParameters    = c;
            photoCapture.StartPhotoModeAsync(cameraParameters, onPhotoModeStarted);
        });
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        // Create a PhotoCapture object
        UnityEngine.XR.WSA.WebCam.PhotoCapture     photoCaptureObject = captureObject;
        UnityEngine.XR.WSA.WebCam.CameraParameters cameraParameters   = new UnityEngine.XR.WSA.WebCam.CameraParameters();
        cameraParameters.hologramOpacity        = 0.0f;
        cameraParameters.cameraResolutionWidth  = cameraResolution.width;
        cameraParameters.cameraResolutionHeight = cameraResolution.height;
        cameraParameters.pixelFormat            = UnityEngine.XR.WSA.WebCam.CapturePixelFormat.BGRA32;

        // Set up a GestureRecognizer to detect Select gestures.
        recognizer              = new UnityEngine.XR.WSA.Input.GestureRecognizer();
        recognizer.TappedEvent += (source, tapCount, ray, photoCapture) =>
        {
            // Activate the camera
            photoCapture.StartPhotoModeAsync(cameraParameters, delegate(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result) {
                // Take a picture
                photoCapture.TakePhotoAsync(OnCapturedPhotoToMemory);
            });
        };
        recognizer.StartCapturingGestures();
    }
예제 #6
0
 void OnStoppedPhotoMode(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result)
 {
     Debug.Log("Camera closed");
     photoCaptureObject.Dispose();
     photoCaptureObject = null;
 }
예제 #7
0
 void OnStoppedPhotoMode(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result)
 {
     photoCaptureObj.Dispose();
     photoCaptureObj = null;
 }
예제 #8
0
 void OnCreatedPhotoCaptureObject(UnityEngine.XR.WSA.WebCam.PhotoCapture captureObject)
 {
     photoCaptureObj = captureObject;
     photoCaptureObj.StartPhotoModeAsync(m_CameraParameters, OnStartPhotoMode);
 }
예제 #9
0
 void OnStoppedPhotoMode(UnityEngine.XR.WSA.WebCam.PhotoCapture.PhotoCaptureResult result)
 {
     photo_capture_.Dispose();
     photo_capture_ = null;
     _processing    = false;
 }