camera: Add camera flip config
This commit is contained in:
parent
8e02c70e82
commit
5ebd466869
16 changed files with 416 additions and 282 deletions
|
@ -155,14 +155,20 @@ void Config::ReadValues() {
|
|||
sdl2_config->Get("Camera", "camera_outer_right_name", "blank");
|
||||
Settings::values.camera_config[OuterRightCamera] =
|
||||
sdl2_config->Get("Camera", "camera_outer_right_config", "");
|
||||
Settings::values.camera_flip[OuterRightCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_outer_right_flip", 0);
|
||||
Settings::values.camera_name[InnerCamera] =
|
||||
sdl2_config->Get("Camera", "camera_inner_name", "blank");
|
||||
Settings::values.camera_config[InnerCamera] =
|
||||
sdl2_config->Get("Camera", "camera_inner_config", "");
|
||||
Settings::values.camera_flip[InnerCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_inner_flip", 0);
|
||||
Settings::values.camera_name[OuterLeftCamera] =
|
||||
sdl2_config->Get("Camera", "camera_outer_left_name", "blank");
|
||||
Settings::values.camera_config[OuterLeftCamera] =
|
||||
sdl2_config->Get("Camera", "camera_outer_left_config", "");
|
||||
Settings::values.camera_flip[OuterLeftCamera] =
|
||||
sdl2_config->GetInteger("Camera", "camera_outer_left_flip", 0);
|
||||
|
||||
// Miscellaneous
|
||||
Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Info");
|
||||
|
|
|
@ -178,13 +178,19 @@ camera_outer_right_name =
|
|||
# A config string for the right outer camera. Its meaning is defined by the camera engine
|
||||
camera_outer_right_config =
|
||||
|
||||
# The image flip to apply
|
||||
# 0: None (default), 1: Horizontal, 2: Vertical, 3: Reverse
|
||||
camera_outer_right_flip =
|
||||
|
||||
# ... for the left outer camera
|
||||
camera_outer_left_name =
|
||||
camera_outer_left_config =
|
||||
camera_outer_left_flip =
|
||||
|
||||
# ... for the inner camera
|
||||
camera_inner_name =
|
||||
camera_inner_config =
|
||||
camera_inner_flip =
|
||||
|
||||
[Miscellaneous]
|
||||
# A filter which removes logs below a certain logging level.
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
namespace Camera {
|
||||
|
||||
std::unique_ptr<CameraInterface> QtCameraFactory::CreatePreview(const std::string& config,
|
||||
int width, int height) const {
|
||||
std::unique_ptr<CameraInterface> camera = Create(config);
|
||||
std::unique_ptr<CameraInterface> QtCameraFactory::CreatePreview(
|
||||
const std::string& config, int width, int height, const Service::CAM::Flip& flip) const {
|
||||
std::unique_ptr<CameraInterface> camera = Create(config, flip);
|
||||
|
||||
if (camera->IsPreviewAvailable()) {
|
||||
return camera;
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace Camera {
|
|||
|
||||
// Base class for camera factories of citra_qt
|
||||
class QtCameraFactory : public CameraFactory {
|
||||
std::unique_ptr<CameraInterface> CreatePreview(const std::string& config, int width,
|
||||
int height) const override;
|
||||
std::unique_ptr<CameraInterface> CreatePreview(const std::string& config, int width, int height,
|
||||
const Service::CAM::Flip& flip) const override;
|
||||
};
|
||||
|
||||
} // namespace Camera
|
||||
|
|
|
@ -46,7 +46,8 @@ bool QtCameraSurface::present(const QVideoFrame& frame) {
|
|||
return true;
|
||||
}
|
||||
|
||||
QtMultimediaCamera::QtMultimediaCamera(const std::string& camera_name)
|
||||
QtMultimediaCamera::QtMultimediaCamera(const std::string& camera_name,
|
||||
const Service::CAM::Flip& flip)
|
||||
: handler(QtMultimediaCameraHandler::GetHandler()) {
|
||||
if (handler->thread() == QThread::currentThread()) {
|
||||
handler->CreateCamera(camera_name);
|
||||
|
@ -54,6 +55,9 @@ QtMultimediaCamera::QtMultimediaCamera(const std::string& camera_name)
|
|||
QMetaObject::invokeMethod(handler.get(), "CreateCamera", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(const std::string&, camera_name));
|
||||
}
|
||||
using namespace Service::CAM;
|
||||
flip_horizontal = basic_flip_horizontal = (flip == Flip::Horizontal) || (flip == Flip::Reverse);
|
||||
flip_vertical = basic_flip_vertical = (flip == Flip::Vertical) || (flip == Flip::Reverse);
|
||||
}
|
||||
|
||||
QtMultimediaCamera::~QtMultimediaCamera() {
|
||||
|
@ -107,8 +111,8 @@ void QtMultimediaCamera::SetResolution(const Service::CAM::Resolution& resolutio
|
|||
|
||||
void QtMultimediaCamera::SetFlip(Service::CAM::Flip flip) {
|
||||
using namespace Service::CAM;
|
||||
flip_horizontal = (flip == Flip::Horizontal) || (flip == Flip::Reverse);
|
||||
flip_vertical = (flip == Flip::Vertical) || (flip == Flip::Reverse);
|
||||
flip_horizontal = basic_flip_horizontal ^ (flip == Flip::Horizontal || flip == Flip::Reverse);
|
||||
flip_vertical = basic_flip_vertical ^ (flip == Flip::Vertical || flip == Flip::Reverse);
|
||||
}
|
||||
|
||||
void QtMultimediaCamera::SetEffect(Service::CAM::Effect effect) {
|
||||
|
@ -128,8 +132,8 @@ bool QtMultimediaCamera::IsPreviewAvailable() {
|
|||
}
|
||||
|
||||
std::unique_ptr<CameraInterface> QtMultimediaCameraFactory::Create(
|
||||
const std::string& config) const {
|
||||
return std::make_unique<QtMultimediaCamera>(config);
|
||||
const std::string& config, const Service::CAM::Flip& flip) const {
|
||||
return std::make_unique<QtMultimediaCamera>(config, flip);
|
||||
}
|
||||
|
||||
std::array<std::shared_ptr<QtMultimediaCameraHandler>, 3> QtMultimediaCameraHandler::handlers;
|
||||
|
|
|
@ -38,7 +38,7 @@ class QtMultimediaCameraHandler;
|
|||
/// This class is only an interface. It just calls QtMultimediaCameraHandler.
|
||||
class QtMultimediaCamera final : public CameraInterface {
|
||||
public:
|
||||
QtMultimediaCamera(const std::string& camera_name);
|
||||
QtMultimediaCamera(const std::string& camera_name, const Service::CAM::Flip& flip);
|
||||
~QtMultimediaCamera();
|
||||
void StartCapture() override;
|
||||
void StopCapture() override;
|
||||
|
@ -55,11 +55,13 @@ private:
|
|||
int width, height;
|
||||
bool output_rgb;
|
||||
bool flip_horizontal, flip_vertical;
|
||||
bool basic_flip_horizontal, basic_flip_vertical;
|
||||
};
|
||||
|
||||
class QtMultimediaCameraFactory final : public QtCameraFactory {
|
||||
public:
|
||||
std::unique_ptr<CameraInterface> Create(const std::string& config) const override;
|
||||
std::unique_ptr<CameraInterface> Create(const std::string& config,
|
||||
const Service::CAM::Flip& flip) const override;
|
||||
};
|
||||
|
||||
class QtMultimediaCameraHandler final : public QObject {
|
||||
|
|
|
@ -9,7 +9,12 @@
|
|||
|
||||
namespace Camera {
|
||||
|
||||
StillImageCamera::StillImageCamera(QImage image_) : image(std::move(image_)) {}
|
||||
StillImageCamera::StillImageCamera(QImage image_, const Service::CAM::Flip& flip)
|
||||
: image(std::move(image_)) {
|
||||
using namespace Service::CAM;
|
||||
flip_horizontal = basic_flip_horizontal = (flip == Flip::Horizontal) || (flip == Flip::Reverse);
|
||||
flip_vertical = basic_flip_vertical = (flip == Flip::Vertical) || (flip == Flip::Reverse);
|
||||
}
|
||||
|
||||
void StillImageCamera::StartCapture() {}
|
||||
|
||||
|
@ -26,8 +31,8 @@ void StillImageCamera::SetResolution(const Service::CAM::Resolution& resolution)
|
|||
|
||||
void StillImageCamera::SetFlip(Service::CAM::Flip flip) {
|
||||
using namespace Service::CAM;
|
||||
flip_horizontal = (flip == Flip::Horizontal) || (flip == Flip::Reverse);
|
||||
flip_vertical = (flip == Flip::Vertical) || (flip == Flip::Reverse);
|
||||
flip_horizontal = basic_flip_horizontal ^ (flip == Flip::Horizontal || flip == Flip::Reverse);
|
||||
flip_vertical = basic_flip_vertical ^ (flip == Flip::Vertical || flip == Flip::Reverse);
|
||||
}
|
||||
|
||||
void StillImageCamera::SetEffect(Service::CAM::Effect effect) {
|
||||
|
@ -58,7 +63,8 @@ const std::string StillImageCameraFactory::getFilePath() {
|
|||
.toStdString();
|
||||
}
|
||||
|
||||
std::unique_ptr<CameraInterface> StillImageCameraFactory::Create(const std::string& config) const {
|
||||
std::unique_ptr<CameraInterface> StillImageCameraFactory::Create(
|
||||
const std::string& config, const Service::CAM::Flip& flip) const {
|
||||
std::string real_config = config;
|
||||
if (config.empty()) {
|
||||
real_config = getFilePath();
|
||||
|
@ -67,7 +73,7 @@ std::unique_ptr<CameraInterface> StillImageCameraFactory::Create(const std::stri
|
|||
if (image.isNull()) {
|
||||
NGLOG_ERROR(Service_CAM, "Couldn't load image \"{}\"", real_config.c_str());
|
||||
}
|
||||
return std::make_unique<StillImageCamera>(image);
|
||||
return std::make_unique<StillImageCamera>(image, flip);
|
||||
}
|
||||
|
||||
} // namespace Camera
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Camera {
|
|||
|
||||
class StillImageCamera final : public CameraInterface {
|
||||
public:
|
||||
StillImageCamera(QImage image);
|
||||
StillImageCamera(QImage image, const Service::CAM::Flip& flip);
|
||||
void StartCapture() override;
|
||||
void StopCapture() override;
|
||||
void SetResolution(const Service::CAM::Resolution&) override;
|
||||
|
@ -30,11 +30,13 @@ private:
|
|||
int width, height;
|
||||
bool output_rgb;
|
||||
bool flip_horizontal, flip_vertical;
|
||||
bool basic_flip_horizontal, basic_flip_vertical;
|
||||
};
|
||||
|
||||
class StillImageCameraFactory final : public QtCameraFactory {
|
||||
public:
|
||||
std::unique_ptr<CameraInterface> Create(const std::string& config) const override;
|
||||
std::unique_ptr<CameraInterface> Create(const std::string& config,
|
||||
const Service::CAM::Flip& flip) const override;
|
||||
|
||||
private:
|
||||
static const std::string getFilePath();
|
||||
|
|
|
@ -128,14 +128,19 @@ void Config::ReadValues() {
|
|||
qt_config->value("camera_outer_right_name", "blank").toString().toStdString();
|
||||
Settings::values.camera_config[OuterRightCamera] =
|
||||
qt_config->value("camera_outer_right_config", "").toString().toStdString();
|
||||
Settings::values.camera_flip[OuterRightCamera] =
|
||||
qt_config->value("camera_outer_right_flip", "0").toInt();
|
||||
Settings::values.camera_name[InnerCamera] =
|
||||
qt_config->value("camera_inner_name", "blank").toString().toStdString();
|
||||
Settings::values.camera_config[InnerCamera] =
|
||||
qt_config->value("camera_inner_config", "").toString().toStdString();
|
||||
Settings::values.camera_flip[InnerCamera] = qt_config->value("camera_inner_flip", "").toInt();
|
||||
Settings::values.camera_name[OuterLeftCamera] =
|
||||
qt_config->value("camera_outer_left_name", "blank").toString().toStdString();
|
||||
Settings::values.camera_config[OuterLeftCamera] =
|
||||
qt_config->value("camera_outer_left_config", "").toString().toStdString();
|
||||
Settings::values.camera_flip[OuterLeftCamera] =
|
||||
qt_config->value("camera_outer_left_flip", "").toInt();
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Data Storage");
|
||||
|
@ -317,14 +322,17 @@ void Config::SaveValues() {
|
|||
QString::fromStdString(Settings::values.camera_name[OuterRightCamera]));
|
||||
qt_config->setValue("camera_outer_right_config",
|
||||
QString::fromStdString(Settings::values.camera_config[OuterRightCamera]));
|
||||
qt_config->setValue("camera_outer_right_flip", Settings::values.camera_flip[OuterRightCamera]);
|
||||
qt_config->setValue("camera_inner_name",
|
||||
QString::fromStdString(Settings::values.camera_name[InnerCamera]));
|
||||
qt_config->setValue("camera_inner_config",
|
||||
QString::fromStdString(Settings::values.camera_config[InnerCamera]));
|
||||
qt_config->setValue("camera_inner_flip", Settings::values.camera_flip[InnerCamera]);
|
||||
qt_config->setValue("camera_outer_left_name",
|
||||
QString::fromStdString(Settings::values.camera_name[OuterLeftCamera]));
|
||||
qt_config->setValue("camera_outer_left_config",
|
||||
QString::fromStdString(Settings::values.camera_config[OuterLeftCamera]));
|
||||
qt_config->setValue("camera_outer_left_flip", Settings::values.camera_flip[OuterLeftCamera]);
|
||||
qt_config->endGroup();
|
||||
|
||||
qt_config->beginGroup("Data Storage");
|
||||
|
|
|
@ -27,14 +27,7 @@ ConfigureCamera::ConfigureCamera(QWidget* parent)
|
|||
// Load settings
|
||||
camera_name = Settings::values.camera_name;
|
||||
camera_config = Settings::values.camera_config;
|
||||
for (auto&& item : camera_name) {
|
||||
if (item == "opencv") {
|
||||
QMessageBox::critical(this, tr("Error"),
|
||||
tr("Sorry, Citra has removed support for OpenCV cameras.\n\nYour "
|
||||
"existing OpenCV cameras have been replaced with Blank."));
|
||||
item = "blank";
|
||||
}
|
||||
}
|
||||
camera_flip = Settings::values.camera_flip;
|
||||
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
||||
for (const QCameraInfo& cameraInfo : cameras) {
|
||||
ui->system_camera->addItem(cameraInfo.deviceName());
|
||||
|
@ -98,6 +91,8 @@ void ConfigureCamera::connectEvents() {
|
|||
connect(ui->system_camera,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||
[=] { stopPreviewing(); });
|
||||
connect(ui->camera_flip, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, [=] { stopPreviewing(); });
|
||||
}
|
||||
|
||||
void ConfigureCamera::updateCameraMode() {
|
||||
|
@ -148,6 +143,8 @@ void ConfigureCamera::updateImageSourceUI() {
|
|||
}
|
||||
ui->system_camera_label->setHidden(image_source != 2);
|
||||
ui->system_camera->setHidden(image_source != 2);
|
||||
ui->camera_flip_label->setHidden(image_source == 0);
|
||||
ui->camera_flip->setHidden(image_source == 0);
|
||||
}
|
||||
|
||||
void ConfigureCamera::recordConfig() {
|
||||
|
@ -166,10 +163,12 @@ void ConfigureCamera::recordConfig() {
|
|||
if (current_selected == CameraPosition::RearBoth) {
|
||||
camera_name[0] = camera_name[2] = implementation;
|
||||
camera_config[0] = camera_config[2] = config;
|
||||
camera_flip[0] = camera_flip[2] = ui->camera_flip->currentIndex();
|
||||
} else if (current_selected != CameraPosition::Null) {
|
||||
int index = static_cast<int>(current_selected);
|
||||
camera_name[index] = implementation;
|
||||
camera_config[index] = config;
|
||||
camera_flip[index] = ui->camera_flip->currentIndex();
|
||||
}
|
||||
current_selected = getCameraSelection();
|
||||
}
|
||||
|
@ -187,9 +186,9 @@ void ConfigureCamera::startPreviewing() {
|
|||
ui->preview_box->setToolTip(tr("Resolution: ") + QString::number(preview_width) + "*" +
|
||||
QString::number(preview_height));
|
||||
// Load previewing camera
|
||||
previewing_camera =
|
||||
Camera::CreateCameraPreview(camera_name[camera_selection], camera_config[camera_selection],
|
||||
preview_width, preview_height);
|
||||
previewing_camera = Camera::CreateCameraPreview(
|
||||
camera_name[camera_selection], camera_config[camera_selection], preview_width,
|
||||
preview_height, static_cast<Service::CAM::Flip>(camera_flip[camera_selection]));
|
||||
if (!previewing_camera) {
|
||||
stopPreviewing();
|
||||
return;
|
||||
|
@ -262,6 +261,7 @@ void ConfigureCamera::setConfiguration() {
|
|||
} else {
|
||||
ui->camera_file->setText(QString::fromStdString(camera_config[index]));
|
||||
}
|
||||
ui->camera_flip->setCurrentIndex(camera_flip[index]);
|
||||
updateImageSourceUI();
|
||||
}
|
||||
|
||||
|
@ -288,6 +288,7 @@ void ConfigureCamera::applyConfiguration() {
|
|||
stopPreviewing();
|
||||
Settings::values.camera_name = camera_name;
|
||||
Settings::values.camera_config = camera_config;
|
||||
Settings::values.camera_flip = camera_flip;
|
||||
Settings::Apply();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
std::unique_ptr<Ui::ConfigureCamera> ui;
|
||||
std::array<std::string, 3> camera_name;
|
||||
std::array<std::string, 3> camera_config;
|
||||
std::array<int, 3> camera_flip;
|
||||
int timer_id = 0;
|
||||
int preview_width = 0;
|
||||
int preview_height = 0;
|
||||
|
|
|
@ -1,257 +1,347 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<ui version="4.0">
|
||||
<class>ConfigureCamera</class>
|
||||
<widget class="QWidget" name="ConfigureCamera">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<class>ConfigureCamera</class>
|
||||
<widget class="QWidget" name="ConfigureCamera">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Camera</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Camera</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_selection_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera to configure</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_selection_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera to configure</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera to configure:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_selection">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera to configure</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Front</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rear</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_mode_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera mode (single or double)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_mode">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera mode (single or double)</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Single (2D)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Double (3D)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_position_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the position of camera to configure</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_position">
|
||||
<property name="toolTip">
|
||||
<string>Select the position of camera to configure</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>Camera to configure:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_selection">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera to configure</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Front</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Rear</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="configurationBox">
|
||||
<property name="title">
|
||||
<string>Configuration</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_mode_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera mode (single or double)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_configuration">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="image_source_label">
|
||||
<property name="toolTip">
|
||||
<string>Select where the image of the emulated camera comes from. It may be an image or a real camera.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera Image Source:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="image_source">
|
||||
<property name="toolTip">
|
||||
<string>Select where the image of the emulated camera come from. It may be an image or a real camera.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Blank (blank)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Still Image (image)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System Camera (qt)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_file_label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="camera_file"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="system_camera_label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="system_camera">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string><Default></string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="prompt_before_load">
|
||||
<property name="text">
|
||||
<string>Prompt before load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>Camera mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_mode">
|
||||
<property name="toolTip">
|
||||
<string>Select the camera mode (single or double)</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Single (2D)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Double (3D)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="previewBox">
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_position_label">
|
||||
<property name="toolTip">
|
||||
<string>Select the position of camera to configure</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="preview_box">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>512</width>
|
||||
<height>384</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Resolution: 512*384</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="preview_button">
|
||||
<property name="text">
|
||||
<string>Click to preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>Camera position:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_position">
|
||||
<property name="toolTip">
|
||||
<string>Select the position of camera to configure</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="configurationBox">
|
||||
<property name="title">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_configuration">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="image_source_label">
|
||||
<property name="toolTip">
|
||||
<string>Select where the image of the emulated camera comes from. It may be an image or a real camera.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera Image Source:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="image_source">
|
||||
<property name="toolTip">
|
||||
<string>Select where the image of the emulated camera comes from. It may be an image or a real camera.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Blank (blank)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Still Image (image)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System Camera (qt)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_file_label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="camera_file"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="system_camera_label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the system camera to use</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Camera:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="system_camera">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the system camera to use</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string><Default></string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="camera_flip_label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the image flip to apply</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Flip:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="camera_flip">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>800</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select the image flip to apply</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Reverse</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="prompt_before_load">
|
||||
<property name="toolTip">
|
||||
<string>Select an image file every time before the camera is loaded</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prompt before load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="previewBox">
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="preview_box">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>512</width>
|
||||
<height>384</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Resolution: 512*384</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="preview_button">
|
||||
<property name="text">
|
||||
<string>Click to preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -17,10 +17,11 @@ void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> fac
|
|||
factories[name] = std::move(factory);
|
||||
}
|
||||
|
||||
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config) {
|
||||
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config,
|
||||
const Service::CAM::Flip& flip) {
|
||||
auto pair = factories.find(name);
|
||||
if (pair != factories.end()) {
|
||||
return pair->second->Create(config);
|
||||
return pair->second->Create(config, flip);
|
||||
}
|
||||
|
||||
if (name != "blank") {
|
||||
|
@ -31,10 +32,10 @@ std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std
|
|||
|
||||
std::unique_ptr<CameraInterface> CreateCameraPreview(const std::string& name,
|
||||
const std::string& config, int width,
|
||||
int height) {
|
||||
int height, const Service::CAM::Flip& flip) {
|
||||
auto pair = factories.find(name);
|
||||
if (pair != factories.end()) {
|
||||
return pair->second->CreatePreview(config, width, height);
|
||||
return pair->second->CreatePreview(config, width, height, flip);
|
||||
}
|
||||
|
||||
if (name != "blank") {
|
||||
|
|
|
@ -18,22 +18,26 @@ public:
|
|||
* Creates a camera object based on the configuration string.
|
||||
* @param config Configuration string to create the camera. The implementation can decide the
|
||||
* meaning of this string.
|
||||
* @param flip The image flip to apply
|
||||
* @returns a unique_ptr to the created camera object.
|
||||
*/
|
||||
virtual std::unique_ptr<CameraInterface> Create(const std::string& config) const = 0;
|
||||
virtual std::unique_ptr<CameraInterface> Create(const std::string& config,
|
||||
const Service::CAM::Flip& flip) const = 0;
|
||||
|
||||
/**
|
||||
* Creates a camera object for preview based on the configuration string.
|
||||
* @param config Configuration string to create the camera. The implementation can decide the
|
||||
* meaning of this string.
|
||||
* @param flip The image flip to apply
|
||||
* @returns a unique_ptr to the created camera object.
|
||||
* Note: The default implementation for this is to call Create(). Derived classes may have other
|
||||
* Implementations. For example, A dialog may be used instead of LOG_ERROR when error
|
||||
* occurs.
|
||||
*/
|
||||
virtual std::unique_ptr<CameraInterface> CreatePreview(const std::string& config, int width,
|
||||
int height) const {
|
||||
return Create(config);
|
||||
int height,
|
||||
const Service::CAM::Flip& flip) const {
|
||||
return Create(config, flip);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,7 +54,8 @@ void RegisterFactory(const std::string& name, std::unique_ptr<CameraFactory> fac
|
|||
* @param config Configuration string to create the camera. The meaning of this string is
|
||||
* defined by the factory.
|
||||
*/
|
||||
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config);
|
||||
std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std::string& config,
|
||||
const Service::CAM::Flip& flip);
|
||||
|
||||
/**
|
||||
* Creates a camera from the factory for previewing.
|
||||
|
@ -60,6 +65,6 @@ std::unique_ptr<CameraInterface> CreateCamera(const std::string& name, const std
|
|||
*/
|
||||
std::unique_ptr<CameraInterface> CreateCameraPreview(const std::string& name,
|
||||
const std::string& config, int width,
|
||||
int height);
|
||||
int height, const Service::CAM::Flip& flip);
|
||||
|
||||
} // namespace Camera
|
||||
|
|
|
@ -1041,8 +1041,9 @@ void Module::ReloadCameraDevices() {
|
|||
}
|
||||
|
||||
void Module::LoadCameraImplementation(CameraConfig& camera, int camera_id) {
|
||||
camera.impl = Camera::CreateCamera(Settings::values.camera_name[camera_id],
|
||||
Settings::values.camera_config[camera_id]);
|
||||
camera.impl = Camera::CreateCamera(
|
||||
Settings::values.camera_name[camera_id], Settings::values.camera_config[camera_id],
|
||||
static_cast<Service::CAM::Flip>(Settings::values.camera_flip[camera_id]));
|
||||
camera.impl->SetFlip(camera.contexts[0].flip);
|
||||
camera.impl->SetEffect(camera.contexts[0].effect);
|
||||
camera.impl->SetFormat(camera.contexts[0].format);
|
||||
|
|
|
@ -140,6 +140,7 @@ struct Values {
|
|||
// Camera
|
||||
std::array<std::string, Service::CAM::NumCameras> camera_name;
|
||||
std::array<std::string, Service::CAM::NumCameras> camera_config;
|
||||
std::array<int, Service::CAM::NumCameras> camera_flip;
|
||||
|
||||
// Debugging
|
||||
bool use_gdbstub;
|
||||
|
|
Loading…
Reference in a new issue