void OnRenderObject() { if (_lastFrameCount != Time.frameCount) { _lastFrameCount = Time.frameCount; if (_device != null) { _device.Update(false); } } }
private void UpdateCameras() { // Update all cameras int numDevices = AVProLiveCameraManager.Instance.NumDevices; for (int i = 0; i < numDevices; i++) { AVProLiveCameraDevice device = AVProLiveCameraManager.Instance.GetDevice(i); // Update the actual image device.Update(false); } }
// Update is called once per frame /* private void Update(){ * deviceL = AVProLiveCameraManager.Instance.GetDevice(deviceNameL); * // deviceR = AVProLiveCameraManager.Instance.GetDevice(deviceNameR); * deviceL.Update(false); * // deviceR.Update(false); * mrL.material.mainTexture = AVProLiveCameraManager.Instance.GetDevice(deviceNameL).OutputTexture; * // mrR.material.mainTexture = AVProLiveCameraManager.Instance.GetDevice(deviceNameR).OutputTexture; * * RenderTexture.active = (RenderTexture)mrL.material.mainTexture; * texL.ReadPixels (new UnityEngine.Rect(0, 0, FRAME_WIDTH, FRAME_HEIGHT), 0, 0); * oriImageL = Texture2dToImage<Bgr, byte> (texL, true); * * * //RenderTexture.active = (RenderTexture)mrR.material.mainTexture; * //texR.ReadPixels (new UnityEngine.Rect(0, 0, FRAME_WIDTH, FRAME_HEIGHT), 0, 0); * //oriImageR = Texture2dToImage<Bgr, byte> (texR, true); * * * CvInvoke.Undistort (oriImageL, resImageL, Camera_Matrix, Distortion_Coefficients); * // CvInvoke.Undistort (oriImageR, resImageR, Camera_Matrix, Distortion_Coefficients); * CvInvoke.Imshow("Left image", resImageL); //Show the image * // CvInvoke.Imshow("Right image", resImageR); //Show the image * }*/ private void UpdateCameraL() { while (true) { Debug.Log("KAD"); deviceL = AVProLiveCameraManager.Instance.GetDevice(deviceNameL); deviceL.Update(false); mrL.material.mainTexture = AVProLiveCameraManager.Instance.GetDevice(deviceNameL).OutputTexture; RenderTexture.active = (RenderTexture)mrL.material.mainTexture; texL.ReadPixels(new UnityEngine.Rect(0, 0, FRAME_WIDTH, FRAME_HEIGHT), 0, 0); oriImageL = Texture2dToImage <Bgr, byte> (texL, true); CvInvoke.Undistort(oriImageL, resImageL, Camera_Matrix, Distortion_Coefficients); CvInvoke.Imshow("Left image", resImageL); //Show the image } }
private void UpdateCameras() { // Update all cameras /*int numDevices = AVProLiveCameraManager.Instance.NumDevices; * //Debug.Log (numDevices); * for (int i = 0; i < numDevices; i++) * { * AVProLiveCameraDevice device = AVProLiveCameraManager.Instance.GetDevice(i); * * // Update the actual image * device.Update(false); * }*/ AVProLiveCameraDevice device = AVProLiveCameraManager.Instance.GetDevice(deviceName); device.Update(false); mr.material.mainTexture = AVProLiveCameraManager.Instance.GetDevice(deviceName).OutputTexture; }
private void UpdateCameras() { device = AVProLiveCameraManager.Instance.GetDevice(deviceName); device.Update(false); mr.material.mainTexture = AVProLiveCameraManager.Instance.GetDevice(deviceName).OutputTexture; was = RenderTexture.active; RenderTexture.active = (RenderTexture)mr.material.mainTexture; tex.ReadPixels(new UnityEngine.Rect(0, 0, FRAME_WIDTH, FRAME_HEIGHT), 0, 0); tex.Apply(); RenderTexture.active = was; /* oriImage = Texture2dToMat (tex);*/ oriImage = Texture2dToImage <Bgr, byte> (tex, true); CvInvoke.Undistort(oriImage, resImage, Camera_Matrix, Distortion_Coefficients); // mr.material.mainTexture = (Texture)ImageToTexture2D(resImage, true); Image <Hsv, Byte> hsv_image = resImage.Convert <Hsv, Byte>(); // Change the HSV value here Hsv hsvmin = new Hsv(H_MIN, S_MIN, V_MIN); Hsv hsvmax = new Hsv(H_MAX, S_MAX, V_MAX); hsv_image = hsv_image.SmoothGaussian(5, 5, 0.1, 0.1); Image <Gray, byte> red_object = hsv_image.InRange(hsvmin, hsvmax); red_object = red_object.Erode(1); red_object = red_object.Dilate(1); CvInvoke.FindNonZero(red_object, nonZeroCoordinates); avgPixelIntensity = CvInvoke.Mean(nonZeroCoordinates); // Debug.Log (avgPixelIntensity.V1); CvInvoke.Imshow("Left image", red_object); //Show the image // CvInvoke.WaitKey(30); diff = 0; if (nonZeroCoordinates.Rows > 1000) { diff = (int)(avgPixelIntensity.V1 - (double)(FRAME_HEIGHT / 2)); //ArduinoSerialHandlerLeft.value0 = diff; } }
private void UpdateCameras() { { #if UNITY_5_4_OR_NEWER || (UNITY_5 && !UNITY_5_0 && !UNITY_5_1) GL.IssuePluginEvent(AVProLiveCameraPlugin.GetRenderEventFunc(), AVProLiveCameraPlugin.PluginID | (int)AVProLiveCameraPlugin.PluginEvent.UpdateAllTextures); #else GL.IssuePluginEvent(AVProLiveCameraPlugin.PluginID | (int)AVProLiveCameraPlugin.PluginEvent.UpdateAllTextures); #endif } // Update all cameras int numDevices = AVProLiveCameraManager.Instance.NumDevices; for (int i = 0; i < numDevices; i++) { AVProLiveCameraDevice device = AVProLiveCameraManager.Instance.GetDevice(i); // Update the actual image device.Update(false); device.Render(); } }