# Opencv-python. How can I use convertTo?

**URL:** <https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942>\
**Category:** Python\
**Created:** [November 14, 2022, 4:15am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942 "2022-11-14T04:15:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CZH](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@CZH](https://forum.opencv.org/u/CZH)\
**Post date:** [November 14, 2022, 4:15am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942/1 "2022-11-14T04:15:17Z")

</div>

```auto
brisk = cv2.BRISK_create()
des = brisk.compute(img,kp, None)
des.convertTo(des_left,cv2.CV_32F)

```

_\> AttributeError: ‘tuple’ object has no attribute ‘convertTo’_

or

`des = des[1].convertTo(des,cv2.CV_32F)`

_\> AttributeError: ‘numpy.ndarray’ object has no attribute ‘convertTo’_

How can I use convertTo in opencv-python? Sincerely hope to get your help.

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [November 14, 2022, 8:05am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942/2 "2022-11-14T08:05:27Z")

</div>

use numpy [astype](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html)

---

<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:** [November 14, 2022, 8:30am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942/3 "2022-11-14T08:30:33Z")

</div>

please explain, _WHY_ you try to do this.

there is no meaningful conversion to float from binary descriptors (BRISK,ORB,etc), those are bitstrings , not numbers

again, please explain the context, seems you try to blindly copypaste a broken idea 😉

---

<div class="post-metadata">

**Author:** ![CZH](https://avatars.discourse-cdn.com/v4/letter/c/e56c9b/32.png) [@CZH](https://forum.opencv.org/u/CZH)\
**Post date:** [November 14, 2022, 9:16am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942/4 "2022-11-14T09:16:09Z")

</div>

I want to try fast detector+brisk descriptor+flann matching, and I found the brisk descriptor don’t fit the input type. After googling , I found someone recommend to use _convertTo_ to make it possible. I tried, but _convertTo_ seems to not included in the opencv-python(contrib), so I came here to ask 🤣.

By the way, if I achieve the _convertTo_, do the matching outcomes meaningful? Or bfmatch will be a better choice?

---

<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:** [November 14, 2022, 10:28am UTC](https://forum.opencv.org/t/opencv-python-how-can-i-use-convertto/10942/5 "2022-11-14T10:28:09Z")

</div>

> [@CZH](#):
>
> if I achieve the _convertTo_, do the matching outcomes meaningful?

no way. the result is just garbage.

keep the descriptors as-is (uint8) and match them with BFMatcher (HAMMING), or . IF you need to use flann, use an LSHIndex:

```auto
FLANN_INDEX_LSH = 6

index_params= dict(algorithm = FLANN_INDEX_LSH,
                   table_number = 6, # 12
                   key_size = 12, # 20
                   multi_probe_level = 1) #2
search_params = dict(checks=50) # or pass empty dictionary

flann = cv2.FlannBasedMatcher(index_params,search_params)

```
