Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of decoding qcamera for Qt USB camera

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "Qt USB camera decoding qcamera method is what", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Qt USB camera decoding qcamera method is what" it!

I. Preface

In addition to special cameras for monitoring, some application scenarios still use USB cameras, and even some single-chip computers or CMOS cameras used on development boards, while Qt is widely used in the embedded field, so using Qt to read and display USB cameras and CMOS cameras is also something that many Qter have done. Qt itself encapsulates the qcamera class, which is specially used for reading and displaying local cameras. This class mainly works well on windows and Android, and it doesn't work well on the embedded system, and the qcamera of widget on Android doesn't work well, so you have to use the camera of qml, so developers are often looking for a hole to fill the hole and find the best moderate solution. For example, a mobile phone app that I have made myself needs to call the phone's camera, front and rear can also be switched, capture the picture and do some processing. Qml is embedded into widget and communicated through signal slots.

Using Qt to load USB camera decoding, there are mainly three schemes, one is Qt, the other is ffmpeg, and the other is v4l2 framework. Each scheme has its own advantages and disadvantages and corresponding application scenarios. For example, Qt is very suitable for scenes that only display cameras under windows. The code is simple and Qt is built-in and easy to use. If you need to get each picture, you have to do your own analysis and processing, such as face recognition. Using ffmpeg is the best, fast and low resource consumption, you can draw your own GPU, very cool, if it is embedded linux, then using v4l2 framework to deal with is the most suitable, native general api framework.

QCamera scenario processing flow:

Instantiate the QCamera object and bind the stateChanged signal to resize.

Instantiate the QCameraViewfinder canvas and set the QCamera object to the canvas. By default, the screen is displayed in the form of a similar handle, which is taken over by the system.

Instantiate the QCameraImageCapture object to capture the picture, if necessary.

II. Functional features

At the same time, it supports real-time acquisition of USB camera on windows, linux and embedded linux.

Support multi-channel USB camera multi-thread real-time acquisition.

On embedded linux devices, automatically find USB device files and load them.

The device file name can be set manually and loaded according to the device file set manually.

The face recognition interface is supported on the embedded linux device to draw the human face frame in real time.

With open, pause, resume, close, screenshot and other general functions.

Two OSD tags can be set, such as text, color, font size, position, etc.

It can be used as a video surveillance system.

Third, effect picture

4. Core code / / widget version static void getCameraInfo (QStringList & deviceNames, QStringList & descriptions) {# ifndef _ arm__#if (QT_VERSION > QT_VERSION_CHECK) deviceNames.clear (); descriptions.clear (); QList cameras = QCameraInfo::availableCameras (); if (cameras.count () = = 0) {qDebug () setViewfinderSettings (set) } # endif#endif} bool CameraThread::init () {# ifdef _ arm__ # else#if (QT_VERSION > QT_VERSION_CHECK) QList cameras = QCameraInfo::availableCameras (); if (cameras.count () = = 0) {qDebug () setViewfinder (viewfinder); QRect rect = frm- > rect (); viewfinder- > setAspectRatioMode (fillImage? Qt::IgnoreAspectRatio: Qt::KeepAspectRatio); int offset = borderWidth * 1 + 0; viewfinder- > setGeometry (offset / 2, offset / 2, rect.width ()-offset, rect.height ()-offset); viewfinder- > setVisible (true); imageCapture = new QCameraImageCapture (camera); connect (imageCapture, SIGNAL (imageCaptured (int, QImage)), this, SLOT (displayImage (int, QImage)); return true } # endif#endif} / / qml version import QtQuick 2.0import QtMultimedia 5.6Item {signal receiveImage () Video {id: video anchors.fill: parent / / source: "rtsp://192.168.1.247:554/av0_0" source: "g:/mp4/1.mp4" MouseArea {anchors.fill: parent onClicked: {video.play ()}} focus : true Keys.onSpacePressed: video.playbackState = = MediaPlayer.PlayingState? Video.pause (): video.play () Keys.onLeftPressed: video.seek (video.position-5000) Keys.onRightPressed: video.seek (video.position + 5000)} Thank you for reading. That's what the Qt USB camera decoding qcamera method is. After the study of this article, I believe you have a deeper understanding of what the Qt USB camera decoding qcamera method is. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report