Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by GregPD65356T · Mar 28, 2018 at 05:39 PM · augmented realitycallbackcaptureemulatorphoto

Microsoft HoloLens Emulator - Callback for PhotoCapture.CreateAsync not being called

I want to add to this HoloLens app, under a NDA, the ability to take photos with the holograms. A more general example can be a photo of someone with a holographic model of the One World Trade Center sitting on the viewer's desk.

For some reason, after doing some debugging, I am noticing that the callback function I've passed in as the second argument of PhotoCapture.CreateAsync is not being called at all. Not even after 10 seconds once this function is called.

The package.appxmanifest file of this UWP app I'm deploying to the HoloLens after building it from Unity does have DeviceCapability tags to use both the webcam and the microphone on the HoloLens itself, including the one in the emulator.

Since this project is under a non-disclosure agreement, unfortunately I can't share a code snippet at all.

Why is the callback not being called at all? Also, as I'm new to this, what am I supposed to do?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KDamen · Mar 29, 2018 at 11:07 AM

Hello @GregPD65356T,

I have some experise with programming with the HoloLens. I ones tested the webcam of the HoloLens, using a script that set the photo as texture of an object.

But the emulator has no webcam, so this must be tested on the HoloLens.

 using UnityEngine;
 using System.Linq;
 using UnityEngine.XR.WSA.WebCam;
 
 public class WebcamToTexture : MonoBehaviour
 {
     PhotoCapture photoCaptureObject = null;
 
     // Use this for initialization
     void Start()
     {
         PhotoCapture.CreateAsync(false, OnPhotoCaptureCreated);
     }
 
     void OnPhotoCaptureCreated( PhotoCapture captureObject )
     {
         photoCaptureObject = captureObject;
 
         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, OnPhotoModeStarted);
     }
 
     void OnStoppedPhotoMode( PhotoCapture.PhotoCaptureResult result )
     {
         photoCaptureObject.Dispose();
         photoCaptureObject = null;
     }
 
     private void OnPhotoModeStarted( PhotoCapture.PhotoCaptureResult result )
     {
         if (result.success) {
             photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory);
         } else {
             Debug.LogError("Unable to start photo mode!");
         }
     }
 
     void OnCapturedPhotoToMemory( PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame photoCaptureFrame )
     {
         if (result.success) {
             // Create our Texture2D for use and set the correct resolution
             Resolution cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res ) => res.width * res.height).First();
             Texture2D targetTexture = new Texture2D(cameraResolution.width, cameraResolution.height);
             // Copy the raw image data into our target texture
             photoCaptureFrame.UploadImageDataToTexture(targetTexture);
             // Do as we wish with the texture such as apply it to a material, etc.
             gameObject.GetComponent<Renderer>().material.mainTexture = targetTexture; 
         }
         // Clean up
         photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode);
     }
 }

Hope it helps you.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GregPD65356T · Mar 29, 2018 at 01:03 PM 0
Share

That's so weird having to learn that the virtual HoloLens in the emulator does not have a virtual webcam of its own. I don't quite understand why it's not included in the emulator to begin with, since it would be so useful for development-level testing.

avatar image KDamen GregPD65356T · Mar 29, 2018 at 01:22 PM 0
Share

$$anonymous$$aybe it's posible to test this particular feature inside Unity itself. Unity can use the webcam of the PC to make pictures.

Is this a possibility?

avatar image GregPD65356T KDamen · Mar 29, 2018 at 01:31 PM 0
Share

With my current project setup, when I click on the Play button, the editor crashes. What I got is a couple of scripts: one responsible for interaction sources, and one for gestures. The Unity editor itself does not have the plugins, I think, to handle it.

Show more comments
Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

132 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting manual focus on UWP device camera 0 Answers

how to run ARCore Instant Preview on Android emulator? 0 Answers

How do you take multiple photos using Webcamtexture and rotate it to show it as smartphone rotation? 0 Answers

Coroutine from Callback doesn't handle yield returns. 2 Answers

keyboard input (num pad) when unity does not have focus 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges