簡體   English   中英

使用ffplay或ffmpeg如何獲取幀中像素的rgb值

[英]Using ffplay or ffmpeg how can I get a pixel's rgb value in a frame

我想在使用ffmpeg解碼的每一幀中提取像素的rgb值。 我調查了ffplay源代碼

get_video_frame
video_refresh
queue_picture

我嘗試了以上三種方法掛接到幀上,但是我不明白如何獲取像素的rgb值。 任何人都可以對此提出一些建議

http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=805

多數民眾贊成在源,這是我使用的轉換源,它按預期工作。 希望這可以幫助某人

ColorRGB GetRGBPixel(const AVFrame& frame, int x, int y)
{
    // Y component
    const unsigned char y = frame.data[0][frame.linesize[0]*y + x];

    // U, V components 
    x /= 2;
    y /= 2;
    const unsigned char u = frame.data[1][frame.linesize[1]*y + x];
    const unsigned char v = frame.data[2][frame.linesize[2]*y + x];

    // RGB conversion
    const unsigned char r = y + 1.402*(v-128);
    const unsigned char g = y - 0.344*(u-128) - 0.714*(v-128);
    const unsigned char b = y + 1.772*(u-128);

    return ColorRGB(r, g, b);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM