• 카테고리

    질문 & 답변
  • 세부 분야

    컴퓨터 비전

  • 해결 여부

    미해결

NameError

20.04.19 21:28 작성 조회수 104

0

# cv2.findCountours() function changed from OpenCV3 to OpenCV4: now it have only two parameters instead of 3

cv2MajorVersion = cv2.__version__.split(".")[0]

print('openCV version : ', cv2MajorVersion)

# check for contours on thresh

if int(cv2MajorVersion) >= 4:

    contours, hierarchy = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

else:

    imageContours, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-9-5caa6544b17f> in <module>
      4 # check for contours on thresh
      5 if int(cv2MajorVersion) >= 4:
----> 6     contours, hierarchy = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)
      7 else:
      8     imageContours, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

NameError: name 'thresh' is not defined

답변 1

답변을 작성해보세요.

0

안녕하세요?

이 프로그램은 RBP_DL12_openCV_get_image.ipynb의 내용인가요?

그렇다면 이번에도 Jupyter notebook에서 앞에 있는 단계를 실행하지 않은것 같습니다.

Jupyter notebook은 명령이 단계별로 나누어져 있어 순서대로 실행해야 합니다. thresh를 만들어주는 부분이 실행 안된 겁니다. 다시한번 순서대로 한 단계씩 실행하시기 바랍니다.

그리고 이전 답변을 못보신 것 같아 다시 말씀드리지만 저에게 구글검색하는 것처럼 에러로그만 보내주시지 않았으면 합니다. 저는 불편하게 느껴집니다.

질문하실 때는 문제가 최소한 어떤 내용이고 어떤 프로그램에서 에러가 생겼는지 정도는 부연설명해 주셨으면 합니다.

서로 얼굴은 못봐서 인사까지는 아니더라도 최소한 상대방에 대한 배려는 해주셨으면 고맙겠습니다.  

감사합니다.