青岛做网站公司电话,app开发公司名字,温州商城网站建设,赣州信息网接上一篇blog#xff1a;同一路RTSP|RTMP流如何同时回调YUV和RGB数据实现渲染和算法分析-CSDN博客
我们知道#xff0c;由于解码后的YUV或RGB数据size比较大#xff0c;如果想把转换后的RGB数据传给比如python算法的话#xff0c;数据量还是挺大#xff0c;为此#xff…接上一篇blog同一路RTSP|RTMP流如何同时回调YUV和RGB数据实现渲染和算法分析-CSDN博客
我们知道由于解码后的YUV或RGB数据size比较大如果想把转换后的RGB数据传给比如python算法的话数据量还是挺大为此开发者提出这样的技术诉求是不是可以按照指定的坐标和宽高给出RGB数据毕竟他们知道哪块区域是需要做算法分析的。
针对此种情况我们的设计如下
/** SmartPlayer.cs* Author: https://daniusdk.com* WeChat: xinsheng120*/int x 100;
int y 100;
int clip_width 960;
int clip_height 540;if (x 0 || y 0)return;clip_width (int)ByteAlign((UInt32)clip_width, 2);
clip_height (int)ByteAlign((UInt32)clip_height, 2);if (x clip_width video_frame.width_ || y clip_height video_frame.height_)return;rgb_frame.format_ (int)NT.NTSmartPlayerDefine.NT_SP_E_VIDEO_FRAME_FORMAT.NT_SP_E_VIDEO_FRAME_FORMAT_ARGB;
rgb_frame.width_ clip_width;
rgb_frame.height_ clip_height;rgb_frame.timestamp_ video_frame.timestamp_;
rgb_frame.stride0_ clip_width * 4;
rgb_frame.stride1_ 0;
rgb_frame.stride2_ 0;
rgb_frame.stride3_ 0;Int32 argb_size rgb_frame.stride0_ * rgb_frame.height_;rgb_frame.plane0_ Marshal.AllocHGlobal(argb_size);IntPtr in_plane0 video_frame.plane0_ video_frame.stride0_ * y x;
IntPtr in_plane1 video_frame.plane1_ video_frame.stride1_ * (y / 2) (x / 2);
IntPtr in_plane2 video_frame.plane2_ video_frame.stride2_ * (y / 2) (x / 2);NTSmartPlayerSDK.NT_SP_I420ToARGB(in_plane0, video_frame.stride0_, in_plane1, video_frame.stride1_, in_plane2, video_frame.stride2_,rgb_frame.plane0_, rgb_frame.stride0_, clip_width, clip_height);
比如我们需要截取的坐标x 100, y 100, 宽 960 高 540那么处理后的数据展示出来效果如右图 左侧是原始的2560*1440的右侧是按设定坐标截取960*540分辨率的数据播放的右侧的数据投递给python或其他视觉算法处理效率会显著提升。
以上是回调YUV数据的同时按照用户使用场景截取指定坐标和分辨率的RGB数据的设计参考。感兴趣的开发者可以单独跟我沟通探讨。