2017-02-22 17 views
2

hololens 앱에서 사진을 캡처하려고합니다. 그것은 작동하지만 보이지 않는 곳으로 이미지를 저장하는 것 같습니다. 내 그림 라이브러리 Described here I think에 저장하고 싶습니다. 또는 hololens에 나의 사진에서 그것을 볼 수있다 그래야 나는 어디에 이미지를 저장해야 하는가.hololens의 사진 폴더에 이미지 저장

적인 filePath = C :/데이터/사용자/JanikJoe는 /의 AppData/지역/패키지/HoloToolkit-Unity_pzq3xp76mxafg/LocalState \ CapturedImage10.02831_n.jpg

filePath2 = C :/데이터/사용자 /에서 DefaultAccount /의 AppData/지역 /DevelopmentFiles/HoloToolkit-UnityVS.Debug_x86.janik/Data\CapturedImage10.02831_n.jpg

using UnityEngine; 
using UnityEngine.VR.WSA.WebCam; 
using System.Linq; 

public class PhotoCaptureFVTC : MonoBehaviour { 

UnityEngine.VR.WSA.WebCam.PhotoCapture photoCaptureObject = null; 
// Use this for initialization 
void Start() 
{ 
    Debug.Log("snap pic taken"); 
    PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated); 
} 

public void OnPhotoCaptureCreated(PhotoCapture captureObject) 
{ 
    photoCaptureObject = captureObject; 

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

    CameraParameters c = new CameraParameters(); 
    c.hologramOpacity = 0.0f; 
    c.cameraResolutionWidth = cameraResolution.width; 
    c.cameraResolutionHeight = cameraResolution.height; 
    c.pixelFormat = CapturePixelFormat.BGRA32; 

    captureObject.StartPhotoModeAsync(c, false, OnPhotoModeStarted); 
} 
void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result) 
{ 
    photoCaptureObject.Dispose(); 
    photoCaptureObject = null; 
} 

private void OnPhotoModeStarted(PhotoCapture.PhotoCaptureResult result) 
{ 
    if (result.success) 
    { 
     string filename = string.Format(@"CapturedImage{0}_n.jpg", Time.time); 
     string filePath = System.IO.Path.Combine(Application.persistentDataPath, filename); 
     string filePath2 = System.IO.Path.Combine(Application.dataPath, filename); 

     photoCaptureObject.TakePhotoAsync(filePath, PhotoCaptureFileOutputFormat.JPG, OnCapturedPhotoToDisk); 
     Debug.LogError("Saved That Image Somewhere" +"FileName: ="+ filename + " FilePath: = " + filePath + " FilePath2: = " + filePath2); 
    } 
    else 
    { 
     Debug.LogError("Unable to start photo mode!"); 
    } 
} 
void OnCapturedPhotoToDisk(PhotoCapture.PhotoCaptureResult result) 
{ 
    if (result.success) 
    { 
     Debug.Log("Saved Photo to disk!"); 
     photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode); 
    } 
    else 
    { 
     Debug.Log("Failed to save Photo to disk"); 
    } 
} 


} 

답변

3
이 카메라 롤 폴더에 직접 저장할 수 없습니다 것 같다

더 그림 라이브러리는에 없다 HoloLens.

이 여기에 같은 질문 : https://forums.hololens.com/discussion/1458/capturing-photo-in-unity-and-saving-to-disk

내가 해결 방법을 시도했다가 그것을 잘 작동합니다. 저장된 이미지를 카메라 롤 폴더로 옮기면됩니다.

#if !UNITY_EDITOR && UNITY_WINRT_10_0 
     var cameraRollFolder = Windows.Storage.KnownFolders.CameraRoll.Path;    
     File.Move(_filePath, Path.Combine(cameraRollFolder, _filename)); 
#endif