Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

How do i get the average red, green and blue from an ofVideoPlayer?

$
0
0

@howdy wrote:

Im using this:

ofPixels & pixels = movie.getPixels();
    
    int vidWidth = pixels.getWidth();
    int vidHeight = pixels.getHeight();
    int nChannels = pixels.getNumChannels();
    int allRed = 0;
    int allGreen = 0;
    int allBlue = 0;
    
    for(int i = 0; i<vidWidth; i++){
        for(int j = 0; j<vidHeight; j++){
            allRed = allRed + pixels[(j*vidWidth+i)*nChannels];
            allGreen = allGreen + pixels[(j*vidWidth+i)*nChannels+1];
            allBlue = allBlue + pixels[(j*vidWidth+i)*nChannels+2];
    }
    }
    int avgRed = allRed/(vidHeight*vidWidth);
    int avgGreen = allGreen/(vidHeight*vidWidth);
    int avgBlue = allBlue/(vidHeight*vidWidth);

Still not getting the expected values

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles