Ejemplo n.º 1
0
 /// <summary>
 /// Convert video frame to <paramref name="dstFormat"/> with Bgr24 mat
 /// <para>
 /// NOTE: only support CV_8U3 Mat!!
 /// </para>
 /// </summary>
 /// <param name="mat">must bge format</param>
 /// <param name="dstFormat">video frame format</param>
 /// <returns></returns>
 public static VideoFrame ToVideoFrame(this Mat mat, AVPixelFormat dstFormat = AVPixelFormat.AV_PIX_FMT_BGR24)
 {
     if (dstFormat != AVPixelFormat.AV_PIX_FMT_BGR24)
     {
         using (PixelConverter converter = new PixelConverter(dstFormat, mat.Width, mat.Height))
         {
             return(converter.ConvertFrame(MatToVideoFrame(mat)));
         }
     }
     return(MatToVideoFrame(mat));
 }
Ejemplo n.º 2
0
 private static Mat VideoFrameToMat(VideoFrame frame)
 {
     if ((AVPixelFormat)frame.AVFrame.format != AVPixelFormat.AV_PIX_FMT_BGRA)
     {
         using (VideoFrame dstFrame = new VideoFrame(AVPixelFormat.AV_PIX_FMT_BGRA, frame.AVFrame.width, frame.AVFrame.height))
             using (PixelConverter converter = new PixelConverter(dstFrame))
             {
                 return(BgraToMat(converter.ConvertFrame(frame)));
             }
     }
     return(BgraToMat(frame));
 }