我正在嘗試使用 OpenCV 顯示收到的 WebRTC 幀imshow()。WebRTC 將幀作為物件提供webrtc::VideoFrame,在我的情況下,我可以從中訪問webrtc::I420Buffer。現在我的問題是如何將資料轉換webrtc::I420Buffer為cv::Mat,以便我可以將其提供給imshow()?
這就是webrtc::I420Buffer看起來的定義
namespace webrtc {
// Plain I420 buffer in standard memory.
class RTC_EXPORT I420Buffer : public I420BufferInterface {
public:
...
int width() const override;
int height() const override;
const uint8_t* DataY() const override;
const uint8_t* DataU() const override;
const uint8_t* DataV() const override;
int StrideY() const override;
int StrideU() const override;
int StrideV() const override;
uint8_t* MutableDataY();
uint8_t* MutableDataU();
uint8_t* MutableDataV();
...
private:
const int width_;
const int height_;
const int stride_y_;
const int stride_u_;
const int stride_v_;
const std::unique_ptr<uint8_t, AlignedFreeDeleter> data_;
};
uj5u.com熱心網友回復:
主要問題是從 I420 顏色格式轉換為 OpenCV 使用的 BGR(或 BGRA)顏色格式。
顏色轉換的兩個不錯的選擇:
- 使用-
Note:
It seems to difficult to actually use WebRTC input stream.
The assumption is that the decoded raw video frame already exists inI420Bufferas defined in your post.
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/450170.html上一篇:numpy陣列的輪廓檢測
下一篇:影像python的對比度歸一化
