2017-10-01 5 views
0

ORBを使用して以前に生成されたスペクトログラムのキーポイントとディスクリプタを検索しようとしています。エラーがKP、DESまたはIMGのデータ型に関連している可能性があり、私が集まっ何からopencv(python)を使用しているときの "orb.detectAndCompute"のエラー

OpenCV Error: Assertion failed (depth == CV_8U || depth == CV_16U || depth == CV_32F) in cvtColor, file /home/undead/opencv/opencv-3.2.0/modules/imgproc/src/color.cpp, line 9710 

Traceback (most recent call last): 
    File "/home/undead/PycharmProjects/KavTest/Test3.py", line 37, in <module> 
    kp[a], des[a] = orb.detectAndCompute(img[a], None) 

cv2.error: /home/undead/opencv/opencv-3.2.0/modules/imgproc/src/color.cpp:9710: error: (-215) depth == CV_8U || depth == CV_16U || depth == CV_32F in function cvtColor 

が、私は」:

start = time.time() 
x = 1 
img = range(101) 
imgname = range(101) 

# Directory Images 
os.chdir("/home/undead/Documents/TempSongSpectro/") #1,2,3 
for file in glob.glob("*.png"): 
    img[x] = cv2.imread(file, 0) # trainImage 
    imgname[x] = os.path.splitext(file)[0] 
# print "%s: %d " % (os.path.splitext(file)[0],(x)) 
x = x + 1 

# Initiate ORB detector 
orb = cv2.ORB_create(3000) 

# find the keypoints and descriptors with ORB 
a = 1 
des = range(101) 
kp = range(101) 

for a in range(1, 101): 
    kp[a], des[a] = orb.detectAndCompute(img[a], None) 

end = time.time() 
print("Initialize time: %f seconds" % (end - start)) 

しかし、私はエラーを取得しています:私はこのコードを持っていますそれを解決する方法についてはあまり確かではありません。誰か助けてもらえますか?

答えて

0

あなたのコードに何か問題があると思います。

これは私のコードとほぼ同じです。

start = time.time() 

imgnames = glob.glob("/home/undead/Documents/TempSongSpectro/*.png") 
#imgnames = imgnames[:100] 

sz = len(imgnames) 
imgs = list(range(sz)) 

for i, name in enumerate(imgnames, start=0): 
    imgs[i] = cv2.imread(name, 0) 

orb = cv2.ORB_create(3000) 

# find the keypoints and descriptors with ORB 
des = list(range(sz)) 
kp = list(range(sz)) 

for i in range(sz): 
    kp[i], des[i] = orb.detectAndCompute(img[i], None) 

end = time.time() 
print("Initialize time: {:.4f} seconds".format(end - start)) 
+0

これは問題を解決したようです。ありがとうございました :) – Undead

関連する問題