/// <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); }); }); }
// 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); }
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); }); }
void OnCreatedPhotoCaptureObject(UnityEngine.XR.WSA.WebCam.PhotoCapture captureObject) { photoCaptureObj = captureObject; photoCaptureObj.StartPhotoModeAsync(m_CameraParameters, OnStartPhotoMode); }