Search Unity

PhotoCapture to capture only Holograms

Discussion in 'VR' started by bestpavan, Nov 13, 2018.

  1. bestpavan

    bestpavan

    Joined:
    Nov 13, 2018
    Posts:
    1
    We are using the PhotoCapture class to take a picture. We want to capture just the holograms that are currently displayed but not the MR environment (like the room we are in and other objects in it). Is there any way to achieve it?

    Also, the photo that is being captured is blurry, is there any way to improve the quality of them?

    Following is the code I am using:

    PhotoCapture photoCaptureObject = null;
    PhotoCapture.CreateAsync(true, delegate (PhotoCapture captureObject) {
    photoCaptureObject = captureObject;
    Resolution cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
    CameraParameters c = new CameraParameters();
    c.hologramOpacity = 1.0f;
    c.cameraResolutionWidth = cameraResolution.width;
    c.cameraResolutionHeight = cameraResolution.height;
    c.pixelFormat = CapturePixelFormat.BGRA32;
    captureObject.StartPhotoModeAsync(c, delegate (PhotoCapture.PhotoCaptureResult result)
    {
    if (result.success)
    {
    string filename = string.Format(@"BlochSphereExport_{0}.jpg", Time.time);
    string filePath = System.IO.Path.Combine(Application.persistentDataPath, filename);
    photoCaptureObject.TakePhotoAsync(filePath, PhotoCaptureFileOutputFormat.JPG, delegate (PhotoCapture.PhotoCaptureResult result2)
    {
    if (result2.success)
    {
    Debug.Log("Saved Photo to disk!");
    photoCaptureObject.StopPhotoModeAsync(delegate (PhotoCapture.PhotoCaptureResult result3)
    {
    photoCaptureObject.Dispose();
    photoCaptureObject = null;
    });

    }

    else

    {

    Debug.Log("Failed to save Photo to disk");

    }

    });

    }

    else

    {

    Debug.LogError("Unable to start photo mode!");

    }

    });

    });