subtraction of point2f vectors

asked 2018-11-17 09:00:57 -0500

viohh gravatar image

updated 2018-11-17 09:04:11 -0500

I get features from goodFeaturesToTrack. Then I use Lucas-Kanade optiacal flow to get new vector. To subtruct two vectors(current and previous) I use: Mat dist = Mat(features_next) - Mat(features_prev);. сout<<dist<<endl; send me something like this:

[-8.173645, 1.7280884;
 -9.0476074, 1.3460178;
 -8.053894, 1.6729126;
 -8.3344727, 1.5041504;
 -8.4681396, 1.2983398;
 -7.7624168, 1.3024292;
 -7.5558472, 1.5894165;
 -6.0166016, -6.3443604;
 -8.6588135, 1.4471436;
 -8.5440674, 1.5252075;
 -8.5332642, 1.2217712;
 -9.019043, 1.1412964;
 -8.1793213, 1.1274414;
 -8.4523926, 1.3099365;
 -8.0050659, 1.4452515;
 -7.769989, 1.5503235;
 -8.8361816, 1.4925537;
 -8.8579407, 1.8752441;
 -7.7745361, 1.0702209;
 -7.8722687, 1.7235107]

What is this? Where are my coordinates? Is there another way to subtract them?

edit retag flag offensive close merge delete

Comments

that's the difference Mat. what did you expect ?

berak gravatar imageberak ( 2018-11-17 09:10:04 -0500 )edit

But why aren't they whole numbers?

viohh gravatar imageviohh ( 2018-11-17 09:30:51 -0500 )edit

Point2f == float coords ;)

(it's all entirely correct !)

so, why did you expect integers, and why is it a problem ?

berak gravatar imageberak ( 2018-11-17 09:40:22 -0500 )edit

I don't get it. How the coordinates work? Aren't they just numbers of pixels of the photo?

viohh gravatar imageviohh ( 2018-11-17 09:53:01 -0500 )edit

think of it like this: 3.6 is between 3 and 4, but slightly closer to 4 ;)

it's called: "subpixel accuracy", btw.

berak gravatar imageberak ( 2018-11-17 09:55:59 -0500 )edit

Interesting, thank you!

viohh gravatar imageviohh ( 2018-11-17 10:07:31 -0500 )edit