파이썬 opencv 에러 error: (-215:Assertion failed) src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F) in function 'magnitude'

InAnarchy·2023년 6월 2일
0

파이썬 에러 모음

목록 보기
3/3
post-thumbnail

선요약

32f, 64f으로 바꿔라.

아니 지는 그냥 책에 np.abs랑 np.clip 따로 했길래 귀찮아서
cv2.convertScaleAbs로 바꾼 죄밖에 없구먼유...

그런데 그것이 죄였다.

dst1,dst2 = np.abs(dst1), np.abs(dst2)

print(type(dst1[0][0]))
print(type(dst2[0][0]))


dst = cv2.magnitude(dst1,dst2) 
print(dst)
<class 'numpy.float32'>
<class 'numpy.float32'>
[[ 0.         0.         0.        ...  0.         0.         0.       ]
 [ 0.         0.         0.        ...  9.055386   5.         0.       ]
 [ 0.         0.         0.        ...  6.082762   3.         0.       ]
 ...
 [ 0.        34.481876  18.384775  ...  3.1622775  6.4031243  0.       ]
 [ 0.        31.890436   5.6568537 ...  3.         5.3851647  0.       ]
 [ 0.         0.         0.        ...  0.         0.         0.       ]]

이 땐 잘 되는디.

dst1,dst2 = cv2.convertScaleAbs(dst1),cv2.convertScaleAbs(dst2)  

print(type(dst1[0][0]))
print(type(dst2[0][0]))


dst = cv2.magnitude(dst1,dst2) 
print(dst)

이렇게 하니까

<class 'numpy.uint8'>
<class 'numpy.uint8'>

error: (-215:Assertion failed) src1.size() == src2.size() && type == src2.type() && (depth == CV_32F || depth == CV_64F) in function 'magnitude'

오류가 뜨는 이유는
타입이 32f, 64f가 아니라서 그렇다...

profile
github blog 쓰다가 관리하기 귀찮아서 돌아왔다

2개의 댓글

comment-user-thumbnail
2024년 1월 16일

안녕하세요 저 Open cv 토끼 너무 귀여운데 퍼가서 카톡프사해도되나요?

1개의 답글