/// <summary>
 /// Get single camera frame in OpenCV Mat format.
 /// Mat will have WebCamTexture's dimensions and MatType of CV_8UC4.
 /// </summary>
 /// <param name="webTex">WebCamTexture from which Texture2D will be created.</param>
 /// <param name="tex">Mat into which WebCamTexture contents will be copied. Will be resized to fit.</param>
 public static void GetWebCamMat(WebCamTexture webTex, ref Mat mat)
 {
     if (webTex.isPlaying)
     {
         CvConvert.WebCamTextureToMat(webTex, ref mat);
     }
 }
Exemple #2
0
 /// <summary>
 /// Get single camera frame in OpenCV Mat format.
 /// Mat will have WebCamTexture's dimensions and MatType of CV_8UC4.
 /// </summary>
 /// <param name="webTex">WebCamTexture from which Texture2D will be created.</param>
 /// <param name="tex">Mat into which WebCamTexture contents will be copied. Will be resized to fit.</param>
 public static void GetWebCamMat(WebCamTexture webTex, ref Mat mat)
 {
     if (webTex.isPlaying)
     {
         if (mat.Height != webTex.width || mat.Width != webTex.height || mat.Type() != MatType.CV_8UC4)
         {
             mat = new Mat(webTex.height, webTex.width, MatType.CV_8UC4);
         }
         CvConvert.WebCamTextureToMat(webTex, ref mat);
     }
 }
        /// <summary>
        /// Gets single camera frame in Texture2D format.
        /// Texture2D will have WebCamTexture's dimension and TextureFormat of RGBA32.
        /// </summary>
        /// <param name="webTex">WebCamTexture from which Texture2D will be created.</param>
        /// <param name="tex">Texture2D into which WebCamTexture contents will be copied. Will be resized to fit.</param>
        public static void GetWebCamTexture2D(WebCamTexture webTex, ref Texture2D tex)
        {
            if (webTex.isPlaying)
            {
                if (tex.width != webTex.width || tex.height != webTex.height ||
                    tex.format != TextureFormat.RGBA32)
                {
                    tex.Resize(webTex.width, webTex.height, TextureFormat.RGBA32, false);
                }

                CvConvert.WebCamTextureToTexture2D(webTex, ref tex);
            }
        }