ORB is not working

asked 2016-03-15 14:07:28 -0600

Yahya gravatar image

updated 2016-03-15 14:08:25 -0600

OpenCV version: 3.1.0

Host OS: Linux Ubuntu 14.04

Language: Python

I wish to use ORB (http://docs.opencv.org/3.1.0/d1/d89/t...) on a 28*28 grayscale image (handwritten digits), where each pixel has a number from 0 to 255.

This is the code I used:

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/hello.py", 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

I also tried:

orb = cv2.ORB_create()
image = img_as_float(image.reshape(28, 28))
kp = orb.detect(image, None)

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

edit retag flag offensive close merge delete

Comments

1

image.reshape(28, 28) means that you will have an image with 28 channels and 28 rows and the tail are columns. I think you need cv::resize(). For handwritten digits I think cv::HogDescriptor() is the better way. In combination with SVM I got good results, although I do just recognize printed characters. Here is an example with Matlab.

matman gravatar imagematman ( 2016-03-15 15:39:25 -0600 )edit
2

image.reshape(28, 28)) is rotten in the 1st place. no, you don't want 28 channels. did you mean to use resize() or similar instead ?

also, please adjust the title to "i can't use orb properly" .. (it's a pebkab problem , not a library one)

berak gravatar imageberak ( 2016-03-15 15:44:54 -0600 )edit