Exemplo n.º 1
0
def handle_image():
    content = request.get_json(force=True)

    time = content['time']
    post_img = content['img'][0]
    img_name = str(str(time) + str(random.randint(0, 65535)))
    # img_name = '1'
    img = open(locate + img_name + '.jpg', 'wb')
    # img = open('q.jpg','wb')
    img_temp = base64.b64decode(post_img)
    img.write(img_temp)

    address = content['address']
    # plate = readImg.read_img()
    import hyperlpr.pipline as pp
    import cv2
    read_img = cv2.imread(locate + img_name + '.jpg')

    plate_temp = pp.SimpleRecognizePlate(read_img)
    # print plate
    plate = '识别失败'
    if plate != None and plate != []:
        plate = plate_temp[0]
    user = User(img=img_name + '.jpg',
                type=1,
                time=time,
                address=address,
                plate=plate)
    db.session.add(user)
    db.session.commit()
    search_res = User.query.filter_by(address=address, time=time).first()
    id = search_res.id
    address = search_res.address
    img = "http://101.132.144.11/getImg/" + img_name
    time = search_res.time
    img.close()
    #失败之后对图片进行删除
    # count = search(plate)
    if plate != '识别失败':
        result = jsonify({
            'res': 'success',
            'address': address,
            'time': time,
            'plate': plate,
            'id': id,
            'img': img
        })
    else:
        result = jsonify({
            'res': 'fail',
            'address': address,
            'time': time,
            'plate': plate,
            'id': id,
            'img': img
        })
    return result
Exemplo n.º 2
0
 def recognize(self):
     self.timer.stop()
     from hyperlpr import pipline as pp
     cv2.imshow('i', self.frame_)
     cv2.waitKey()
     _, res = pp.SimpleRecognizePlate(self.frame_)
     if not len(res):
         res.append('无效的图片')
     item = QStandardItem(res[0])
     self.model_t.setItem(self.i, 0, item)
     self.i += 1
Exemplo n.º 3
0
    def recognize_0(self):
        _, res = pp.SimpleRecognizePlate(self.frame_)
        if not len(res):
            # res.append('无效的图片')
            return
        value = self.model_t.data(self.model_t.index(self.i - 1, 0))
        if value == res[0]:
            return
        item = QStandardItem(res[0])

        self.model_t.setItem(self.i, 0, item)
        self.i += 1
Exemplo n.º 4
0
 def start_check(self, file):
     image = cv2.imread(file)
     image, res = pp.SimpleRecognizePlate(image)
     try:
         self.ui.label.setText(res[0])
     except Exception as e:
         self.ui.plainTextEdit.appendPlainText('抱歉,未检测到车牌...')
         self.ui.plainTextEdit.appendPlainText('---------------------------')
         return e
     self.ui.label.adjustSize()
     check_res = self.sql_tools.check_plate(res[0])
     print(check_res)
     if check_res[0]:
         if check_res[1][4] == '0':
             now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
             self.ui.plainTextEdit.appendPlainText('车牌号:{}\n进入时间:{}'.format(check_res[1][1], now_time))
             self.sql_tools.update_intime_plate_info(now_time, check_res[1][0])
             self.ui.plainTextEdit.appendPlainText('匹配成功,正在下发抬杆指令...')
             self.open_the_door()
             time.sleep(0.01)
             self.ui.plainTextEdit.appendPlainText('下发成功,正在抬杆')
             self.ui.plainTextEdit.appendPlainText('---------------------------')
         elif check_res[1][4] == '1':
             now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
             in_time = time.mktime(time.strptime(check_res[1][2], "%Y-%m-%d %H:%M:%S"))
             out_time = time.mktime(time.strptime(now_time, "%Y-%m-%d %H:%M:%S"))
             self.ui.plainTextEdit.appendPlainText('车牌号:{}\n进入时间:{}'.format(check_res[1][1], check_res[1][2]))
             self.ui.plainTextEdit.appendPlainText('驶出时间:{}'.format(now_time))
             stop_time = out_time - in_time
             stop_time_day = int(stop_time / 86400)
             stop_time_hour = int((stop_time % 86400) / 3600)
             stop_time_min = int(((stop_time % 86400) % 3600) / 60)
             str_stop_time = "已停车{}天{}时{}分,请缴费{}元".format(stop_time_day, stop_time_hour, stop_time_min, 2)
             self.ui.plainTextEdit.appendPlainText(str_stop_time)
             self.ui.plainTextEdit.appendPlainText('欢迎再次光临,正在下发抬杆指令...')
             self.open_the_door()
             time.sleep(0.01)
             self.ui.plainTextEdit.appendPlainText('下发成功,正在抬杆')
             self.ui.plainTextEdit.appendPlainText('---------------------------')
             self.sql_tools.update_outime_plate_info(now_time, check_res[1][0])
     else:
         self.ui.plainTextEdit.appendPlainText('外来车辆,不予抬杆...')
         self.ui.plainTextEdit.appendPlainText('---------------------------')
Exemplo n.º 5
0
for filename in os.listdir(parent):

    path = os.path.join(parent, filename)
    print path

    if path.endswith(".jpg") or path.endswith(".png"):
        ics, name = os.path.split(path)

        name, ext = name.split(".")

        image = cv2.imread(path)
        image = image[roi[1]:roi[1] + roi[3], roi[0]:roi[0] + roi[2]]
        # cv2.imshow("test",image)
        # cv2.waitKey(0)
        info, dataset = pp.SimpleRecognizePlate(image)
        ext = ext.strip()
        name = name.strip()

        if len(dataset) == 0:
            count_undetected += 1

            # cv2.imwrite("./cache/bad2/" + name + ".png", image)

        for one in dataset:

            # p = sm.StringMatcher(seq1=one.encode("utf-8"),seq2=name.encode("utf-8"))
            A = one.encode("utf-8")
            B = name.encode("utf-8")
            print one.encode("utf-8"), "<->", name.encode(
                "utf-8"), "编辑距离:", comparestring(A, B)
Exemplo n.º 6
0
from hyperlpr import pipline

import cv2

# image1 = cv2.imread("./dataset/0.jpg")
# image2 = cv2.imread("./dataset/1.jpg")
# image3 = cv2.imread("./dataset/5.jpg")
# image4 = cv2.imread("./dataset/6.jpg")

image5 = cv2.imread("./dataset/3144391.png")
#
# pipline.SimpleRecognizePlate(image4)
# pipline.SimpleRecognizePlate(image3)
pipline.SimpleRecognizePlate(image5)
from hyperlpr import pipline as pp
import cv2
import h5py

image = cv2.imread("6.jpg")
image, res = pp.SimpleRecognizePlate(image)