Qt writing security video monitoring system 21 camera management

Posted by raquelzinha on Sun, 29 Dec 2019 09:04:50 +0100

I. Preface

Camera management is the core of the database in the whole system. Only when the camera information is added can it be loaded and a tree list be generated. The field content of the camera table information has been changed several times and may need to be modified later. At present, the camera table information mainly includes camera number, camera name, video recorder, manufacturer, equipment address and media Address, PTZ address, main stream address, sub stream address, latitude and longitude, background map, X coordinate, Y coordinate, user name, user password, enabling status, installation location. Among them, the device address, media address, PTZ address, main code stream address and sub code stream address are obtained when searching the device through onvif. The code stream address is required, and the other three can be empty, which are used for PTZ control. The background map represents the name of the image file of the image map module corresponding to the camera. By default, it is in the map folder under the same executable directory. The XY coordinate is the location on the corresponding map, the longitude and latitude are the location in the online map and the offline map. The user name and password are the user information corresponding to onvif to log in to the camera. The user name and password information must be correct, otherwise, in the cloud The console control will fail. Each time the data sent by the PTZ control has user information. If the user information is incorrect, it will fail to execute. This user is different from the login user of the camera's web interface. Generally, it is set in the background of the camera where the onvif user information is.

Open source address of paging component: https://gitee.com/feiyangqingyun/QWidgetDemo https://github.com/feiyangqingyun/QWidgetDemo File name: dbpage

Experience address: https://gitee.com/feiyangqingyun/QWidgetExe https://github.com/feiyangqingyun/QWidgetExe File name: Bin video system.zip

2, Functional features

  1. Support 16 screen switching, full screen switching, etc., including 1 + 4 + 6 + 8 + 9 + 13 + 16 screen switching.
  2. Support alt+enter full screen, esc exit full screen.
  3. Custom message box + error box + inquiry box + prompt box at the bottom right corner.
  4. 17 sets of skin styles are changed at will, all styles are unified, including menu, etc.
  5. Move the mouse on the dashboard of the platform to highlight and identify eight directions accurately.
  6. The bottom screen toolbar (screen segmentation switch + screenshot sound and other settings) is moved up to highlight.
  7. You can change the logo + Chinese software name + English software name in the upper left corner of the configuration file.
  8. Package Baidu map, three-dimensional switching, equipment point, mouse click to get latitude and longitude.
  9. Stack form, each form is a separate qwidget, convenient to write their own code.
  10. The top right mouse button menu can dynamically control the display and hide of time CPU + upper left corner panel + lower left corner panel + upper right corner panel + lower right corner panel, and support to restore the default layout.
  11. The toolbar can place multiple small icons and close icons.
  12. The left and right sides can be dragged and stretched, and the width and height positions can be memorized automatically, which can be recovered after restart.
  13. Double click the camera node to automatically play the video, double-click the node to automatically add the video in turn, and it will automatically jump to the next one, double-click the parent node to automatically add all the videos under the node.
  14. The camera node can be dragged to the corresponding form to play the video, and the local file can be dragged to play directly.
  15. The video window supports drag switching and instant response.
  16. Double click the node + drag the node + drag the form exchange location, and the url.txt will be updated automatically.
  17. It supports loading 16 channels of video from url.txt to play, automatically remembering the corresponding video of the last channel, and automatically opening and playing after the software is started.
  18. The volume bar control in the lower right corner automatically hides when the focus is lost, and the volume bar mute icon.
  19. Integrated with Baidu map, you can add the corresponding location of the device, automatically generate the map, support zoom and 3D map, and provide the choice of map style, a total of 12 styles.
  20. Drag the video outside the channel form to automatically delete the video.
  21. Right click to delete current + all videos, screenshot current + all videos.
  22. VCR management, camera management, can add, delete, modify, import, export and print information, apply new device information to generate tree list immediately, without restart.
  23. Whether to load the map can be opened freely in pro file.
  24. Four kinds of cores can be selected for video playback, vlc+ffmpeg+easyplayer + Haikang sdk, which can be set in pro.
  25. 1 + 4 + 9 + 16 screen polling can be set, polling interval and polling code stream type can be set. Click the start polling button directly on the right side of the toolbar at the bottom of the main interface, and then click stop polling again.
  26. The mouse pointer is not automatically hidden by default for more than 10 seconds.
  27. Support the onvif search equipment, support any onvif camera, including but not limited to the Huawei of Haikang Dahua Yushi Tiandi Weiye, etc., and support the onvif PTZ control.
  28. Highly customizable, users can easily derive their own functions on this basis, supporting linux system.

3, Renderings

4, Core code

void frmConfigIpc::on_btnAdd_clicked()
{
    int count = model->rowCount();
    model->insertRow(count);

    int ipcID = model->index(count - 1, 0).data().toInt() + 1;
    QString ipcName = model->index(count - 1, 1).data().toString();
    QString nvrName = model->index(count - 1, 2).data().toString();
    QString ipcType = model->index(count - 1, 3).data().toString();
    QString onvifAddr = model->index(count - 1, 4).data().toString();
    QString mediaAddr = model->index(count - 1, 5).data().toString();
    QString ptzAddr = model->index(count - 1, 6).data().toString();
    QString rtspMain = model->index(count - 1, 7).data().toString();
    QString rtspSub = model->index(count - 1, 8).data().toString();
    QString ipcPosition = model->index(count - 1, 9).data().toString();
    QString ipcImage = model->index(count - 1, 10).data().toString();
    int ipcX = model->index(count - 1, 11).data().toInt();
    int ipcY = model->index(count - 1, 12).data().toInt();
    QString userName = model->index(count - 1, 13).data().toString();
    QString userPwd = model->index(count - 1, 14).data().toString();
    QString ipcEnable = model->index(count - 1, 15).data().toString();
    QString ipcAddr = model->index(count - 1, 16).data().toString();

    if (ipcName.startsWith("Video camera#")) {
        ipcName = QString("Video camera#%1").arg(ipcID);
    }

    ipcX += App::DeviceWidth;
    if (ipcX > App::MapWidth - 100) {
        ipcX = 5;
        ipcY += App::DeviceHeight;
    }

    if (count == 0) {
        ipcID = 1;
        ipcName = "Video camera#1";
        nvrName = "Video recorder#1";

        ipcType = "other";
        //onvifAddr = "http://192.168.1.128/onvif/device_service";
        //mediaAddr = "http://192.168.1.128//onvif/media_service";
        //ptzAddr = "http://192.168.1.128//onvif/ptz_service";
        rtspMain = "rtsp://192.168.1.128:554/0";
        rtspSub = "rtsp://192.168.1.128:554/1";
        ipcPosition = "121.534942,31.307706";
        ipcImage = "nothing";
        ipcX = 5;
        ipcY = 5;
        userName = "admin";
        userPwd = "admin";
        ipcEnable = "Enable";
        ipcAddr = "Installation position of video recorder";
    }

    //Set new row defaults
    model->setData(model->index(count, 0), ipcID);
    model->setData(model->index(count, 1), ipcName);
    model->setData(model->index(count, 2), nvrName);
    model->setData(model->index(count, 3), ipcType);
    model->setData(model->index(count, 4), onvifAddr);
    model->setData(model->index(count, 5), mediaAddr);
    model->setData(model->index(count, 6), ptzAddr);
    model->setData(model->index(count, 7), rtspMain);
    model->setData(model->index(count, 8), rtspSub);
    model->setData(model->index(count, 9), ipcPosition);
    model->setData(model->index(count, 10), ipcImage);
    model->setData(model->index(count, 11), ipcX);
    model->setData(model->index(count, 12), ipcY);
    model->setData(model->index(count, 13), userName);
    model->setData(model->index(count, 14), userPwd);
    model->setData(model->index(count, 15), ipcEnable);
    model->setData(model->index(count, 16), ipcAddr);
    ui->tableView->setCurrentIndex(model->index(count, 0));
}

void frmConfigIpc::on_btnSave_clicked()
{
    model->database().transaction();
    if (model->submitAll()) {
        model->database().commit();
        DBHelper::loadIpcInfo();
        DeviceHelper::initDeviceTree();
        DeviceHelper::initVideoIcon();
        DeviceHelper::initDeviceMap();
        DeviceHelper::initDeviceButton();
        AppEvent::Instance()->slot_saveIpcInfo();
    } else {
        model->database().rollback();
        QUIHelper::showMessageBoxError("Failed to save information,Information cannot be empty,Please fill in again!");
    }
}

void frmConfigIpc::on_btnDelete_clicked()
{
    if (ui->tableView->currentIndex().row() < 0) {
        QUIHelper::showMessageBoxError("Please select the camera to delete!");
        return;
    }

    if (QUIHelper::showMessageBoxQuestion("Are you sure you want to delete this camera? Cannot recover after deletion!") == QMessageBox::Yes) {
        int row = ui->tableView->currentIndex().row();
        model->removeRow(row);
        model->submitAll();
        ui->tableView->setCurrentIndex(model->index(model->rowCount() - 1, 0));
        DBHelper::loadIpcInfo();
        DeviceHelper::initDeviceTree();
        DeviceHelper::initVideoIcon();
        AppEvent::Instance()->slot_saveIpcInfo();
    }
}

void frmConfigIpc::on_btnReturn_clicked()
{
    model->revertAll();
}

void frmConfigIpc::on_btnClear_clicked()
{
    if (model->rowCount() <= 0) {
        return;
    }

    if (QUIHelper::showMessageBoxQuestion("Are you sure you want to clear all camera information?") == QMessageBox::Yes) {
        DBHelper::clearIpcInfo();
        model->select();
        DBHelper::loadIpcInfo();
        DeviceHelper::initDeviceTree();
        DeviceHelper::initVideoIcon();
        AppEvent::Instance()->slot_saveIpcInfo();
    }
}

Topics: Database github SDK Linux