Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Common/Cpp/Options/EnumDropdownDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ class EnumDropdownDatabase : public IntegerEnumDropdownDatabase{
public:
EnumDropdownDatabase() : IntegerEnumDropdownDatabase() {}
EnumDropdownDatabase(std::initializer_list<Entry> list){
size_t index = 0;
for (auto iter = list.begin(); iter != list.end(); ++iter, index++){
for (auto iter = list.begin(); iter != list.end(); ++iter){
add(
iter->value,
std::move(iter->slug),
Expand Down
15 changes: 7 additions & 8 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ if(WIN32 AND QT_DEPLOY_FILES)
if(QT_CANDIDATE_DIR AND EXISTS "${QT_CANDIDATE_DIR}")
message(STATUS "Using preferred Qt directory for Qt${QT_MAJOR} ${PREFERRED_QT_VER}: ${QT_CANDIDATE_DIR}")
list(APPEND CMAKE_PREFIX_PATH "${QT_CANDIDATE_DIR}")
find_package(Qt${QT_MAJOR} ${PREFERRED_QT_VER} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
find_package(Qt${QT_MAJOR} ${PREFERRED_QT_VER} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets OpenGLWidgets Qml Quick QuickWidgets REQUIRED)
else()
# Find all subdirectories in the Qt base directory
find_package(Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
find_package(Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets OpenGLWidgets Qml Quick QuickWidgets REQUIRED)
file(GLOB QT_SUBDIRS LIST_DIRECTORIES true "${QT_BASE_DIR}/${QT_MAJOR}*")

# Filter and sort the directories to find the latest version
Expand Down Expand Up @@ -109,7 +109,7 @@ if(WIN32 AND QT_DEPLOY_FILES)
REQUIRED
)
else()
find_package(Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
find_package(Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets OpenGLWidgets Qml Quick QuickWidgets REQUIRED)
endif()

# disable deprecated Qt APIs
Expand Down Expand Up @@ -188,7 +188,7 @@ endif()
# Function to apply common properties to both library and executable targets
function(apply_common_target_properties target_name)
set_target_properties(${target_name} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${target_name} PRIVATE Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::SerialPort Qt${QT_MAJOR}::Multimedia Qt${QT_MAJOR}::MultimediaWidgets)
target_link_libraries(${target_name} PRIVATE Qt${QT_MAJOR}::Widgets Qt${QT_MAJOR}::SerialPort Qt${QT_MAJOR}::Multimedia Qt${QT_MAJOR}::MultimediaWidgets Qt${QT_MAJOR}::OpenGLWidgets Qt${QT_MAJOR}::Qml Qt${QT_MAJOR}::Quick Qt${QT_MAJOR}::QuickWidgets)
target_link_libraries(${target_name} PRIVATE Threads::Threads)

#add defines
Expand Down Expand Up @@ -468,10 +468,9 @@ else() # macOS and Linux
endif() # end Linux

# Find OpenCV
pkg_search_module(OpenCV REQUIRED opencv4 opencv)
target_include_directories(SerialProgramsLib SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS}) # "SYSTEM" to suppress warnings
target_link_directories(SerialProgramsLib PUBLIC ${OpenCV_LIBRARY_DIRS})
target_link_libraries(SerialProgramsLib PUBLIC ${OpenCV_LINK_LIBRARIES})
find_package(OpenCV REQUIRED)
target_include_directories(SerialProgramsLib SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) # "SYSTEM" to suppress warnings
target_link_libraries(SerialProgramsLib PUBLIC ${OpenCV_LIBS})

#we hope to use our own Tesseract build in future so we can rid that dependency
#but right now to run on Linux and Mac we need to use external Tesseract library
Expand Down
13 changes: 10 additions & 3 deletions SerialPrograms/Source/CommonFramework/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,18 @@ int main(int argc, char *argv[]){
#endif

#if defined(__linux__)
// Qt multimedia, default to gstreamer to prevent flickering
// Easier than the alternative which is compiling qt6multimedia with QT_DEFAULT_MEDIA_BACKEND
// Enable libv4l2 for GStreamer by default to fix issues with cheap capture cards
// This helps prevent "Invalid argument (22)" buffer allocation errors on v4l2src.
if (qEnvironmentVariableIsEmpty("GST_V4L2_USE_LIBV4L2")) {
qputenv("GST_V4L2_USE_LIBV4L2", "1");
}

// Qt multimedia, default to ffmpeg to prevent GStreamer capture drops.
// GStreamer used to be preferred to prevent flickering but causes fatal
// crashes (buffer allocation errors) with cheap capture cards on Linux.
// See: https://doc.qt.io/qt-6.5/qtmultimedia-index.html
if (qEnvironmentVariableIsEmpty("QT_MEDIA_BACKEND"))
qputenv("QT_MEDIA_BACKEND", "gstreamer");
qputenv("QT_MEDIA_BACKEND", "ffmpeg");
#endif

// So far, this is only needed on Mac where static initialization is fucked up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
#if 0
#elif QT_VERSION_MAJOR == 6
#include "CameraWidgetQt6.h"
#if QT_VERSION_MINOR >= 5
#include "CameraWidgetQt6.5.h"
#include "CameraWidgetQt6_QVideoWidget.h"
#include "CameraWidgetQt6_QML.h"
#endif

#if defined(__linux__) || defined(__APPLE__)
#include "CameraWidgetOpenCV.h"
#include "CameraWidgetOpenCV_QOpenGLWidget.h"
#endif


Expand Down Expand Up @@ -50,11 +55,29 @@ struct CameraBackends{
}

CameraBackends(){
#if defined(__linux__) || defined(__APPLE__)
m_backends.emplace_back(
"opencv-v4l2", "Linux: OpenCV V4L2",
std::make_unique<CameraOpenCV::CameraBackend>()
);
m_backends.emplace_back(
"opencv-v4l2-gl", "Linux: OpenCV V4L2 (GPU Offloaded)",
std::make_unique<CameraOpenCV_QOpenGLWidget::CameraBackend>()
);
#endif
#if QT_VERSION_MAJOR == 6
m_backends.emplace_back(
"qt6-QVideoSink", "Qt6: QVideoSink",
std::make_unique<CameraQt6QVideoSink::CameraBackend>()
);
m_backends.emplace_back(
"qt6-qvideowidget", "Qt6: GPU Offloaded (QOpenGLWidget)",
std::make_unique<CameraQt6QVideoWidget::CameraBackend>()
);
m_backends.emplace_back(
"qt6-qml", "Qt6: GPU Offloaded (QML QQuickWidget)",
std::make_unique<CameraQt6QML::CameraBackend>()
);
#endif
#if QT_VERSION_MAJOR == 6 && QT_VERSION_MINOR >= 5
m_backends.emplace_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class VideoBackendOption : public IntegerEnumDropdownOption{

// Abstract base class for camera backend implementation.
// Call `get_camera_backend()` to get the camera backend singleton.
// Current camera backend is implemented in CameraWidgetQt6.h/cpp.
// Qt6 camera backends are implemented in CameraWidgetQt6*.h/cpp.
class CameraBackend{
public:
virtual ~CameraBackend() = default;
Expand All @@ -47,7 +47,7 @@ class CameraBackend{


// Get the camera backend singleton.
// Current camera backend is implemented in CameraWidgetQt6.h/cpp.
// Qt6 camera backends are implemented in CameraWidgetQt6*.h/cpp.
const CameraBackend& get_camera_backend();

// Call `get_camera_backend()` to get camera backend reference and get all cameras' info.
Expand Down
Loading