GithubHelp home page GithubHelp logo

about data about alpr_utils HOT 2 CLOSED

ufownl avatar ufownl commented on August 18, 2024
about data

from alpr_utils.

Comments (2)

ufownl avatar ufownl commented on August 18, 2024

Download the dataset CCPD, and you could generate the dataset.json using the code snippet below:

import os
import cv2
import json
import random
import multiprocessing


provinces = ["皖", "沪", "津", "渝", "冀", "晋", "蒙", "辽", "吉", "黑", "苏", "浙", "京", "闽", "赣", "鲁", "豫", "鄂", "湘", "粤", "桂", "琼", "川", "贵", "云", "藏", "陕", "甘", "青", "宁", "新", "警", "学", "O"]
alphabets = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'O']
ads = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'O']


def process(walk):
    dataset = []
    for root, filename in walk:
        name, ext = os.path.splitext(filename)
        labels = name.split("-")
        if len(labels) < 7:
            continue
        image = os.path.join(root, filename)
        height, width = cv2.imread(image, 1).shape[:2]
        points = labels[3].split("_")
        points = [tuple(points[2].split("&")), tuple(points[3].split("&")), tuple(points[0].split("&")), tuple(points[1].split("&"))]
        points = [float(x) / width for x, _ in points] + [float(y) / height for _, y in points]
        plate = [int(tk) for tk in labels[4].split("_")]
        plate = "".join([provinces[plate[0]], alphabets[plate[1]]] + [ads[tk] for tk in plate[2:]])
        dataset.append({"image": image, "points": points, "plate": plate})
    return dataset


if __name__ == "__main__":
    walk = [(root, filename) for root, _, files in os.walk("CCPD2019") for filename in files]
    walk = [walk[i:i + 10000] for i in range(0, len(walk), 10000)]
    with multiprocessing.Pool(multiprocessing.cpu_count() * 2) as p:
        dataset = [dc for ds in p.map(process, walk) for dc in ds]
    random.shuffle(dataset)
    print(json.dumps(dataset))

from alpr_utils.

Juldeng avatar Juldeng commented on August 18, 2024

ok,thanks for your answer

from alpr_utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.