C++ - Could use a little explanation of Vec3b in OpenCV

I ran into this 'Vec3b green(0,255,0), blue (255,0,0);' in some code I'm converting to another language. I'm new to C++ OpenCV and was wondering where it is in the Documentation, I searched everywhere and couldn't find it. I also grepped the entire OpenCV directory and found this to be the closest to a definition of it

'typedef Vec3b RGB;'

in the /home/w/Documents/opencv-master/modules/imgproc/test/test_cvtyuv.cpp file

I grepped for RGB and couldn't find a definition on that either though there was alot of output on it and I may have missed something. I'm writing a C wrapper for it is why I need to know, so far I have this to wrap the above 'Vec3b green(0,255,0)':

 Vec3b cv_create_Vec3b(const char* color, int val1, int val2, int val3) {
     return new Vec3b color (val1, val2, val3);

But gets this error:

 opencv_generated.cpp:8:22: error: expected ‘;’ before ‘color’
      return new Vec3b color (val1, val2, val3);
opencv_generated.cpp:8:45: error: ‘color’ cannot be used as a function
     return new Vec3b color (val1, val2, val3);

I, first of all, could use help, to find out how to type "color" . It just needs a variable that would be "green" or "blue" whatever is input when it ran(new to C++ kind of)..Second just if someone could point me to or tell me info on it or show me a declaration on it so I'd have enough info to write my wrapper I'd be grateful.

Thank you ^


I found how to do it n another S.O. post. pls see comments

here https://stackoverflow.com/questions/22311634/c-help-writing-function-parameters-for-c-wrappers-for-c

Vec3b* cv_create_Vec3b(int val1, int val2, int val3) {
   return new Vec3b (val1, val2, val3);

Vec3b is a type (looks like a color value to me) and "green" and "blue" are variable names. You can't store variable names in strings (obviously) and hence you can't have a function which generates these values. Also, your function is syntactically wrong. While i don't understand how you would write a c wrapper to a c++ project (if part of it is in c++, you need a c++ compiler, so what's the point?), I'd definitely recommend you to learn c++ before attempting anything with it. The syntactic possibilities are too far and wide to just learn by yourself while reading code.

EDIT: maybe try something like this?

Vec3b Green() {
    Vec3b result(0, 255, 0);
    return result;

Need Your Help

How do I determine if a value is an instance of a generic type, ignoring the type parameter, in vb.net?

vb.net generics type-parameter

I have a class C(Of T). I want to determine if some given value has type C, regardless of what T is. For example, I might want to determine if a value is a strongly-typed list, regardless what type...

Sidekiq not enqueuing jobs

ruby-on-rails ruby-on-rails-3 redis sidekiq

I am switching from delayed_jobs to sidekiq and I am having a bit of an issue with getting sidekiq to enqueue the jobs.