Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
acgist committed Feb 23, 2024
2 parents 9774f37 + 528abcc commit 222d2e2
Show file tree
Hide file tree
Showing 45 changed files with 525 additions and 941 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ jobs:
################ fltk
# sudo apt install libfltk1.3-dev=1.3.8-4
sudo apt install libfltk1.3-dev
################ mlpack
# sudo apt install libmlpack-dev
sudo apt install libstb-dev libcereal-dev libarmadillo-dev libensmallen-dev
git clone https://github.com/mlpack/mlpack.git
cd mlpack
git checkout 4.2.0
mkdir build
cd build
cmake .. -D BUILD_CLI_EXECUTABLES=OFF
sudo make -j 8 install
cd ../../
################ opencv
# sudo apt install libopencv-dev=4.5.4+dfsg-9ubuntu4
sudo apt install libopencv-dev
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ target
deps/fltk
deps/glog
deps/json
deps/mlpack
deps/opencv
deps/libtorch
deps/libtorch-cpu
Expand Down
27 changes: 15 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release/bin)
endif()

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/target/)
set(CMAKE_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/)

set(HEADER_DIR src/header/)
set(SOURCE_DIR src/source/)

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} deps/libtorch)

set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/target/)
set(CMAKE_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/)

include_directories(
deps/libtorch/include
deps/libtorch/include/torch/csrc/api/include
Expand All @@ -69,37 +69,40 @@ if(CMAKE_HOST_WIN32)
CMAKE_PREFIX_PATH
${CMAKE_PREFIX_PATH}
deps/fltk
deps/mlpack
deps/opencv
)

include_directories(
deps/fltk/include
deps/mlpack/include
deps/opencv/include
)

if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(FLTK_FLUID_EXECUTABLE deps/fltk/tools/fltk/debug)

file(GLOB FLTK_DLLS "deps/fltk/debug/bin/*.dll")
file(GLOB MLPACK_DLLS "deps/mlpack/debug/bin/*.dll")
file(GLOB OPENCV_DLLS "deps/opencv/x64/vc16/bin/opencv_videoio_ffmpeg480_64.dll"
"deps/opencv/x64/vc16/bin/opencv_videoio_msmf480_64d.dll"
"deps/opencv/x64/vc16/bin/opencv_world480d.dll"
)
else()
set(FLTK_FLUID_EXECUTABLE deps/fltk/tools/fltk)
file(GLOB FLTK_DLLS "deps/fltk/bin/*.dll")
file(GLOB MLPACK_DLLS "deps/mlpack/bin/*.dll")

file(GLOB FLTK_DLLS "deps/fltk/release/bin/*.dll")
file(GLOB OPENCV_DLLS "deps/opencv/x64/vc16/bin/opencv_videoio_ffmpeg480_64.dll"
"deps/opencv/x64/vc16/bin/opencv_videoio_msmf480_64.dll"
"deps/opencv/x64/vc16/bin/opencv_world480.dll"
)
endif()

file(GLOB TORCH_DLLS "deps/libtorch/lib/*.dll")
file(GLOB OPENCV_DLLS "deps/opencv/x64/vc16/bin/*.dll")
file(GLOB TORCH_DLLS "deps/libtorch/lib/*.dll")

find_package(libpng REQUIRED)
endif()

find_package(FLTK REQUIRED)
find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
find_package(LAPACK REQUIRED)
find_package(Armadillo REQUIRED)

add_subdirectory(deps)
add_subdirectory(core)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
|fltk|界面框架|1.3.8|https://github.com/fltk/fltk|
|glog|日志框架|v0.6.0|https://github.com/google/glog|
|json|JSON框架|v3.11.2|https://github.com/nlohmann/json|
|mlpack|机器学习框架|4.2.0|https://github.com/mlpack/mlpack|
|OpenCV|机器视觉框架|4.8.0|https://github.com/opencv/opencv|
|LibTorch|机器学习框架|v2.0.1|https://github.com/pytorch/pytorch|

Expand Down
7 changes: 3 additions & 4 deletions boot/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ endif()

add_definitions(-DC10_USE_GLOG)

if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:MSVCRT")
endif()

if(CMAKE_HOST_WIN32)
set(CMAKE_EXE_LINKER_FLAGS "/NODEFAULTLIB:MSVCRT")

add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FLTK_DLLS} $<TARGET_FILE_DIR:${PROJECT_NAME}>
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TORCH_DLLS} $<TARGET_FILE_DIR:${PROJECT_NAME}>
)

string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
foreach(image_file ${IMAGES_FILES})
file(COPY ${image_file} DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE_LOWER}/images)
Expand Down
13 changes: 7 additions & 6 deletions boot/main/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
int main(const int argc, const char * const argv[]) {
lifuren::init(argc, argv);
LOG(INFO) << "启动系统";
lifuren::MainWindow* window = new lifuren::MainWindow(512, 256, "李夫人");
window->show();
lifuren::MainWindow* mainPtr = new lifuren::MainWindow(1200, 800, "李夫人");
mainPtr->init();
mainPtr->show();
const int code = Fl::run();
LOG(INFO) << "启动完成";
lifuren::shutdown();
// 释放窗口
if(window != nullptr) {
delete window;
window = nullptr;
if(mainPtr != nullptr) {
delete mainPtr;
mainPtr = nullptr;
}
lifuren::shutdown();
return code;
}
92 changes: 76 additions & 16 deletions boot/main/src/header/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include "GLog.hpp"

#include "FL/Fl.H"
#include "FL/Fl_Input.H"
#include "FL/Fl_Button.H"
#include "FL/Fl_Window.H"
#include "FL/Fl_PNG_Image.H"
#include "FL/Fl_JPEG_Image.H"
#include "FL/Fl_Text_Buffer.H"
#include "FL/Fl_Text_Display.H"

namespace lifuren {

Expand All @@ -21,6 +21,12 @@ namespace lifuren {
*/
class LFRWindow : public Fl_Window {

protected:
/**
* 图标指针
*/
Fl_PNG_Image* iconImagePtr = nullptr;

public:
/**
* @param width 窗口宽度
Expand All @@ -30,11 +36,17 @@ class LFRWindow : public Fl_Window {
LFRWindow(int width, int height, const char* titlePtr);
virtual ~LFRWindow();

protected:
public:
/**
* 加载窗口
*/
virtual void init();

protected:
/**
* 加载组件
*/
virtual void drawElement() = 0;
/**
* 设置图标
*/
Expand All @@ -44,19 +56,45 @@ class LFRWindow : public Fl_Window {
*/
void center();

protected:
/**
* 图标指针
*/
Fl_PNG_Image* iconImagePtr;

};

class AboutWindow;

/**
* 主窗口
*/
class MainWindow : public LFRWindow {

private:
// AudioGC按钮
Fl_Button* audioGcPtr = nullptr;
// AudioTS按钮
Fl_Button* audioTsPtr = nullptr;
// Audio分组
Fl_Group* audioGroupPtr = nullptr;
// ImageGC按钮
Fl_Button* imageGcPtr = nullptr;
// ImageTS按钮
Fl_Button* imageTsPtr = nullptr;
// Image分组
Fl_Group* imageGroupPtr = nullptr;
// VideoGC按钮
Fl_Button* videoGcPtr = nullptr;
// VideoTS按钮
Fl_Button* videoTsPtr = nullptr;
// Video分组
Fl_Group* videoGroupPtr = nullptr;
// PoetryGC按钮
Fl_Button* poetryGcPtr = nullptr;
// PoetryTS按钮
Fl_Button* poetryTsPtr = nullptr;
// Poetry分组
Fl_Group* poetryGroupPtr = nullptr;
// 关于按钮
Fl_Button* aboutButtonPtr = nullptr;
// 关于窗口
AboutWindow* aboutWindowPtr = nullptr;

public:
/**
* @param width 窗口宽度
Expand All @@ -71,20 +109,42 @@ class MainWindow : public LFRWindow {
* 关于
*/
void about();
/**
* 设置
*/
void setting();

protected:
void init() override;
/**
* 加载组件
*/
virtual void drawElement() override;

};

/**
* 设置窗口
* 关于窗口
*/
class SettingWindow : public LFRWindow {
class AboutWindow : public LFRWindow {

private:
// 官网
Fl_Button* homePagePtr = nullptr;
// 关于内容
Fl_Text_Buffer* aboutBufferPtr = nullptr;
// 关于
Fl_Text_Display* aboutDisplayPtr = nullptr;

public:
/**
* @param width 窗口宽度
* @param height 窗口高度
* @param titlePtr 窗口名称
*/
AboutWindow(int width, int height, const char* titlePtr);
virtual ~AboutWindow();

protected:
/**
* 加载组件
*/
virtual void drawElement() override;

};

Expand Down
Binary file modified boot/main/src/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions boot/main/src/source/AboutWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "../header/Window.hpp"

#include "FL/filename.H"

lifuren::AboutWindow::AboutWindow(int width, int height, const char* titlePtr) : LFRWindow(width, height, titlePtr) {
}

lifuren::AboutWindow::~AboutWindow() {
LOG(INFO) << "关闭AboutWindow";
if(this->homePagePtr != nullptr) {
delete this->homePagePtr;
this->homePagePtr = nullptr;
}
if(this->aboutDisplayPtr != nullptr) {
delete this->aboutDisplayPtr;
this->aboutDisplayPtr = nullptr;
}
if(this->aboutBufferPtr != nullptr) {
delete this->aboutBufferPtr;
this->aboutBufferPtr = nullptr;
}
}

void lifuren::AboutWindow::drawElement() {
this->aboutDisplayPtr = new Fl_Text_Display(10, 30, this->w() - 20, this->h() - 90, "关于");
this->aboutDisplayPtr->wrap_mode(this->aboutDisplayPtr->WRAP_AT_COLUMN, this->aboutDisplayPtr->textfont());
this->aboutDisplayPtr->color(FL_BACKGROUND_COLOR);
// 内容
this->aboutBufferPtr = new Fl_Text_Buffer();
this->aboutBufferPtr->text("李夫人,这是一个研究生成网络、机器视觉、自然语言处理的程序。\n");
this->aboutBufferPtr->append("Gitee:https://gitee.com/acgist/lifuren\n");
this->aboutBufferPtr->append("Github:https://github.com/acgist/lifuren\n");
this->aboutBufferPtr->append("作者:acgist");
this->aboutDisplayPtr->buffer(this->aboutBufferPtr);
// 主页
this->homePagePtr = new Fl_Button(this->w() / 2 - 40, this->h() - 40, 80, 30, "主页");
this->homePagePtr->callback([](Fl_Widget* widgetPtr, void* voidPtr) -> void {
const int ret = fl_open_uri("https://gitee.com/acgist/lifuren");
LOG(INFO) << "打开主页:" << ret;
}, this);
}
33 changes: 28 additions & 5 deletions boot/main/src/source/LFRWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include "../header/Window.hpp"

/**
* @param source 原始值
* @param target 比较值
*
* @return 绝对值
*/
int abs(int source, int target);

lifuren::LFRWindow::LFRWindow(int width, int height, const char* titlePtr) : Fl_Window(width, height, titlePtr) {
this->begin();
this->init();
this->end();
}

lifuren::LFRWindow::~LFRWindow() {
Expand All @@ -14,16 +19,34 @@ lifuren::LFRWindow::~LFRWindow() {
}

void lifuren::LFRWindow::init() {
this->begin();
this->icon();
this->center();
this->drawElement();
this->end();
}

void lifuren::LFRWindow::icon() {
Fl_PNG_Image iconImage("../images/logo.png");
const char* iconPath = "../images/logo.png";
LOG(INFO) << "加载图标" << iconPath;
Fl_PNG_Image iconImage(iconPath);
this->iconImagePtr = static_cast<Fl_PNG_Image*>(iconImage.copy(32, 32));
Fl_Window::default_icon(this->iconImagePtr);
}

void lifuren::LFRWindow::center() {
this->position(200, 200);
LOG(INFO) << "窗口居中";
const int fullWidth = Fl::w();
const int fullHeight = Fl::h();
const int width = this->w();
const int height = this->h();
this->position(abs(fullWidth, width) / 2, abs(fullHeight, height) / 2);
}

int abs(int source, int target) {
if(source > target) {
return source - target;
} else {
return target - source;
}
}
Loading

0 comments on commit 222d2e2

Please sign in to comment.