How to use orb on a image in CV2?

I wish to use ORB ( on a 28*28 grayscale image (handwritten digits), where each pixel has a number from 0 to 255.

This is the code I used:

# image = {load the array of 754 numbers}
orb = cv2.ORB_create()
image = image.reshape(28, 28))
kp = orb.detect(image, None)

But I keep getting this error:

OpenCV Error: Assertion failed (depth == CV_8U || depth == CV_16U || depth == CV_32F) in cvtColor, file /home/yahya/Documents/_other_downloaded_apps/opencv/modules/imgproc/src/color.cpp, line 7935
Traceback (most recent call last):
  File "/home/yahya/Documents/", line 118, in <module>
    kp = orb.detect(image, None)
cv2.error: /home/yahya/Documents/_other_downloaded_apps/opencv/modules/imgproc/src/color.cpp:7935: error: (-215) depth == CV_8U || depth == CV_16U || depth == CV_32F in function cvtColor

How can I do this and why am I getting this error?


I seemed to have solved part of this problem. It turns out that orb accepts float32 numbers (not 64).

Therefore I updated my code as follows:

orb = cv2.ORB_create()
image = feature_x[0].reshape(28, 28).astype('float32')
kp = orb.detect(image, None)

But now I have the following error:

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor, file /home/yahya/Documents/_other_downloaded_apps/opencv/modules/imgproc/src/color.cpp, line 7456
Traceback (most recent call last):
  File "/home/yahya/Documents/", line 188, in <module>
    kp = orb.detect(image, None)
cv2.error: /home/yahya/Documents/_other_downloaded_apps/opencv/modules/imgproc/src/color.cpp:7456: error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor


The image you are trying to load isn't compatible type for the orb. You should convert it first before using it. Also you don't need reshape if you are loading it into numpy array

orb = cv2.ORB_create()
image = image.astype(np.uint8, copy=False)
kp = orb.detect(image, None)

Need Your Help

Google Maps v2 inside a Fragment return void

android google-maps android-fragments

In my application i'm using navigation drawer with swipe tabs (following this) and inside one of these tabs i want to use google maps. I'm getting this error:

Symfony2 : ternary relation

symfony doctrine-orm

I try to create a ternary relation whith composite primary keys (3 primary keys):