Writing vector in OpenCV

15,084

Solution 1

vector<Vec4i> line;

line.push_back(Vec4i(1,2,3,4));
line.push_back(Vec4i(5,6,7,8));

Solution 2

see dis: http://opencv.willowgarage.com/documentation/cpp/basic_structures.html#vec .

typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;

typedef Vec<short, 2> Vec2s;
typedef Vec<short, 3> Vec3s;
typedef Vec<short, 4> Vec4s;

typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;

typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
typedef Vec<float, 4> Vec4f;


typedef Vec<float, 6> Vec6f;

typedef Vec<double, 2> Vec2d;
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;

now you know !

Share:
15,084
user2148843
Author by

user2148843

Updated on June 04, 2022

Comments

  • user2148843
    user2148843 almost 2 years

    How do you write a vector in OpenCV? Using HoughlinesP, the lines are of type Vector<Vec4i> and holds values [x1,y1,x2,y2]. How do I make my own vector? I tried

    vector<Vec4i> line;
    

    line[0] = [1,2,3,4];

    and it doesn't work with the error 'expected an identifier. Please advice, thank you.

  • user2148843
    user2148843 about 11 years
    what if I want to write it into a particular array say line[1]?
  • berak
    berak about 11 years
    you mean: vector<Vec4i> line(100); /*line has 100 Vec4i now*/ line[1] = Vec4i(6,5,4,3); ? for more on vectors, have a look at cplusplus.com/reference
  • HDJEMAI
    HDJEMAI over 8 years