close

Binarization編譯畫面

加上LP780-27,螢幕和攝影機中間無任何前景物, 此時, 隱約可以看到我的臉也會出現在螢幕上

ps. LP780-27: INFRARED PASS/VISIBLE BLOCK FILTERS

將手掌(前景物)置放於攝影機和螢幕之間, 設定二值化門檻123

Binarization.cpp

/*
 *    This method is called to copy image data from the src frame to the dest frame.
 *
 *    Depending on the value of m_bEnabled, this implementation applies a binarization or
 *    copies the image data without modifying it.
 */
bool CBinarizationFilter::transform( const DShowLib::IFrame& src, DShowLib::IFrame& dest )
{
    // Check whether the destination frame is available
    if( dest.getPtr() == 0 ) return false;

    BYTE* pIn = src.getPtr();                           // 指向影像來源
    BYTE* pOut = dest.getPtr();                       // 指向影像目的

    // Copy the member variables to the function's stack, to protect them from being
    // overwritten by parallel calls to setThreshold() etc.
    //
    // beginParamTransfer/endParamTransfer makes sure that the values from various
    // member variables are consistent, because the user of this filter must enclose
    // writing parameter access into beginParamTransfer/endParamTransfer, too.
    beginParamTransfer();
    bool enabled = m_bEnabled;
    int threshold = m_threshold;
    endParamTransfer();

    // Check whether binarization is enabled
    if( m_bEnabled )
    {
        // For each byte in the input buffer, check whether it is greater or
        // equal to the threshold.
        int bufferSize = src.getFrameType().buffersize;            // 取得影像像素長度
        while( bufferSize-- > 0 )
        {
            if( *pIn++ >= threshold )                                     // 大於所設定的門檻 = 255
            {
                *pOut++ = 255;
            }
            else
            {
                *pOut++ = 0;
            }
        }
    }
    else
    {
        // Binarization is disabled: Copy the image data without modifying it.
        memcpy( pOut, pIn, src.getFrameType().buffersize );
    }

    return true;
}

全站熱搜
創作者介紹
創作者 me1237guy 的頭像
me1237guy

天天向上

me1237guy 發表在 痞客邦 留言(0) 人氣()