简体   繁体   中英

Accessing vec3b in a vector in opencv

vector<Vec3b> dedColors;

Could someone please explain me how I can read and write values to the variable dedColors? I need to store 3 values in each of the vector.

You do it something like this:

vector<Vec3b> dedColors;
dedColors.push_back(Vec3b(1,2,3));
dedColors.push_back(Vec3b(4,5,6));
dedColors.push_back(Vec3b(7,8,9));

Where 1,2,3 , 4,5,6 etc are the BGR values of the elements that you want to store.

You can read back like this:

unsigned char uVal = dedColors[2][1];  // reads '8'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM