Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 16a21ba

Browse files
authored
Fix crash on Fedora systems due to provider libusb (#86)
- Add static libusb to Fedora docker images - Add static opencv to Fedora docker images (as libusb is pulled as an opencv indirect dependency) - Add safety mutex to prevent cameras double scan being triggered - Fix docker.py script with relative paths
1 parent 6cae591 commit 16a21ba

12 files changed

Lines changed: 25 additions & 21 deletions

File tree

scripts/travis/package

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
set -e
33
. ${TRAVIS_BUILD_DIR}/git_commit_date.sh
4+
mkdir -p "$TRAVIS_BUILD_DIR/packages"
45

56
if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
67
source ~/virtualenv/python3.6/bin/activate
@@ -11,6 +12,5 @@ fi
1112
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
1213
cd "$TRAVIS_BUILD_DIR/build"
1314
make package -j4
14-
mkdir -p "$TRAVIS_BUILD_DIR/packages"
1515
cp -av *.dmg "$TRAVIS_BUILD_DIR/packages"
1616
fi

src/commons/opencv_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace cv {
4242
// const int COLOR_RGBA2RGB = CV_RGBA2RGB;
4343
// const int COLOR_HSV2BGR = CV_HSV2BGR;
4444
// const int COLOR_BGR2HSV = CV_BGR2HSV;
45+
// const int COLOR_YUV2RGB_YUYV = CV_YUV2RGB_YUYV;
4546
// const int IMWRITE_JPEG_QUALITY = CV_IMWRITE_JPEG_QUALITY;
4647
// const int IMWRITE_PXM_BINARY = CV_IMWRITE_PXM_BINARY;
4748
// const int IMREAD_UNCHANGED = CV_LOAD_IMAGE_UNCHANGED;

src/drivers/supporteddrivers.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <QFileInfo>
2525
#include <QDirIterator>
2626
#include <QJsonDocument>
27+
#include <QMutex>
28+
#include <QMutexLocker>
2729
#include "drivers/imagerexception.h"
2830

2931
using namespace std;
@@ -62,6 +64,7 @@ std::shared_ptr<Driver> SupportedDriver::driver()
6264
DPTR_IMPL(SupportedDrivers) {
6365
SupportedDrivers *q;
6466
QList<SupportedDriver::ptr> supported_drivers;
67+
shared_ptr<QMutex> drivers_scan_mutex;
6568

6669
void find_drivers(const QString &directory);
6770
void load_driver(const QString &filename);
@@ -70,6 +73,7 @@ DPTR_IMPL(SupportedDrivers) {
7073

7174
SupportedDrivers::SupportedDrivers(const QStringList &driversPath) : dptr(this)
7275
{
76+
d->drivers_scan_mutex = make_shared<QMutex>();
7377
for(const QString &path: driversPath)
7478
d->find_drivers(path);
7579
}
@@ -134,6 +138,7 @@ void SupportedDrivers::aboutToQuit()
134138

135139
QList<CameraPtr> SupportedDrivers::cameras() const
136140
{
141+
QMutexLocker lock(d->drivers_scan_mutex.get());
137142
qDebug() << "Detecting active cameras";
138143
QList<CameraPtr> cameras;
139144
for(auto supported_driver: d->supported_drivers) {

src/drivers/v4l2/v4l2imagingworker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ V4L2ImagingWorker::V4L2ImagingWorker(const V4L2DevicePtr& device, const v4l2_for
6666
// Compressed formats
6767
{V4L2_PIX_FMT_MJPEG, bind(&Private::import_frame, d.get(), _1)},
6868
// YUV Colorspace
69-
{V4L2_PIX_FMT_YUYV, bind(&Private::convert_frame, d.get(), _1, CV_8UC2, CV_YUV2RGB_YUYV, Frame::RGB)},
69+
{V4L2_PIX_FMT_YUYV, bind(&Private::convert_frame, d.get(), _1, CV_8UC2, cv::COLOR_YUV2RGB_YUYV, Frame::RGB)},
7070
};
7171
auto pixelformat = format.fmt.pix.pixelformat;
7272
if(!formats.contains(pixelformat))

support/docker/docker.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
docker_path = os.path.abspath(os.path.dirname(__file__))
1313
code_path = os.path.dirname(os.path.dirname(docker_path))
14-
os.chdir(docker_path)
1514

1615
images = [
1716
Ubuntu('19.04', 'x86_64'),
@@ -68,7 +67,6 @@ def list_images():
6867
def package(args):
6968
if args.clean_logs:
7069
cleanup_logs()
71-
7270
destination_path = os.path.abspath(args.dest) if args.dest and args.dest != 'none' else None
7371
filtered_images = filter_images(args.images_filter)
7472
cmake_defines = args.cmake_define

support/docker/dockerfile.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import subprocess
66
from datetime import datetime
77

8-
images_dir = 'images'
9-
logs_dir = os.path.abspath('./logs')
8+
docker_path = os.path.abspath(os.path.dirname(__file__))
9+
10+
images_dir = os.path.join(docker_path, 'images')
11+
logs_dir = os.path.abspath(os.path.join(docker_path, 'logs'))
1012

1113
def cleanup_logs():
1214
shutil.rmtree(logs_dir, ignore_errors=True)
@@ -15,7 +17,7 @@ def cleanup_logs():
1517
class Dockerfile:
1618
def __init__(self, name, snippets, files, substitutions):
1719
self.name = name
18-
self.snippets = [Snippet(os.path.join('snippets', snippet + '.in')) for snippet in snippets]
20+
self.snippets = [Snippet(os.path.join(docker_path, 'snippets', snippet + '.in')) for snippet in snippets]
1921
self.substitutions = substitutions
2022
self.files = files
2123
self.status = None
@@ -33,8 +35,8 @@ def write(self):
3335
snippets = []
3436

3537
snippets.extend(self.snippets)
36-
snippets.append(Snippet('snippets/workdir.in'))
37-
snippets.append(Snippet('snippets/entrypoint.in'))
38+
snippets.append(Snippet(os.path.join(docker_path, 'snippets/workdir.in')))
39+
snippets.append(Snippet(os.path.join(docker_path, 'snippets/entrypoint.in')))
3840

3941
for snippet in snippets:
4042
with open(dockerfile, 'a') as f:
@@ -62,7 +64,7 @@ def package(self, code_path, destination_path, make_jobs, cmake_defines, stderr=
6264
'-e',
6365
'MAKE_OPTS=-j{}'.format(make_jobs),
6466
]
65-
if destination_path and destination_path != 'none':
67+
if destination_path:
6668
cmdline.extend([
6769
'-v',
6870
'{}:/dest'.format(os.path.abspath(destination_path)),

support/docker/fedora.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
class Fedora(LinuxBase):
55
def __init__(self, version, arch):
6-
super().__init__('fedora', 'fedora', version, arch)
6+
super().__init__('fedora', 'fedora', version, arch, ['libusb', 'opencv'])
77

88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include(${CMAKE_CURRENT_LIST_DIR}/configuration-fedora-base.cmake)
2-
set(CPACK_RPM_PACKAGE_REQUIRES "libusb, qt5-qtbase >= 5.5.0, opencv >= 2.4.0 , fxload, CCfits" CACHE STRING "")
2+
set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.5.0, fxload, CCfits, libdc1394" CACHE STRING "")
33

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include(${CMAKE_CURRENT_LIST_DIR}/configuration-fedora-base.cmake)
2-
set(CPACK_RPM_PACKAGE_REQUIRES "libusb, qt5-qtbase >= 5.5.0, opencv >= 2.4.0 , fxload, CCfits" CACHE STRING "")
2+
set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.5.0, fxload, CCfits, libdc1394" CACHE STRING "")
33

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include(${CMAKE_CURRENT_LIST_DIR}/configuration-fedora-base.cmake)
2-
set(CPACK_RPM_PACKAGE_REQUIRES "libusb, qt5-qtbase >= 5.5.0, opencv >= 2.4.0 , fxload, CCfits" CACHE STRING "")
2+
set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= 5.5.0, fxload, CCfits, libdc1394" CACHE STRING "")
33

0 commit comments

Comments
 (0)