No suitable user-defined conversion from "cv::Matx<double, 2, 1>" to "cv::Vec2d" exists

I have to perform the following per-element product:

out = dist * v1 * v2 / res;

where:

  • dist is a scalar (double)
  • v1, v2, v3 are cv::Vec2d (vector of 2 double)

My very easy peasy code with opencv:

 return (dist * v1).mul(v2).div(v3);

The error I got (compiling with cl.exe under VC17):

E0312	no suitable user-defined conversion from "cv::Matx<double, 2, 1>" to "cv::Vec2d" exists

Breaking down the operations, the problem is with .div, while .mul works fine.

Now, looking at the doc, I can note:

  • cv::Vec<_Tp,cn> is inherited from cv::Matx<_Tp,cn,1>, thus cv::Vec2d should be the same as cv::Matx<double,cn,1>. Am I missing something?
  • cv::Vec<_Tp,cn> is cited into the doc, but I’ve not found either the declaration of cv::Vec<_Tp,cn>::div nor a mention to it or to the per-element division operation in general. However the method does exists.

Any idea where I’m wrong and how to (easily) fix?

Side Notes

  • Cross-posted on SO
  • Issue opened on GitHub
2 Likes

undeclared crosspost:

1 Like

I didn’t find the prohibition to cross-posting in the forum guidelines. However, I’ve flag this post to be deleted if deemed inappropriate by a moderator. Thanks for the comment