Analyze RGB Videostream


i’am new to OpenCV and have a general question. Is it possible to analyze the RGB values of a videostream with the OpenCV library? I found many information about converting color spaces, but nothing about reading color elements of a captured videostream.

Best regards

yes it is possible.
what do you really want to do ?

Hi berak, thank you for first information :slight_smile:
I want to build a software which analyzes an videostream and show the values of RGB as numbers in a GUI and maybe as waveform graphic too .
It should be a tool for the analyze process only, not for manipulating a videoframe.

Best regards

can you be a bit more specific (pun intended)?
a 640x480 image already has more than a million values
are looking for histograms or similar ?

what do you want to anylyze ? what are you looking for there ?
what is “the purpose of your program” ?

Yes it should be similar to a histogram visualization.
The program should show the videostream as waveform, rgb-parade and vectorscope. It should be a software for the measurement of an captured video.
For caputuring I want to use a Deck Link from Black Magic, maybe together with there SDK.

converting to HSV will give you hue & saturation info

also have a look at opencv’s (rudimentary) drawing functions

Vec3b is a vector of three elements of uint8 type.

cv::Mat somepicture; // that is hopefully CV_8UC3, the usual format
// ...
// use VideoReader to read frames into `somepicture`
// ...
Vec3b& pixel =<Vec3b>(i,j); // get a pixel (reference) from i-th row (y), j-th column (x)
// pixel[0] is blue, pixel[1] is green, pixel[2] is red
pixel[0] = 255 - pixel[0]; // invert the blue value (example)
// ...
cv::imshow("result", somepicture);

PLEASE work through the tutorials. this is the very basics of how to work with OpenCV.

there may be high level methods that might do what you need faster (recommended). if there aren’t, you’ll have to do your own looping over the pixels, or possibly use OpenCV’s parallel_for_

Thanks for your feedback. At the first moment, before I create this topic the possibilities and the documentation of OpenCV was overwhelming for me. Now I will go and work with the documentation.