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

**URL:** <https://forum.opencv.org/t/no-suitable-user-defined-conversion-from-cv-matx-double-2-1-to-cv-vec2d-exists/11537>\
**Category:** C++\
**Tags:** core\
**Created:** [January 8, 2023, 8:21pm UTC](https://forum.opencv.org/t/no-suitable-user-defined-conversion-from-cv-matx-double-2-1-to-cv-vec2d-exists/11537 "2023-01-08T20:21:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [January 8, 2023, 8:21pm UTC](https://forum.opencv.org/t/no-suitable-user-defined-conversion-from-cv-matx-double-2-1-to-cv-vec2d-exists/11537/1 "2023-01-08T20:21:15Z")

</div>

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](https://docs.opencv.org/3.4/d6/dcf/classcv_1_1Vec.html), 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](https://stackoverflow.com/q/75050990/5321862)
- Issue opened on [GitHub](https://github.com/opencv/opencv/issues/23115)

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [January 8, 2023, 9:58pm UTC](https://forum.opencv.org/t/no-suitable-user-defined-conversion-from-cv-matx-double-2-1-to-cv-vec2d-exists/11537/2 "2023-01-08T21:58:05Z")

</div>

undeclared crosspost:

> <https://stackoverflow.com/questions/75050990/no-suitable-user-defined-conversion-from-cvmatxdouble-2-1-to-cvvec2d>

> <https://meta.stackoverflow.com/questions/266053/is-it-ok-to-cross-post-a-question-between-non-stack-exchange-and-stack-exchange>

---

<div class="post-metadata">

**Author:** ![buzz](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@buzz](https://forum.opencv.org/u/buzz)\
**Post date:** [January 9, 2023, 5:56am UTC](https://forum.opencv.org/t/no-suitable-user-defined-conversion-from-cv-matx-double-2-1-to-cv-vec2d-exists/11537/3 "2023-01-09T05:56:46Z")

</div>

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
