Ask Your Question
0

Reference of e.g. Vec::all

asked 2012-11-03 21:26:50 -0600

cg gravatar image

Hi there!

I'm rather new to programming in general, just did a small Qt project recently. I am now looking into openCV. Very recently I was trying to look up the function Vec::all (as used in Scalar::all).

To my surprise, the official documentation (http://opencv.willowgarage.com/documentation/cpp/core_basic_structures.html?highlight=vec) just says

template<typename T, int cn> class Vec : public Matx<T, cn, 1>
{
public:
    typedef T value_type;
    enum { depth = DataDepth<T>::value, channels = cn,
           type = CV_MAKETYPE(depth, channels) };

    **// various methods ...**
};

typedef Vec<uchar, 2> Vec2b
...

So it is hidden under various methods. I dug up an old looking pdf where I could actually read:

// constructs vector with all the components set to alpha.
static Vec all(_Tp alpha);

But, as I said, the pdf looks old and I just googled it. Isn't there an official documentation? Or am I supposed to look into the source code itself? I actually did find the line

static Vec all(_Tp alpha);

in 'core.hpp', but without any comments, so the old pdf was even more helpful.

Any help will be appreciated, thanks! Chris

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-11-06 17:31:09 -0600

SR gravatar image

updated 2012-11-13 12:27:03 -0600

try

// if that's the type
typedef Vec<uchar, 2> Vec2b;

// you get a vector containing all elements set to 5.
Vec2b v = Vec2b::all(5);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-11-03 21:26:50 -0600

Seen: 343 times

Last updated: Nov 13 '12