Python导入模块根本不起作用

时间:2020-03-19 08:43:55

标签: python module python-import

我有一个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'

0 个答案:

没有答案