Python модуль импорта вообще не работает - PullRequest
0 голосов
/ 19 марта 2020

У меня есть python проект, в котором я пытаюсь добавить скрипт, который делал раньше. Поэтому я поместил его в подкаталог моего проекта, и у меня есть такая структура:

enter image description here

С class_PlateDetection.py Я хочу импортировать segmentation.py ( Особенно функция segment_characters_from_plate), но модуль импорта не работает. это class_PlateDetection.py модуль импорта:

from utils.segmentation import segment_characters_from_plate

и это полный segment_characters_from_plate импорт функционального модуля внутри segmentation.py:

import cv2
import numpy as np

import imutils
from skimage.filters import threshold_local
from skimage import measure


def sort_contours_left_to_right(character_contours):
    """
    Sort contours from left to right
    """
    i = 0
    boundingBoxes = [cv2.boundingRect(c) for c in character_contours]
    (character_contours, boundingBoxes) = zip(*sorted(zip(character_contours, boundingBoxes),
                                                key=lambda b:b[1][i], reverse=False))
    return character_contours


def segment_characters_from_plate(plate_img, fixed_width):
    """
    extract the Value component from the HSV color space and apply adaptive thresholding
    to reveal the characters on the license plate
    """
    V = cv2.split(cv2.cvtColor(plate_img, cv2.COLOR_BGR2HSV))[2]
    T = threshold_local(V, 29, offset=15, method='gaussian')
    thresh = (V > T).astype('uint8') * 255
    thresh = cv2.bitwise_not(thresh)

этот импорт выдаст мне ошибку: ModuleNotFoundError: No module named 'utils.segmentation'

...