Skip to content
Open
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
67 changes: 39 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,13 @@ endif()
find_package(OpenCV REQUIRED)

# Find Qt6
find_package(Qt6 REQUIRED COMPONENTS Core Charts Gui Widgets OpenGL)
find_package(Qt6 COMPONENTS Core Charts Gui Widgets OpenGL)
if(Qt6_FOUND)
qt_standard_project_setup()
add_compile_definitions(BUILD_GUI)
else()
message(WARNING "Qt6 not found, disabling the GUI.")
endif()

message(STATUS "Found CMAKE_INSTALL_BINDIR: ${CMAKE_INSTALL_BINDIR}")
message(STATUS "Found CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
Expand All @@ -180,18 +185,22 @@ set(CMAKE_AUTOUIC ON) # Enable automatic UIC

# Add subdirectories for each project
add_subdirectory(cvutil)
add_subdirectory(PluginManager)
add_subdirectory(RoiManager)
if (Qt6_FOUND)
add_subdirectory(PluginManager)
add_subdirectory(RoiManager)
endif()

# Install OpenCV and Qt6 runtime shared libraries
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
foreach(opencv_lib ${OpenCV_LIBS})
install(FILES $<TARGET_FILE:${opencv_lib}> CONFIGURATIONS Debug Release DESTINATION bin)
endforeach()

foreach(qt_lib Qt6::Core Qt6::Widgets Qt6::Gui Qt6::Charts Qt6::OpenGL Qt6::OpenGLWidgets)
install(FILES $<TARGET_FILE:${qt_lib}> CONFIGURATIONS Debug Release DESTINATION bin)
endforeach()
if(Qt6_FOUND)
foreach(qt_lib Qt6::Core Qt6::Widgets Qt6::Gui Qt6::Charts Qt6::OpenGL Qt6::OpenGLWidgets)
install(FILES $<TARGET_FILE:${qt_lib}> CONFIGURATIONS Debug Release DESTINATION bin)
endforeach()
endif()

if(MSVC)
# Configurable path for MSVC LLVM bin directory
Expand Down Expand Up @@ -260,16 +269,16 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

set_target_properties(PluginManager PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

set_target_properties(RoiManager PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
if (Qt6_FOUND)
set_target_properties(PluginManager PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
set_target_properties(RoiManager PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
endif()

# foreach(opencv_lib ${OpenCV_LIBS})
# install(FILES $<TARGET_FILE:${opencv_lib}> CONFIGURATIONS Debug Release DESTINATION lib/cvutil COMPONENT runtime)
Expand All @@ -296,22 +305,24 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
endforeach()

# Install PDB files for Qt6 libraries
foreach(qt_lib Qt6::Core Qt6::Widgets Qt6::Gui Qt6::Charts Qt6::OpenGL Qt6::OpenGLWidgets)
get_target_property(pdb_path ${qt_lib} IMPORTED_PDB_LOCATION_DEBUG)
if (NOT pdb_path)
get_target_property(pdb_path ${qt_lib} IMPORTED_LOCATION_DEBUG)
if(pdb_path)
string(REPLACE ".dll" ".pdb" pdb_path ${pdb_path})
if (Qt6_FOUND)
foreach(qt_lib Qt6::Core Qt6::Widgets Qt6::Gui Qt6::Charts Qt6::OpenGL Qt6::OpenGLWidgets)
get_target_property(pdb_path ${qt_lib} IMPORTED_PDB_LOCATION_DEBUG)
if (NOT pdb_path)
get_target_property(pdb_path ${qt_lib} IMPORTED_LOCATION_DEBUG)
if(pdb_path)
string(REPLACE ".dll" ".pdb" pdb_path ${pdb_path})
endif()
endif()
endif()
if(pdb_path AND EXISTS ${pdb_path})
install(FILES ${pdb_path} CONFIGURATIONS Debug DESTINATION bin)
endif()
endforeach()
if(pdb_path AND EXISTS ${pdb_path})
install(FILES ${pdb_path} CONFIGURATIONS Debug DESTINATION bin)
endif()
endforeach()
endif()
endif()

# Install Qt6 support plugins
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND Qt6_FOUND)
foreach(qt_plugin Qt6::QWindowsIntegrationPlugin)
install(FILES $<TARGET_FILE:${qt_plugin}> CONFIGURATIONS Debug Release DESTINATION bin/platforms)
# Copy pdb files for the plugins
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Information about this fork

Modified source code to remove dependencies on Qt6.

TODO:
- Better replace QString
- Port RoiManager (uses QtGraphicsRectItem for calculations)

# Computer Vision UTILity toolkit (CVUTIL)

cvutil is a C++ computer vision library that extends the functionality of OpenCV. The library contains some functions that are frequently used computer vision developers for convenience. The library uses multi-threading, vectorization routines available in Intel's AVX 2.0 to execute algorithms in the library. The optimizaion can be disabled optionally.
Expand Down
15 changes: 10 additions & 5 deletions RoiManager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ target_link_libraries(RoiManager
PRIVATE
cvutil_compiler_flags
${OpenCV_LIBS}
Qt6::Core
Qt6::Widgets
Qt6::Charts
Qt6::Gui
Qt6::OpenGL
)

if (Qt6_FOUND)
target_link_libraries(RoiManager
PRIVATE
Qt6::Core
Qt6::Widgets
Qt6::Charts
Qt6::Gui
Qt6::OpenGL
)

# Link mimalloc for Release builds only
if(USE_MIMALLOC)
if(TARGET mimalloc)
Expand Down
2 changes: 2 additions & 0 deletions RoiManager/include/RoiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ along with cvutil; see the file COPYING. If not, see

// To disable warnings from external headers.
#pragma warning(push, 0)
#ifdef BUILD_GUI
#include <QtWidgets/QtWidgets>
#endif
#include <opencv2/opencv.hpp>

#include <iostream>
Expand Down
74 changes: 45 additions & 29 deletions cvutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,9 @@ set(SOURCES
cvutil_bwskel.cpp
cvutil_bwthin.cpp
cvutil_core.cpp
cvutil_figure.cpp
cvutil_linesim.cpp
cvutil_videowriter.cpp
main.cpp
cvutil_matlab_interface.cpp
MainWindow/BatchProcessor.cpp
MainWindow/FeatureExtractorThread.cpp
MainWindow/GraphicsScene.cpp
MainWindow/InteractiveExtractorThread.cpp
MainWindow/logger.cpp
MainWindow/MainWindow.cpp
MainWindow/helper_functions.cpp
MainWindow/MaterialStyle.cpp
Profiler.cpp
resources.qrc
)
Expand All @@ -37,29 +27,49 @@ set(HEADERS
cvutil_bwskel.h
cvutil_bwthin.h
cvutil_core.h
cvutil_figure.h
cvutil_linesim.h
cvutil_templates.h
cvutil_matlab_interface.h
cvutil_types.h
cvutil_videowriter.h
demo.h
figure.h
main.h
MainWindow/BatchProcessor.h
MainWindow/FeatureExtractorThread.h
MainWindow/GraphicsScene.h
MainWindow/InteractiveExtractorThread.h
MainWindow/logger.h
MainWindow/MainWindow.h
MainWindow/helper_functions.h
MainWindow/MaterialStyle.h
profiler.h
resource.h
stdproto.h
video.h
)

if(Qt6_FOUND)
list(
APPEND SOURCES
main.cpp
cvutil_figure.cpp
MainWindow/BatchProcessor.cpp
MainWindow/FeatureExtractorThread.cpp
MainWindow/GraphicsScene.cpp
MainWindow/InteractiveExtractorThread.cpp
MainWindow/logger.cpp
MainWindow/MainWindow.cpp
MainWindow/helper_functions.cpp
MainWindow/MaterialStyle.cpp
)

list(
APPEND HEADERS
cvutil_figure.h
demo.h
figure.h
main.h
MainWindow/BatchProcessor.h
MainWindow/FeatureExtractorThread.h
MainWindow/GraphicsScene.h
MainWindow/InteractiveExtractorThread.h
MainWindow/logger.h
MainWindow/MainWindow.h
MainWindow/helper_functions.h
MainWindow/MaterialStyle.h
)
endif()

# Include the resource file only if it's WIN32 and MSVC
if(WIN32)
list(APPEND SOURCES cvutil.rc)
Expand Down Expand Up @@ -111,15 +121,21 @@ target_link_libraries(cvutil
PRIVATE
cvutil_compiler_flags
${OpenCV_LIBS}
Qt6::Core
Qt6::Widgets
Qt6::Charts
Qt6::Gui
Qt6::OpenGL
PluginManager # These are handled at the solution level, no need to add subdirectories here
RoiManager
)

if(Qt6_FOUND)
target_link_libraries(cvutil
PRIVATE
Qt6::Core
Qt6::Widgets
Qt6::Charts
Qt6::Gui
Qt6::OpenGL
PluginManager # These are handled at the solution level, no need to add subdirectories here
RoiManager
)
endif()

# Link mimalloc for Release builds only
if(USE_MIMALLOC)
if(TARGET mimalloc)
Expand Down
2 changes: 2 additions & 0 deletions cvutil/cvutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ along with cvutil; see the file COPYING. If not, see
#include "cvutil_matlab_interface.h"
#include "video.h"
#include "cvutil_templates.h"
#ifdef BUILD_GUI
#include "figure.h"
#endif

#endif
20 changes: 18 additions & 2 deletions cvutil/cvutil_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ along with cvutil; see the file COPYING. If not, see
#include "cvutil_bwskel.h"
#include "cvutil_types.h"

#ifdef BUILD_GUI
#include "MainWindow/MainWindow.h"
#include "MainWindow/MaterialStyle.h"
#endif

using namespace std;
using namespace cv;
Expand Down Expand Up @@ -311,6 +313,7 @@ vector<vector<int>> cvutil::getConnectedComponents(Mat img, Mat& lab, int size,
return result;
}

#ifdef BUILD_GUI
void onMouse(int event, int _x, int _y, int flags, void *data)
{
if (event != EVENT_LBUTTONUP && //event != EVENT_MOUSEMOVE &&
Expand Down Expand Up @@ -441,6 +444,7 @@ void onMouse(int event, int _x, int _y, int flags, void *data)

m.release();
}
#endif

void cvutil::printheader(Mat m)
{
Expand All @@ -454,6 +458,7 @@ void cvutil::printheader(Mat m)
cout << m << endl;
}

#ifdef BUILD_GUI
// Similar to imshow() in opencv, but has
// * An onMouse event Handler.
// * We do not have to call namedWindow() before calling
Expand Down Expand Up @@ -502,6 +507,7 @@ void cvutil::window(cv::String winname, Mat m)
setMouseCallback(winname, onMouse, static_cast<void*>(wd));
waitKey(0);
}
#endif

Mat cvutil::bwthin(Mat input)
{
Expand Down Expand Up @@ -775,7 +781,7 @@ void cvutil::init(int &argc, char *argv[], bool useOpt, bool useGUI)
{
// Enable the OpenCV to use hardware acceleration.
setUseOptimized(useOpt);

#ifdef BUILD_GUI
// Initialize Qt sub-system.
if (useGUI)
{
Expand All @@ -787,6 +793,7 @@ void cvutil::init(int &argc, char *argv[], bool useOpt, bool useGUI)
GlobalValues::app = nullptr;
GlobalValues::coreapp = new QCoreApplication(argc, argv);
}
#endif

//QApplication::setStyle(new MaterialStyle());

Expand Down Expand Up @@ -888,6 +895,7 @@ Mat cvutil::getImageFromComponents(Size sz, vector<vector<int>> components)
return result;
}

#ifdef BUILD_GUI
Ptr<cvutilWindow> cvutil::getImageProcessorWindow(QIcon appico)
{
static MainWindow *result = nullptr;
Expand All @@ -902,20 +910,25 @@ Ptr<cvutilWindow> cvutil::getImageProcessorWindow(QIcon appico)
return result;
}
}
#endif

Mat cvutil::imread(QString& filename, int flags)
{
#ifdef BUILD_GUI
QFile file(filename);
if (!file.open(QFile::ReadOnly))
return Mat();
QByteArray arr = file.readAll();
file.close();

return imdecode(vector<uchar>(arr.begin(), arr.end()), flags);
#else
return imread(filename, flags);
#endif
}

bool cvutil::imwrite(QString filename, Mat img, const std::vector<int> & params)
{
#ifdef BUILD_GUI
if (filename.length() == 0)
{
qCritical() << "Cannot save the image.";
Expand Down Expand Up @@ -959,6 +972,9 @@ bool cvutil::imwrite(QString filename, Mat img, const std::vector<int> & params)
file.write(arr);
file.close();

#else
bool result = imwrite(filename, img, params);
#endif
return result;
}

Expand Down
4 changes: 4 additions & 0 deletions cvutil/cvutil_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ along with cvutil; see the file COPYING. If not, see

#include "cvutil.h"

#ifndef BUILD_GUI
typedef cv::String QString;
#endif

namespace cvutil
{
CVUTILAPI cv::Mat getSingleChannel(cv::Mat m);
Expand Down
2 changes: 2 additions & 0 deletions cvutil/cvutil_matlab_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ along with cvutil; see the file COPYING. If not, see
#define MATLAB_INTERFACE_H

#include "cvutil.h"
#ifdef BUILD_GUI
#include "figure.h"
#endif

#define bwconncomp getConnectedComponents

Expand Down
Loading