# Opencv ptr()'s overload 9 and 10

**URL:** <https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126>\
**Category:** C++\
**Created:** [May 4, 2021, 7:51am UTC](https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126 "2021-05-04T07:51:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxx0717](https://avatars.discourse-cdn.com/v4/letter/z/df788c/32.png) [@zxx0717](https://forum.opencv.org/u/zxx0717)\
**Post date:** [May 4, 2021, 7:51am UTC](https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126/1 "2021-05-04T07:51:55Z")

</div>

[https://docs.opencv.org/master/d3/d63/classcv\_1\_1Mat.html#a7ce1d8cc9a83ae7cab79766d0eb6c0a8](https://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#a7ce1d8cc9a83ae7cab79766d0eb6c0a8)

```
Mat mat = (Mat_<int>{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}).reshape(2, 3);
const Vec<int,2> vi2{1,1};
mat.ptr(vi2);
error: mat.ptr<2>(Vec2i) undefined ,the source code just exactly decalre,but undefined .

```

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [May 4, 2021, 8:10am UTC](https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126/2 "2021-05-04T08:10:50Z")

</div>

opencv version and _exact_ error msg, please 😉

(apart from that, yes, i can repeat it on master(4.5.2-pre))

---

<div class="post-metadata">

**Author:** ![zxx0717](https://avatars.discourse-cdn.com/v4/letter/z/df788c/32.png) [@zxx0717](https://forum.opencv.org/u/zxx0717)\
**Post date:** [May 7, 2021, 7:12am UTC](https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126/3 "2021-05-07T07:12:37Z")

</div>

opencv 4.5.1 ,how to use Mat::ptr’s 9th and 10th overload [OpenCV: cv::Mat Class Reference](https://docs.opencv.org/master/d3/d63/classcv_1_1Mat.html#a7ce1d8cc9a83ae7cab79766d0eb6c0a8)  
any samples may help me .

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [May 7, 2021, 7:41am UTC](https://forum.opencv.org/t/opencv-ptr-s-overload-9-and-10/3126/4 "2021-05-07T07:41:20Z")

</div>

there are no samples, [you found a bug](https://github.com/opencv/opencv/issues/20044). (it’s not implemented)

(same problem for 19 20)

we’ll fix this later, for now you can put the missing implementation into your own code, like:

```auto
template<int n> uchar* Mat::ptr(const Vec<int, n>& idx) {
	return Mat::ptr(idx.val);
}
template<int n> const uchar* Mat::ptr(const Vec<int, n>& idx) const {
	return Mat::ptr(idx.val);
}
template<typename _Tp, int n> _Tp* Mat::ptr(const Vec<int, n>& idx) {
	return Mat::ptr<_Tp>(idx.val);
}
template<typename _Tp, int n> const _Tp* Mat::ptr(const Vec<int, n>& idx) const {
	return Mat::ptr<_Tp>(idx.val);
}

```
