視頻數據截取中心正方形求平均值

unsigned short IrFloodManager::caculateAverageValue(unsigned short *buffer,int w,int h){
    Grayscale16Pixel* pIR = (Grayscale16Pixel*)buffer;
    QVector<int> data_index;
    int center_x=w/2;
    int center_y=h/2;
    int first_point_x=center_x-match_width/2;
    int first_point_y=center_y-match_width/2;
    int end_point_x=center_x+match_width/2;
    int end_point_y=center_y+match_width/2;
    int sum=0;
    int i=first_point_x;
    int j=first_point_y;
    for (i;i<end_point_x;i++){
        for(j;j<end_point_y;j++){
            data_index.push_back(i*j);
        }
    }
    for (int i = 0; i < data_index.size(); ++i){
        sum+=pIR[data_index.at(i)];
    }
    unsigned short m_Value = sum/data_index.size();
    qDebug("calculate IR Value : %8d\n", m_Value);

 
    return m_Value;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章