Exemple #1
0
import glob
import matplotlib.image as mpimg
import matplotlib.pyplot as plt

# NomeroffNet path
NOMEROFF_NET_DIR = os.path.abspath('../../')
sys.path.append(NOMEROFF_NET_DIR)

# Import license plate recognition tools.
from NomeroffNet import Detector
from NomeroffNet import filters

# load model
nnet = Detector()
nnet.loadModel(NOMEROFF_NET_DIR)

# Walking through the ./examples/images/ directory and checking each of the images for license plates.
rootDir = '../images/*'

imgs = [mpimg.imread(img_path) for img_path in glob.glob(rootDir)]

cv_imgs_masks = nnet.detect_mask(imgs)

for img, cv_img_masks in zip(imgs, cv_imgs_masks):
    # Generate splashs.
    splashs = filters.color_splash(img, cv_img_masks)
    for splash in splashs:
        plt.imshow(splash)
        plt.axis("off")
        plt.show()
Exemple #2
0
nnet = Detector()
nnet.loadModel(NOMEROFF_NET_DIR)

# Detect numberplate
# img_path = 'images/example2.jpeg'
# img_path = '/usr/src/app/src/nomeroff-net/examples/images/example2.jpeg'
# img_path = '/usr/src/app/src/nomeroff-net/examples/images/example3.jpg'

for filename in glob.glob('/usr/src/app/src/nomeroff-net/cars/*'):
    print(filename)

    img = mpimg.imread(filename)

    # Generate image mask.
    cv_imgs_masks = nnet.detect_mask([img])

    for cv_img_masks in cv_imgs_masks:
        # Detect points.
        arrPoints = rectDetector.detect(cv_img_masks)

        # cut zones
        zones = rectDetector.get_cv_zonesBGR(img, arrPoints, 64, 295)

        # find standart
        regionIds, stateIds, countLines = optionsDetector.predict(zones)
        regionNames = optionsDetector.getRegionLabels(regionIds)

        # find text with postprocessing by standart
        textArr = textDetector.predict(zones)
        textArr = textPostprocessing(textArr, regionNames)