gpt4 book ai didi

c++ - 如何使用 Qt Camera 放大/缩小?

转载 作者:行者123 更新时间:2023-11-30 05:23:09 26 4
gpt4 key购买 nike

我是 Qt 的新手,我必须在 Qt 中通过网络摄像头创建图像捕获并打印它。我已经设法完成了大部分需要执行的任务,但有一个问题,当我看到网络摄像头图像时,我想放大/缩小以捕捉图像,我该怎么做?我没有任何喜悦地搜索了网络。到目前为止我所拥有的

    ui->setupUi(this);
vCam = new QCamera(this);
vCamViewfinder = new QCameraViewfinder(this);
vCamImageCapture = new QCameraImageCapture(vCam, this);
vLayout = new QVBoxLayout;
vMenu = new QMenu("Options",this);
vStart = new QAction("Start", this);
vEnd = new QAction("End",this);
vCapture = new QAction("Capture",this);

vMenu->addActions({ vStart, vEnd, vCapture });
ui->pushButton_camAction->setMenu(vMenu);
vCam->setViewfinder(vCamViewfinder);
vLayout->addWidget(vCamViewfinder);
vLayout->setMargin(0);
ui->graphicsView->setLayout(vLayout);

connect(vStart, &QAction::triggered, [&](){
vCam->start();
});
connect(vEnd, &QAction::triggered, [&](){
vCam->stop();
});
connect(vCapture, &QAction::triggered, [&](){
on_pushButton_camAction_clicked();
});

void VisitorSignIn::on_pushButton_camAction_clicked()
{
QString vImage = "C:/Qt/VisitorsImages/1.jpg";
vCamImageCapture->setCaptureDestination(QCameraImageCapture::CaptureToFile);
QImageEncoderSettings imgEncSet;
imgEncSet.setCodec("image/jpeg");
imgEncSet.setResolution(640, 480);
vCamImageCapture->setEncodingSettings(imgEncSet);
vCam->setCaptureMode(QCamera::CaptureStillImage);
vCam->start();
vCam->searchAndLock();
vCamImageCapture->capture(vImage);
vCam->unlock();
}

最佳答案

看看http://doc.qt.io/qt-5/qcamerafocus.html这些方法允许光学和数字变焦。

关于c++ - 如何使用 Qt Camera 放大/缩小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39334562/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com