Skip to content

Commit

Permalink
Fix camera initialization issue on TRIK
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov committed Aug 22, 2018
1 parent 945a75a commit 8546f77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions trikControl/src/cameraDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,21 @@ CameraDevice::CameraDevice(const QString & mediaPath, const trikKernel::Configur
QString type = configurer.attributeByDevice("camera", "type");
QString src = configurer.attributeByDevice("camera", "src");

QString osInfo = QSysInfo::productType();
QString currentArch = QSysInfo::currentCpuArchitecture();
QString failMessage;

QLOG_INFO() << "OS name: " << osInfo << " currentArch: " << currentArch;

bool isLinux = osInfo == "ubuntu" || osInfo == "debian"; // can be done with macros Q_OS_LINUX more easily
if (type == "qtmultimedia") {
if (! isLinux || currentArch != "arm") {
decltype(mCameraImpl)(new QtCameraImplementation(src)).swap(mCameraImpl);
} else {
failMessage = "can not use qt camera on TRIK controller";
}
} else if (type == "v4l2") {
if (isLinux) {
decltype(mCameraImpl)(new V4l2CameraImplementation(src, hardwareAbstraction)).swap(mCameraImpl);
} else {
failMessage = "can use v4l2 only on Linux";
}
#ifdef Q_OS_LINUX
decltype(mCameraImpl)(new V4l2CameraImplementation(src, hardwareAbstraction)).swap(mCameraImpl);
#else
failMessage = "can use v4l2 only on Linux";
#endif
} else if (type == "file") {
QStringList filters = configurer.attributeByDevice("camera", "filters").split(',');
decltype(mCameraImpl)(new ImitationCameraImplementation(filters, mediaPath)).swap(mCameraImpl);
} else {
failMessage = "unknown camera device type";
failMessage = "unknown camera device type:" + type;
}

if (mCameraImpl) {
Expand Down
2 changes: 1 addition & 1 deletion trikHal/src/trik/trikHardwareAbstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ OutputDeviceFileInterface *TrikHardwareAbstraction::createOutputDeviceFile(const
QVector<uint8_t> TrikHardwareAbstraction::captureV4l2StillImage(const QString &port, const QString &pathToPic) const
{
Q_UNUSED(pathToPic);
static TrikV4l2VideoDevice device(port); // need only one camera device
TrikV4l2VideoDevice device(port); // need only one camera device

QLOG_INFO() << "Start open v4l2 device" << port;

Expand Down

0 comments on commit 8546f77

Please sign in to comment.