protected override void UpdateTexture()
        {
            cameraSource.CaptureFrame(frameMatrix);

            if (applyComicFilterToggle.isOn)
            {
                comicFilter.Process(frameMatrix, frameMatrix);
            }

            Imgproc.putText(frameMatrix, "[NatCam With OpenCVForUnity Example]", new Point(5, frameMatrix.rows() - 50), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
            Imgproc.putText(frameMatrix, "- Integration With NatShare Example", new Point(5, frameMatrix.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
            // Convert to Texture2D
            Utils.fastMatToTexture2D(frameMatrix, texture, true, 0, false);
        }
예제 #2
0
        // Update is called once per frame
        void Update()
        {
            updateCount++;
            elapsed += Time.deltaTime;
            if (elapsed >= 1f)
            {
                updateFPS    = updateCount / elapsed;
                onFrameFPS   = onFrameCount / elapsed;
                drawFPS      = drawCount / elapsed;
                updateCount  = 0;
                onFrameCount = 0;
                drawCount    = 0;
                elapsed      = 0;

                Debug.Log("didUpdateThisFrame: " + didUpdateThisFrame + " updateFPS: " + updateFPS + " onFrameFPS: " + onFrameFPS + " drawFPS: " + drawFPS);
                if (fpsMonitor != null)
                {
                    fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                    fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));

                    if (matrix != null)
                    {
                        fpsMonitor.Add("width", matrix.width().ToString());
                        fpsMonitor.Add("height", matrix.height().ToString());
                    }
                    fpsMonitor.Add("orientation", Screen.orientation.ToString());
                }
            }

            if (NatCam.IsPlaying && didUpdateThisFrame)
            {
                drawCount++;

                Mat matrix = GetMat();

                if (matrix != null)
                {
                    comicFilter.Process(matrix, matrix);

                    Imgproc.putText(matrix, "[NatCam With OpenCVForUnity Example]", new Point(5, matrix.rows() - 50), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
                    Imgproc.putText(matrix, "- Integration With NatShare Example", new Point(5, matrix.rows() - 10), Core.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);

                    // Restore the coordinate system of the image by OpenCV's Flip function.
                    Utils.fastMatToTexture2D(matrix, texture, true, 0, false);
                }
            }
        }
예제 #3
0
        protected override void UpdateTexture()
        {
            cameraSource.CaptureFrame(frameMatrix);

            if (applyComicFilterToggle.isOn)
            {
                comicFilter.Process(frameMatrix, frameMatrix);
            }

            textPos.x = 5;
            textPos.y = frameMatrix.rows() - 50;
            Imgproc.putText(frameMatrix, exampleTitle, textPos, Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, textColor, 1, Imgproc.LINE_AA, false);
            textPos.y = frameMatrix.rows() - 30;
            Imgproc.putText(frameMatrix, exampleSceneTitle, textPos, Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, textColor, 1, Imgproc.LINE_AA, false);
            textPos.y = frameMatrix.rows() - 10;
            Imgproc.putText(frameMatrix, settingInfo1, textPos, Imgproc.FONT_HERSHEY_SIMPLEX, 0.5, textColor, 1, Imgproc.LINE_AA, false);

            // Convert to Texture2D
            Utils.fastMatToTexture2D(frameMatrix, texture, true, 0, false);
        }