Ask Your Question
1

C++ - Difference between Vec definitions [closed]

asked 2016-10-31 23:09:26 -0600

skr_robo gravatar image

updated 2016-11-01 00:58:46 -0600

berak gravatar image

What is the difference between the definitions:

1) vector<Vec4i> lines and

2) Vec4i l

I found both these in the same code here. I am wondering if there is any difference between the both? If not why use the first format which is longer?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by skr_robo
close date 2016-11-04 15:30:58.387541

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-11-01 01:12:00 -0600

berak gravatar image

1) a Vec4i is a struct holding 4 integers, you can access them using the [] operator, like in:

Vec4i l(1,2,3,4);   l[2] == 3;

2) a std::vector is a (template)container for various things.

in the houghlines example, each found line has 2 endpoints, they are kept in a Vec4i like (x1,y1, x2,y2). since the algorithm will find many lines, those are stored in a vector<Vec4i> lines, and you would access it with

lines[which_line][which_coordinate]
edit flag offensive delete link more

Comments

So, this means lines is a vector which contains Vec4i objects?

skr_robo gravatar imageskr_robo ( 2016-11-01 21:51:37 -0600 )edit

exactly !

berak gravatar imageberak ( 2016-11-02 00:42:48 -0600 )edit

Thank You so much for the help.

skr_robo gravatar imageskr_robo ( 2016-11-04 15:30:47 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-10-31 23:09:26 -0600

Seen: 421 times

Last updated: Nov 01 '16