Intelligent gate system of parking lot (qt)

Posted by Ekate on Thu, 30 Dec 2021 01:36:53 +0100

demand

This project is a three-level project at the end of the term, which was completed by my roommate and I in a team. Among them, I am responsible for Baidu identification, camera acquisition, time display and code integration

Design

The functions of the project include: the camera obtains the license plate number, screenshots and automatically saves them, automatically analyzes and displays the license plate number, carries out voice broadcasting, displays the current time, entry time, departure time, calculates payment, and views parking records. The vehicle is detected by the light spot sensor and the information is transmitted to qt through the serial port.

The project is divided into mainwindow and dialog interfaces. The mainwindow interface mainly realizes the functions of parking and photographing, screenshot analysis of license plate number, display time, payment, voice recognition and so on; The dialog interface is mainly used to view parking records.

The controls used in the project include Label control, button, horizontal layout, vertical layout, grid layout, tab control, text editing, menu and tool control.

Time display, payment, prompt tone

Time display: create a QTimer object in the constructor, connect the signal and slot function, bind the timer to the TimeUpdate function, and set the slot function to trigger every second; Define the member function timerUpdate(), entryTime(), leaveTime() to display the current time, entry time and departure time in the user interface; Use the QDateTime class to provide date and time functions, use the static function currentDateTime() of QDateTime class to obtain the current date and time, then set the display format, and finally display the time on the Label;

Payment: extract the text in the Label, convert QString into QDateTime, and obtain the entry time and departure time; Convert the entry time and departure time of QDateTime type into timestamp, define an int type to calculate the payment amount, format the number as a QString in hexadecimal, and then display the payment amount on the Label;

Prompt tone: create a QTextToSpeech object (the QTextToSpeech class provides a text to speech engine) to obtain text information, and use the say() function to synthesize text.

Character recognition, camera recognition

Camera: QMultimedia contains many media related classes. QCamera class is used to open the camera device of the system, and QCameraImageCapture is used for screenshots. Use setPixmap to display the pictures intercepted by the camera (QPixmap is mainly used to display the images on the screen); realize automatic saving in a specific path.

Character recognition: create an application and obtain the API Key and Secret Key of the application. Send a post request to obtain a token through the known API Key and Secret Key of the application. Send relevant text information through the token obtained in the previous step and post to obtain the recognition result. Analyze the feedback data, judge whether it is an object, and then start analyzing the data for vehicle identification and analysis. The processed and saved pictures are displayed on the interface to identify Baidu ai and the slot function of the identification result. If successful, send data, safety judgment and serial port data.

  1. Create an application in Baidu Intelligent Cloud character recognition. The steps are as follows:

    Creating an application process on Baidu Intelligent Cloud

Through the above steps, your application will be created, as shown in the following figure:

The following is a process of creating Baidu recognition class objects and Baidu AI initialization and character recognition.

  1. Camera acquisition method

    mainwindow.h

    //Camera part
    #include <QCamera>
    #include <QCameraViewfinder>
    #include <QCameraImageCapture>
    #include <QCameraInfo>
    #include <QDebug>
    #include <QPixmap>
    
    
      //camera
     void captureImage();
     void displayImage(int,QImage);
     void saveImage();
     void imageSaved(int id,const QString &fileName);//Slot function
    
    //Photographic screenshot
    QCamera *camera;
    QCameraViewfinder *viewfinder;
    QCameraImageCapture *imageCapture;
    

    mainwindow.c

      //Camera acquisition
        camera = new QCamera(this);
        viewfinder = new QCameraViewfinder(this);
        imageCapture = new QCameraImageCapture(camera);
        ui->ImageView->addWidget(viewfinder);
        ui->image->setScaledContents(true);//Picture adaptive label size
        camera->setViewfinder(viewfinder);
        camera->start();
        connect(imageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(displayImage(int,QImage)));
        connect(ui->buttonCapture, SIGNAL(clicked()), this, SLOT(captureImage()));
        connect(imageCapture,&QCameraImageCapture::imageSaved,this,&MainWindow::imageSaved);
    
Time display

mainwindow.c

//Display date and time through QLabel control
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(timerUpdate()));
    timer->start(1000);


//current time 
void MainWindow::timerUpdate()
{
    QDateTime time = QDateTime::currentDateTime();
    QString str = time.toString("present time:yyyy-MM-dd hh:mm:ss  dddd");
    ui->dateTime->setText(str);
}
//Entry time
void MainWindow::entryTime()
{
//    UI - > label - > settext ("welcome");
    QDateTime time = QDateTime::currentDateTime();
    QString str2 = time.toString("yyyy-MM-dd hh:mm:ss");
    ui->label_2->setText(str2);
}
//Departure time
void MainWindow::leaveTime()
{
    QDateTime time = QDateTime::currentDateTime();
    QString str3 = time.toString("yyyy-MM-dd hh:mm:ss");
    ui->label_3->setText(str3);
}

achievements

main interface

Serial interface

The view record interface was written by my roommate

Operation results:

Project Download

Link: Code engineering.

Topics: C++ Qt Embedded system Single-Chip Microcomputer