当前位置:网站首页>QT - connect USB camera
QT - connect USB camera
2022-07-26 11:17:00 【vhcjgc】
function : Use QT Connect USB camera , Click the button to display the screen
QT += multimedia
QT += multimediawidgets
#include "camera.h"
#include "ui_camera.h"
Camera::Camera(QWidget *parent) :
QWidget(parent),
ui(new Ui::Camera)
{
ui->setupUi(this);
iniCamera();
}
Camera::~Camera()
{
delete ui;
}
void Camera::iniCamera()
{
cameras = QCameraInfo::availableCameras();// Get a list of cameras
qDebug()<<cameras.size();
for(int i = 0;i<cameras.size();i++)
ui->comboCamera->addItem(cameras[i].description());// Camera description
}
void Camera::on_camStartBtn_clicked()
{
curCamera=new QCamera(cameras[ui->comboCamera->currentIndex()],this);// newly build QCamera
curCamera->setViewfinder(ui->widget); // Set viewfinder preview
curCamera->start();
}
#ifndef CAMERA_H
#define CAMERA_H
#include <QWidget>
#include <QCameraInfo>
#include <QCamera>
#include <QLabel>
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QMediaRecorder>
namespace Ui {
class Camera;
}
class Camera : public QWidget
{
Q_OBJECT
public:
explicit Camera(QWidget *parent = nullptr);
~Camera();
void iniCamera();// Camera initialization
QCamera *curCamera=Q_NULLPTR;//
QList<QCameraInfo> cameras;// List of available cameras
QCameraImageCapture *imageCapture; // Screenshots
QMediaRecorder* mediaRecorder;// videotape
private slots:
void on_camStartBtn_clicked();
private:
Ui::Camera *ui;
};
#endif // CAMERA_H

Realization effect

边栏推荐
- pytest 前后置方法
- [development tool] ieda red
- 104. Maximum depth of binary tree
- 产品无力销量下滑 上汽名爵还能否走出阴霾
- easyui02
- [idea]如何新建一个项目
- Can SAIC mingjue get out of the haze if its products are unable to sell and decline
- pytest pytest.ini配置 用例分组 用例跳过
- pytest pytest. Ini configuration case grouping case skipping
- Visual conversion of nmap vulnerability scanning results
猜你喜欢
随机推荐
Bash shell learning notes (VII)
常用库安装
像素和内存的关系
Generation and transformation of pulse waveform
Pytest case execution sequence
win10 1903 笔记本开热点出现蓝屏问题
LE Audio规范概述
Pytest execution rules_ Basic usage_ Common plug-ins_ Common assertions_ Common parameters
-bash: ./build. Sh: /bin/bash^m: bad interpreter: no that file or directory
[development tool] ieda red
pytest 执行规则_基本用法_常用插件_常用断言_常用参数
Solve the problem of the popularity of org.apache.commons.codec.binary.base64
logging基本使用
ISO 639:1988 : Code for the representation of names of languages
LinkedList of source code
mysql数据库进阶
Bash shell learning notes (V)
In depth interpretation of happens before principle
菜鸟看源码之HashTable
Dichotomous template summary






![[idea]如何新建一个项目](/img/33/f210d59ccd3664487f401929dac24c.png)


