void Start() { Application.targetFrameRate = 60; m_RuntimeModel = ModelLoader.Load(inputModel, false); m_Worker = WorkerFactory.CreateWorker(WorkerFactory.Type.ComputePrecompiled, m_RuntimeModel, false); #if (WEBCAM) #if UNITY_WSA Resolution cameraResolution = VideoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First(); Debug.Log(cameraResolution); float cameraFramerate = VideoCapture.GetSupportedFrameRatesForResolution(cameraResolution).OrderByDescending((fps) => fps).First(); Debug.Log(cameraFramerate); VideoCapture.CreateAsync(false, delegate(VideoCapture videoCapture) { if (videoCapture != null) { m_VideoCapture = videoCapture; //Debug.Log("Created VideoCapture Instance!"); CameraParameters cameraParameters = new CameraParameters(); cameraParameters.hologramOpacity = 0.0f; cameraParameters.frameRate = cameraFramerate; cameraParameters.cameraResolutionWidth = cameraResolution.width; cameraParameters.cameraResolutionHeight = cameraResolution.height; cameraParameters.pixelFormat = CapturePixelFormat.BGRA32; m_VideoCapture.StartVideoModeAsync(cameraParameters, VideoCapture.AudioState.ApplicationAndMicAudio, OnStartedVideoCaptureMode); } else { Debug.LogError("Failed to create VideoCapture Instance!"); } }); #else m_WebcamTexture = new WebCamTexture(); m_WebcamTexture.Play(); #endif #else var targetRT = RenderTexture.GetTemporary(inputResolutionX, inputResolutionY, 0); Graphics.Blit(inputImage, targetRT, postprocessMaterial); m_Input = new Tensor(targetRT, 3); //m_Input = new Tensor(1, inputResolutionY, inputResolutionX, 3); #endif }
private static void InvokeOnVideoModeStoppedDelegate(VideoCapture.OnVideoModeStoppedCallback callback, long hResult) { callback(VideoCapture.MakeCaptureResult(hResult)); }
private static void InvokeOnStoppedRecordingVideoToDiskDelegate(VideoCapture.OnStoppedRecordingVideoCallback callback, long hResult) { callback(VideoCapture.MakeCaptureResult(hResult)); }
public static IEnumerable <float> GetSupportedFrameRatesForResolution(Resolution resolution) { return(VideoCapture.GetSupportedFrameRatesForResolution_Internal(resolution.width, resolution.height)); }