Example #1
0
 void OnFrame()
 {
     // Capture the preview frame
     deviceCamera.CaptureFrame(buffer);
     // Convert to greyscale
     ConvertToGrey(buffer);
     // Fill the texture with the greys
     texture.LoadRawTextureData(buffer);
     texture.Apply();
 }
        /// <summary>
        /// Gets the mat of the current frame.
        /// The Mat object's type is 'CV_8UC4' (RGBA).
        /// </summary>
        /// <returns>The mat of the current frame.</returns>
        public override Mat GetMat()
        {
            if (!hasInitDone || !natCamDeviceCamera.IsRunning || pixelBuffer == null)
            {
                return((rotatedFrameMat != null) ? rotatedFrameMat : frameMat);
            }

            // Set `flip` flag to true because OpenCV uses inverted Y-coordinate system
            natCamDeviceCamera.CaptureFrame(pixelBuffer);
            Utils.copyToMat(pixelBuffer, frameMat);

            FlipMat(frameMat, flipVertical, flipHorizontal);
            if (rotatedFrameMat != null)
            {
                Core.rotate(frameMat, rotatedFrameMat, Core.ROTATE_90_CLOCKWISE);
                return(rotatedFrameMat);
            }
            else
            {
                return(frameMat);
            }
        }
Example #3
0
 public void CaptureFrame(Mat matrix)
 {
     camera.CaptureFrame(sourceBuffer);
     Utils.copyToMat(sourceBuffer, matrix);
     Core.flip(matrix, matrix, 0);
 }