1

Below is my code which i took it from github and modifying according to my need, it is showing me an error at the line print(characters) when i am trying to take the characters as string in the variable from the video and to insert them in the database. It is working fine on the image but not on the video.

import numpy as np
from skimage.transform import resize
from skimage import measure
from skimage.measure import regionprops
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import DetectPlate
import cx_Oracle
import datetime

# The invert was done so as to convert the black pixel to white pixel and vice versa
license_plate = np.invert(DetectPlate.plate_like_objects[0])

labelled_plate = measure.label(license_plate)

fig, ax1 = plt.subplots(1)
ax1.imshow(license_plate, cmap="gray")
# the next two lines is based on the assumptions that the width of
# a license plate should be between 5% and 15% of the license plate,
# and height should be between 35% and 60%
# this will eliminate some
character_dimensions = (0.35*license_plate.shape[0], 0.60*license_plate.shape[0], 0.05*license_plate.shape[1], 0.15*license_plate.shape[1])
min_height, max_height, min_width, max_width = character_dimensions

characters = []

counter=0
column_list = []
for regions in regionprops(labelled_plate):
    y0, x0, y1, x1 = regions.bbox
    region_height = y1 - y0
    region_width = x1 - x0

    if region_height > min_height and region_height < max_height and region_width > min_width and region_width < max_width:
        roi = license_plate[y0:y1, x0:x1]

        # draw a red bordered rectangle over the character.
        rect_border = patches.Rectangle((x0, y0), x1 - x0, y1 - y0, edgecolor="red",
                                       linewidth=2, fill=False)
        ax1.add_patch(rect_border)

        # resize the characters to 20X20 and then append each character into the characters list
        resized_char = resize(roi, (20, 20))
        characters.append(resized_char)

        # this is just to keep track of the arrangement of the characters
        column_list.append(x0)
print(characters)

connection = cx_Oracle.connect('nabeel/1234@localhost/xe')
cursor = connection.cursor()
dtime=datetime.datetime.now()
cursor.execute("insert into number_plate(reg_no,tstamp) values(:licPlate,:ts)",licPlate=characters)
cursor.setinputsizes(ts=cx_Oracle.TIMESTAMP)
cursor.execute(None, {'ts':dtime})
connection.commit()
connection.close()

plt.show()

i expect that it would insert the license plate number in the table along with time stamp. Thanks

3
  • 2
    Can you post the full error? Is it a traceback or some kind of warning?
    – SyntaxVoid
    Commented Apr 19, 2019 at 19:18
  • 1
    it is showing this line: cursor.execute("insert into number_plate(reg_no,tstamp) values(:licPlate,:ts)",licPlate=characters), then after that NotSupportedError : Element 0 value is unsupported.. This is the only thing i am getting Commented Apr 20, 2019 at 1:58
  • hey SyntaxVoid am i doing something wrong in the code? I mean i cross verified the code but it is showing NotSupportedError: Element 0 value is unsupported. Dont know what to do. Cannot find anywhere. If anyone can answer this please that would really helpful.. Thanks Commented Apr 22, 2019 at 5:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.