EasyGUI 및 SimpleCV- TypeError : '모듈'개체를 호출 할 수 없습니다.

미래 엔지니어

simpleCV 프로그램을위한 GUI를 만들려고합니다. 나는 그것을하기 위해 easyGUI를 사용하고 있습니다. 내 코드는 다음과 같습니다.

from easygui import * 
from SimpleCV import *
from cv2 import *
from cv import *
from PIL import *
import time
import sys
while True:
    msgbox("""Welcome to my program!""", image = "pi.jpg")
    msgbox("Select img ")
    nam=fileopenbox(filetypes=['*'])
    print nam
    img=Image(nam)
    img1=img.binarize()
    time.sleep(1)
    img1.save("result.png")
    msgbox("This is the result", image = "result.png")
    msg = "Do you want to continue?"
    title = "Please Confirm"
    if ccbox(msg, title): # show continue/cancle dialog
        print "okk" # user chose continue  
    else:
        sys.exit(0) # user chose cancle

하지만 이상한 오류가 발생합니다 ..

Traceback (most recent call last):
  File "C:\Python27\tryyyy", line 13, in <module>
    img=Image(nam)
TypeError: 'module' object is not callable

나는 print dir (Image)를 시도했고, 나는 얻었다 :

['ADAPTIVE', 'AFFINE', 'ANTIALIAS', 'BICUBIC', 'BILINEAR', 'CONTAINER', 'CUBIC', 'DEBUG', 'EXTENSION', 'EXTENT', 'FLIP_LEFT_RIGHT', 'FLIP_TOP_BOTTOM', 'FLOYDSTEINBERG', 'ID', 'Image', 'ImageMode', 'ImagePalette', 'ImagePointHandler', 'ImageTransformHandler', 'IntType', 'LINEAR', 'MESH', 'MIME', 'MODES', 'NEAREST', 'NONE', 'NORMAL', 'OPEN', 'ORDERED', 'PERSPECTIVE', 'QUAD', 'RASTERIZE', 'ROTATE_180', 'ROTATE_270', 'ROTATE_90', 'SAVE', 'SEQUENCE', 'StringType', 'TupleType', 'UnicodeStringType', 'VERSION', 'WEB', '_E', '_ENDIAN', '_ImageCrop', '_MAPMODES', '_MODEINFO', '_MODE_CONV', 'builtins', 'doc', 'file', 'name', 'package','_conv_type_shape ','_fromarray_typemap ','_getdecoder ','_getencoder ','_getscaleoffset ','_imaging_not_installed ','_initialized ','_show ','_showxv ','_wedge ','blend ','byteorder ', 'composite', 'core', 'eval', 'fromarray', 'frombuffer', 'fromstring', 'getmodebandnames', 'getmodebands', 'getmodebase', 'getmodetype', 'init', 'isDirectory', 'isImageType ','isNumberType ','isSequenceType ','isStringType ','isTupleType ','merge ','new ','open ','os ','preinit ','register_extension ','register_mime ','register_open ', '등록 _ 저장', 'string ','sys ','warnings ']

SimpleCV를 가져 왔습니다. 이 오류가 발생하는 이유를 도와 주시겠습니까? 미리 감사드립니다.

로버트 러그

@zoosuck이 언급했듯이 '이미지'는 모듈입니다. 이것은 정확하지만 문제가 아닙니다 (참고로이 응답을 편집했습니다).

먼저, 제가 뭔가를 제안해도 될까요? 한 번에 전체 프로그램을 작성하려고합니다. 대신 GUI가 전혀없고 이미지가 표시되지 않는 매우 간단한 프로그램을 시도해보십시오. '페인트'와 같은 외부 도구를 사용하여 기본 로직이 제대로 작동하는지 확인합니다. 그런 다음 멋진 GUI를 추가하고 기본 로직이 제대로 작동하면 루프를 실행하십시오.

참조 : Python PIL을 사용하여 RGB 이미지를 순수한 흑백 이미지로 변환

좋습니다. 답으로 돌아가서 다음 세 가지 질문에 답해보세요.

  1. 이미지 란? 나는 당신이 그것이 무엇이라고 생각 하는지를 의미하지 않습니다. 그러나 그것은 무엇입니까?
  2. 그거 어디서 났어?
  3. 왜 당신이 생각했던 것이 아닌가.

잠시 시간을내어 이에 답하십시오. 또한 디버깅에 대한 작은 팁을 제공하고 싶었습니다. 이 두 줄의 코드를 삽입하면 코드에서 "놀 수있는"부분이 생깁니다.

import code
code.interact(local=dict(globals(), **locals()))

파일 상단에 '가져 오기'를 넣으십시오. 중지하려는 곳에 'code. *'줄을 입력합니다. 프로그램을 정상적으로 실행하십시오. code.interact 문에 >>>가 표시됩니다. 이제 놀아보세요! print Image 또는 print (Image)를 입력하고 help (Image)를 시도하십시오. 당신은 무엇을 얻습니까? 내가 얻은 것은 다음과 같습니다.

>>> Image
<module 'PIL.Image' from 'C:\Python27\lib\site-packages\PIL\Image.pyc'>

기다림! SimpleCV가 아닌 PIL.Image라고 말합니다! 문제는 수입 명세서에 있습니다. 나는 당신이 그들을 변경하는 것이 좋습니다. 하던 대로 할 있지만 때로는 매우 혼란 스럽습니다. 대신 다음과 같이 변경하십시오.

import SimpleCV as cv
import PIL as pil

그런 다음 코드에서 항상 'cv.Image'라고 말하십시오. 구체적이지 않았고 PIL이 '이미지'를 덮어 썼기 때문에 잘못된 이미지를 얻었습니다. 대신 위에서 언급 한대로 가져 오면 훨씬 덜 혼란 스러울 것이라고 생각합니다. 이게 도움이 되길 바란다!

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Python TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Python 모듈 문제 : TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

'모듈'개체의 TypeError는 호출 할 수 없습니다.

분류에서Dev

Python timeit-TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

Pytorch 1.7.0 | DataLoader 오류-TypeError : '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

/ api / register / '모듈'개체의 TypeError를 호출 할 수 없습니다.

분류에서Dev

pygame '모듈'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'개체는 Django 3 렌더링 함수를 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

분류에서Dev

TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

분류에서Dev

모델 적합 / TypeError : 'NoneType'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '_IncompatibleKeys'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'NoneType'개체는 CircleCI를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'CurrencyConverter'개체를 호출 할 수 없습니다.

분류에서Dev

firebase = firebase (config) TypeError : 'module'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

분류에서Dev

TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

분류에서Dev

Q : TypeError : '_csv.reader'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'Int64Index'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'Player'개체는 Django를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'Post'개체를 호출 할 수 없습니다.

분류에서Dev

groupby-TypeError 'DataFrame'개체를 호출 할 수 없습니다.

분류에서Dev

Python Script TypeError : 'int'개체를 호출 할 수 없습니다.

분류에서Dev

Python 오류 : TypeError : 'list'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : '게임'개체를 호출 할 수 없습니다.

분류에서Dev

Python-TypeError : 'list'개체를 호출 할 수 없습니다.

분류에서Dev

TypeError : 'Weather'개체를 호출 할 수 없습니다.

Related 관련 기사

  1. 1

    Python / Pygame : TypeError : '모듈'개체를 호출 할 수 없습니다.

  2. 2

    Python TypeError : '모듈'개체를 호출 할 수 없습니다.

  3. 3

    TypeError '모듈'개체를 호출 할 수 없습니다.

  4. 4

    Python 모듈 문제 : TypeError : '모듈'개체를 호출 할 수 없습니다.

  5. 5

    '모듈'개체의 TypeError는 호출 할 수 없습니다.

  6. 6

    Python timeit-TypeError : '모듈'개체를 호출 할 수 없습니다.

  7. 7

    Pytorch 1.7.0 | DataLoader 오류-TypeError : '모듈'개체를 호출 할 수 없습니다.

  8. 8

    / api / register / '모듈'개체의 TypeError를 호출 할 수 없습니다.

  9. 9

    pygame '모듈'개체를 호출 할 수 없습니다.

  10. 10

    TypeError : '모듈'개체는 Django 3 렌더링 함수를 호출 할 수 없습니다.

  11. 11

    TypeError : '모듈'객체는 Python3을 호출 할 수 없습니다.

  12. 12

    TypeError : '모듈'객체는 Spacy Python에서 호출 할 수 없습니다.

  13. 13

    모델 적합 / TypeError : 'NoneType'개체를 호출 할 수 없습니다.

  14. 14

    TypeError : '_IncompatibleKeys'개체를 호출 할 수 없습니다.

  15. 15

    TypeError : 'NoneType'개체는 CircleCI를 호출 할 수 없습니다.

  16. 16

    TypeError : 'CurrencyConverter'개체를 호출 할 수 없습니다.

  17. 17

    firebase = firebase (config) TypeError : 'module'개체를 호출 할 수 없습니다.

  18. 18

    TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

  19. 19

    TypeError : '목록'개체를 호출 할 수 없습니다-assertWarns ()

  20. 20

    Q : TypeError : '_csv.reader'개체를 호출 할 수 없습니다.

  21. 21

    TypeError : 'Int64Index'개체를 호출 할 수 없습니다.

  22. 22

    TypeError : 'Player'개체는 Django를 호출 할 수 없습니다.

  23. 23

    TypeError : 'Post'개체를 호출 할 수 없습니다.

  24. 24

    groupby-TypeError 'DataFrame'개체를 호출 할 수 없습니다.

  25. 25

    Python Script TypeError : 'int'개체를 호출 할 수 없습니다.

  26. 26

    Python 오류 : TypeError : 'list'개체를 호출 할 수 없습니다.

  27. 27

    TypeError : '게임'개체를 호출 할 수 없습니다.

  28. 28

    Python-TypeError : 'list'개체를 호출 할 수 없습니다.

  29. 29

    TypeError : 'Weather'개체를 호출 할 수 없습니다.

뜨겁다태그

보관