gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)

        img = Frame(np.array(Image.fromarray(gray)), str(image_name()), None,
                    None)
        cv.imwrite("../processed/original/" + img._id + ".png", img.image)
        log("Start processing frame " + str(img._id) + " at " +
            datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f'))
        print("Start processing frame " + str(img._id) + " at " +
              datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f'))

        img.CropImage()
        img.image = imgProcessing.Billateral(img.image)
        cv.imwrite("../processed/billateral/" + img._id + ".png", img.image)

        img.image = imgProcessing.Canny(img.image)
        cv.imwrite("../processed/canny/" + img._id + ".png", img.image)

        imgProcessing.FindPossiblePlates(img, False, False)
        log("New frame " + str(img._id) + " finished processing at " +
            datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f'))
        print("New frame " + str(img._id) + " finished processing at " +
              datetime.datetime.now().strftime('%Y-%m-%d_%H:%M:%S:%f'))

        if len(img.arrayOfPlates) == 0:
            log("No plates found in frame " + str(img._id) +
                ", applying dilate filter...")
            print("No plates found in frame " + str(img._id) +
                  ", applying dilate filter...")
            img.image = imgProcessing.Dilate(img.image)
            cv.imwrite("../processed/dilate/" + str(img._id) + " .png",
예제 #2
0
from frame import Frame
from imageProcessing import ImageProcessing
import cv2 as cv
import numpy as np
imgPlaca = cv.imread("C:/Users/oluis/Desktop/images/original/torta.png",
                     cv.IMREAD_GRAYSCALE)

plateCopy = imgPlaca.copy()

imgProcessing = ImageProcessing()

plateCopy = imgProcessing.MoreLight(plateCopy)
plateCopy = imgProcessing.Billateral(plateCopy)
plateCopy = imgProcessing.Canny(plateCopy)

findContournsImg, contoursPlate, hierarchy = cv.findContours(
    plateCopy.copy(), cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)

backtorgbplate = cv.cvtColor(plateCopy, cv.COLOR_GRAY2RGB)

for contour in contoursPlate:
    x, y, w, h = cv.boundingRect(contour)
    proportion = float(w) / h
    if proportion > 0.57 and proportion < 0.84 and h > 11:
        cv.rectangle(backtorgbplate, (x, y), (x + w, y + h), (0, 0, 255), 1)

cv.imshow('placa', backtorgbplate)

cv.waitKey(0)