yuzu: Force camera output to be saved on a buffer (#8805)

merge-requests/60/head
Narr the Reg 2022-08-22 23:54:48 +07:00 committed by GitHub
parent 5503d572ab
commit db2335e2f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 2 deletions

@ -815,6 +815,12 @@ void GRenderWindow::InitializeCamera() {
if (Settings::values.ir_sensor_device.GetValue() == cameraInfo.deviceName().toStdString() || if (Settings::values.ir_sensor_device.GetValue() == cameraInfo.deviceName().toStdString() ||
Settings::values.ir_sensor_device.GetValue() == "Auto") { Settings::values.ir_sensor_device.GetValue() == "Auto") {
camera = std::make_unique<QCamera>(cameraInfo); camera = std::make_unique<QCamera>(cameraInfo);
if (!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder) &&
!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
LOG_ERROR(Frontend,
"Camera doesn't support CaptureViewfinder or CaptureStillImage");
continue;
}
camera_found = true; camera_found = true;
break; break;
} }
@ -825,10 +831,22 @@ void GRenderWindow::InitializeCamera() {
} }
camera_capture = std::make_unique<QCameraImageCapture>(camera.get()); camera_capture = std::make_unique<QCameraImageCapture>(camera.get());
if (!camera_capture->isCaptureDestinationSupported(
QCameraImageCapture::CaptureDestination::CaptureToBuffer)) {
LOG_ERROR(Frontend, "Camera doesn't support saving to buffer");
return;
}
camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
&GRenderWindow::OnCameraCapture); &GRenderWindow::OnCameraCapture);
camera->unload(); camera->unload();
if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder)) {
camera->setCaptureMode(QCamera::CaptureViewfinder); camera->setCaptureMode(QCamera::CaptureViewfinder);
} else if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
camera->setCaptureMode(QCamera::CaptureStillImage);
}
camera->load(); camera->load();
camera->start(); camera->start();

@ -42,6 +42,12 @@ void ConfigureCamera::PreviewCamera() {
LOG_INFO(Frontend, "Selected Camera {} {}", cameraInfo.description().toStdString(), LOG_INFO(Frontend, "Selected Camera {} {}", cameraInfo.description().toStdString(),
cameraInfo.deviceName().toStdString()); cameraInfo.deviceName().toStdString());
camera = std::make_unique<QCamera>(cameraInfo); camera = std::make_unique<QCamera>(cameraInfo);
if (!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder) &&
!camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
LOG_ERROR(Frontend,
"Camera doesn't support CaptureViewfinder or CaptureStillImage");
continue;
}
camera_found = true; camera_found = true;
break; break;
} }
@ -57,10 +63,22 @@ void ConfigureCamera::PreviewCamera() {
} }
camera_capture = std::make_unique<QCameraImageCapture>(camera.get()); camera_capture = std::make_unique<QCameraImageCapture>(camera.get());
if (!camera_capture->isCaptureDestinationSupported(
QCameraImageCapture::CaptureDestination::CaptureToBuffer)) {
LOG_ERROR(Frontend, "Camera doesn't support saving to buffer");
return;
}
camera_capture->setCaptureDestination(QCameraImageCapture::CaptureDestination::CaptureToBuffer);
connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this, connect(camera_capture.get(), &QCameraImageCapture::imageCaptured, this,
&ConfigureCamera::DisplayCapturedFrame); &ConfigureCamera::DisplayCapturedFrame);
camera->unload(); camera->unload();
if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureViewfinder)) {
camera->setCaptureMode(QCamera::CaptureViewfinder); camera->setCaptureMode(QCamera::CaptureViewfinder);
} else if (camera->isCaptureModeSupported(QCamera::CaptureMode::CaptureStillImage)) {
camera->setCaptureMode(QCamera::CaptureStillImage);
}
camera->load(); camera->load();
camera->start(); camera->start();