Example #1
0
        // Use this for initialization
        void Start()
        {
            capture = new UnityEngine.XR.WSA.WebCam.VideoCapture();

            #if UNITY_WEBGL && !UNITY_EDITOR
            StartCoroutine(Utils.getFilePathAsync(fileName, (result) => {
                capture.open(result);
                Init();
            }));
            #else
            capture.open(Utils.getFilePath(fileName));
            Init();
            #endif
        }
Example #2
0
        private void PlayVideo(string filePath)
        {
            if (isPlaying || isRecording)
            {
                return;
            }

            capture = new UnityEngine.XR.WSA.WebCam.VideoCapture();
            capture.open(filePath);

            if (!capture.isOpened())
            {
                Debug.LogError("capture.isOpened() is false. ");
                capture.release();
                return;
            }

            Debug.Log("CAP_PROP_FORMAT: " + capture.get(Videoio.CAP_PROP_FORMAT));
            Debug.Log("CV_CAP_PROP_PREVIEW_FORMAT: " + capture.get(Videoio.CV_CAP_PROP_PREVIEW_FORMAT));
            Debug.Log("CAP_PROP_POS_MSEC: " + capture.get(Videoio.CAP_PROP_POS_MSEC));
            Debug.Log("CAP_PROP_POS_FRAMES: " + capture.get(Videoio.CAP_PROP_POS_FRAMES));
            Debug.Log("CAP_PROP_POS_AVI_RATIO: " + capture.get(Videoio.CAP_PROP_POS_AVI_RATIO));
            Debug.Log("CAP_PROP_FRAME_COUNT: " + capture.get(Videoio.CAP_PROP_FRAME_COUNT));
            Debug.Log("CAP_PROP_FPS: " + capture.get(Videoio.CAP_PROP_FPS));
            Debug.Log("CAP_PROP_FRAME_WIDTH: " + capture.get(Videoio.CAP_PROP_FRAME_WIDTH));
            Debug.Log("CAP_PROP_FRAME_HEIGHT: " + capture.get(Videoio.CAP_PROP_FRAME_HEIGHT));
            double ext = capture.get(Videoio.CAP_PROP_FOURCC);

            Debug.Log("CAP_PROP_FOURCC: " + (char)((int)ext & 0XFF) + (char)(((int)ext & 0XFF00) >> 8) + (char)(((int)ext & 0XFF0000) >> 16) + (char)(((int)ext & 0XFF000000) >> 24));

            capture.grab();
            previewRgbMat = new Mat();
            capture.retrieve(previewRgbMat, 0);
            int frameWidth  = previewRgbMat.cols();
            int frameHeight = previewRgbMat.rows();

            previewColors  = new Color32[frameWidth * frameHeight];
            previrwTexture = new Texture2D(frameWidth, frameHeight, TextureFormat.RGB24, false);

            capture.set(Videoio.CAP_PROP_POS_FRAMES, 0);

            previewPanel.texture = previrwTexture;

            isPlaying = true;
        }
Example #3
0
        // Use this for initialization
        void Start()
        {
            capture = new UnityEngine.XR.WSA.WebCam.VideoCapture();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = Utils.getFilePathAsync("768x576_mjpeg.mjpeg", (result) => {
                coroutines.Clear();

                capture.open(result);
                Initialize();
            });
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            capture.open(Utils.getFilePath("768x576_mjpeg.mjpeg"));
            Initialize();
            #endif
        }