16,213
社区成员
发帖
与我相关
我的任务
分享
if(camera == NULL){
camera=new QCamera(this);
connect(camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(slotStateChanged(QCamera::Status)));
connect(camera, SIGNAL(error(QCamera::Error)), this, SLOT(slotCameraError(QCamera::Error)));
}
if(viewfinder == NULL){
viewfinder=new QCameraViewfinder(this);
ui->widget->layout()->addWidget(viewfinder);
camera->setViewfinder(viewfinder);
}
if(imageCapture == NULL){
imageCapture = new QCameraImageCapture(camera);
connect(imageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(displayImage(int,QImage)));
connect(imageCapture, SIGNAL(error(int,QCameraImageCapture::Error,QString)), this, SLOT(slotError(int,QCameraImageCapture::Error,QString)));
}
imageCapture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);
imageCapture->setBufferFormat(QVideoFrame::PixelFormat::Format_Jpeg);