[Python] NameError: name 'cv2' is not define while trying to run def __init__(self, width,...

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to sun some neural network code with cv2 and getting error

    def __init__(self, width, height, inter=cv2.INTER_AREA):
    ^^^
    NameError: name 'cv2' is not define

    knn.py --dataset ./datasets/animals
    Traceback (most recent call last):
    File "/Users/test/Desktop/CODE/knn.py", line 6, in <module>
    from pyimagesearch.preprocessing import SimplePreprocessor
    File "/Users/test/Desktop/CODE/pyimagesearch/preprocessing/SimplePreprocessor.py", line 4, in <module>
    class SimplePreprocessor:
    File "/Users/test/Desktop/CODE/pyimagesearch/preprocessing/SimplePreprocessor.py", line 5, in SimplePreprocessor
    def __init__(self, width, height, inter=cv2.INTER_AREA):
    ^^^
    NameError: name 'cv2' is not defined

    Continue reading...

Compartilhe esta Página