private void OnEnable() { if (link.targetCam == null) { link.targetCam = GetComponent <Camera>(); } manualCam = new ManuallyRenderCamera(link.targetCam); commander = new CameraEventRetention(manualCam.Camera); cmd = new CommandBuffer(); cap = new DepthCapture(); depthTex = new ResizableRenderTexture(new FormatRT() { textureFormat = RenderTextureFormat.Depth, depth = 24 }); depthColorTex = new ResizableRenderTexture(new FormatRT() { textureFormat = RenderTextureFormat.ARGBHalf, readWrite = RenderTextureReadWrite.Linear, depth = 0, }); pip = new PIPTexture(); currCamData = default; validator.Reset(); validator.SetCheckers(() => currCamData.Equals(link.targetCam)); validator.Validation += () => { currCamData = link.targetCam; cmd.Clear(); var size = link.targetCam.Size(); depthTex.Size = size; depthColorTex.Size = size; cmd.Clear(); cap.StepThreashold = tuner.stepThreashold; cap.Capture(cmd, depthColorTex, tuner.depthOutputMode); commander.Set(tuner.captureEvent, cmd); pip.CurrTuner = tuner.pip; pip.TargetCam = link.targetCam; }; manualCam.AfterCopyFrom += v => { manualCam.Camera.depthTextureMode = DepthTextureMode.Depth; manualCam.Camera.cullingMask = tuner.CullingMask(); }; validator.Validate(); depthTex.AfterCreateTexture += v => validator.Invalidate(); depthColorTex.AfterCreateTexture += v => { using (new RenderTextureActivator(depthColorTex)) GL.Clear(true, true, Color.white); validator.Invalidate(); }; }
IEnumerator Start() { Screen.sleepTimeout = SleepTimeout.NeverSleep; if (processRequestsInMainThread) { Application.runInBackground = true; } server = new WebServer(port, workerThreads, processRequestsInMainThread); server.logRequests = logRequests; server.HandleRequest += HandleRequest; if (startOnAwake) { server.Start(); } GameObject.Find("serveraddress").GetComponent <Text>().text = GetLocalIPAddress(); GameObject.Find("status").GetComponent <Text>().text = "Camera Filtering: " + filterSelected; GameObject.Find("status").GetComponent <Text>().color = filterSelected ? Color.green : Color.yellow; if (Application.platform == RuntimePlatform.IPhonePlayer) { capture_ = new DepthCapture(); yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); capture_.Configure(filter: filterSelected); capture_.Start(); } }
// Use this for initialization IEnumerator Start() { Debug.Log("Start"); if (Application.platform == RuntimePlatform.IPhonePlayer) { capture_ = new DepthCapture(); yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam)); capture_.Configure(); capture_.Start(); } }
private void changeFilterStatus(bool newStatus) { if (newStatus != filterSelected) { filterSelected = newStatus; if (Application.platform == RuntimePlatform.IPhonePlayer) { capture_.Stop(); capture_.Dispose(); capture_ = new DepthCapture(); capture_.Configure(filter: filterSelected); capture_.Start(); } else { System.Threading.Thread.Sleep(2000); } GameObject.Find("status").GetComponent <Text>().text = "Camera Filtering: " + filterSelected; GameObject.Find("status").GetComponent <Text>().color = filterSelected ? Color.green : Color.yellow; } }
private void OnDisable() { if (commander != null) { commander.Reset(); commander = null; } if (manualCam != null) { manualCam.Dispose(); manualCam = null; } if (cap != null) { cap.Dispose(); cap = null; } if (cmd != null) { cmd.Dispose(); cmd = null; } if (depthTex != null) { depthTex.Dispose(); depthTex = null; } if (depthColorTex != null) { depthColorTex.Dispose(); depthColorTex = null; } if (pip != null) { pip.Dispose(); pip = null; } }
public IEnumerator captureNorm() { //Create folder Directory.CreateDirectory("Assets/Animations/Animation_" + animId + "/Normal"); while (isRecording) { //capture whole screen Rect lRect = new Rect(0f, 0f, Screen.width, Screen.height); if (capturedNorm) { Destroy(capturedNorm); } yield return(new WaitForEndOfFrame()); capturedNorm = DepthCapture.capture(lRect); SaveToFile(capturedNorm, "Normal"); } animId++; }