Capture
2 TopicsUnity3d & MRTK open Hololens 2 camera on button click and display the image in the Untiy scene after
As described in the title I have a scene wich contains a button. I attached a script with the code you see below to a ```PhotoManager``` GameObject. The button runs ```TakePhoto()``` from the script below when the button gets pressed. I expected that when you click the button, the HoloLens will open the camera and you can take a picture. Once the picture has been taken, the user should see it in the scene. However, nothing happens when you click the button... When i run the scene in unity and press the button in the game window i'm getting this error: ```InvalidOperationException: Sequence contains no elements```. (I dont have a webcam connected to my computer) The code is form the https://docs.unity3d.com/2018.4/Documentation/Manual/windowsholographic-photocapture.html. using UnityEngine; using System.Collections; using System.Linq; using UnityEngine.Windows.WebCam; public class PhotoCaptureExample : MonoBehaviour { PhotoCapture photoCaptureObject = null; Texture2D targetTexture = null; // Use this for initialization public void TakePhoto() { Resolution cameraResolution = PhotoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First(); targetTexture = new Texture2D(cameraResolution.width, cameraResolution.height); // Create a PhotoCapture object PhotoCapture.CreateAsync(false, delegate (PhotoCapture captureObject) { photoCaptureObject = captureObject; CameraParameters cameraParameters = new CameraParameters(); cameraParameters.hologramOpacity = 0.0f; cameraParameters.cameraResolutionWidth = cameraResolution.width; cameraParameters.cameraResolutionHeight = cameraResolution.height; cameraParameters.pixelFormat = CapturePixelFormat.BGRA32; // Activate the camera photoCaptureObject.StartPhotoModeAsync(cameraParameters, delegate (PhotoCapture.PhotoCaptureResult result) { // Take a picture photoCaptureObject.TakePhotoAsync(OnCapturedPhotoToMemory); }); }); } void OnCapturedPhotoToMemory(PhotoCapture.PhotoCaptureResult result, PhotoCaptureFrame photoCaptureFrame) { // Copy the raw image data into the target texture photoCaptureFrame.UploadImageDataToTexture(targetTexture); // Create a GameObject to which the texture can be applied GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad); Renderer quadRenderer = quad.GetComponent<Renderer>() as Renderer; quadRenderer.material = new Material(Shader.Find("Custom/Unlit/UnlitTexture")); quad.transform.parent = this.transform; quad.transform.localPosition = new Vector3(0.0f, 0.0f, 3.0f); quadRenderer.material.SetTexture("_MainTex", targetTexture); // Deactivate the camera photoCaptureObject.StopPhotoModeAsync(OnStoppedPhotoMode); } void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result) { // Shutdown the photo capture resource photoCaptureObject.Dispose(); photoCaptureObject = null; } }1.9KViews0likes0CommentsHow is Smart Copy able to capture both screenshot and meta data at the same time with only 1 copy?
I'm trying this on Edge Version 89.0.722.0 (Official build) canary (64-bit) I use Smart Copy to capture a part of a web page, then I paste it into Notepad and I get meta data like texts. then without copying anything else to the clipboard, I open up Paint 3D and do another paste there, this time I get the picture of that part of the web page I captured using Smart Copy! how is this even possible? 1 copy task and 2 different outputs? when I use Smart Copy and then press Win + V to view the clipboard, I only see text, not picture, but after pressing Ctrl + V in Paint 3D i get the picture and after pressing Ctrl + V in Notepad I get text. I'm not complaining though, this is actually very brilliant and smart.1.6KViews3likes5Comments