我希望在 28*28 灰度图像(手写数字)上使用 ORB(http://docs.opencv.org/3.1.0/d1/d89/tutorial_py_orb.html#gsc.tab=0),其中每个像素都有一个从 0 到 255 的数字。
这是我使用的代码:
# image = {load the array of 754 numbers}
orb = cv2.ORB_create()
image = image.reshape(28, 28))
kp = orb.detect(image, None)
但我不断收到此错误:
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
我该怎么做?为什么会出现这个错误?
更新
我似乎已经解决了这个问题的一部分。事实证明,orb 接受 float32 数字(不是 64)。
因此我更新了我的代码如下:
orb = cv2.ORB_create()
image = feature_x[0].reshape(28, 28).astype('float32')
kp = orb.detect(image, None)
但现在我有以下错误:
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/hello.py", 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