fix.修复Linux下的编译错误

This commit is contained in:
MistEO
2022-01-03 03:24:13 +08:00
parent f05f28f8f4
commit 277bb958ac
6 changed files with 22 additions and 7 deletions

2
.gitignore vendored
View File

@@ -432,4 +432,4 @@ screen.png
adb_screen.png
tools/*.png
resource/infrast
.vscode/settings.json
.vscode

View File

@@ -27,11 +27,13 @@ find_library(MeoJson_LIB NAMES meojson PATHS 3rdparty/lib)
if (WIN32)
find_library(OpenCV NAMES opencv_world453 PATHS 3rdparty/lib)
find_library(ZLIB NAMES zlibstatic PATHS 3rdparty/lib)
else ()
find_package(OpenCV REQUIRED)
find_package(ZLIB REQUIRED)
endif ()
target_link_libraries(MeoAssistant ${OpenCV} ${PaddleOCR_LIB} ${Penguin_LIB} ${MeoJson_LIB})
target_link_libraries(MeoAssistant ${OpenCV} ${PaddleOCR_LIB} ${Penguin_LIB} ${MeoJson_LIB} ${ZLIB})
if (BUILD_TEST)
add_executable(test tools/TestCaller/main.cpp)

View File

@@ -10,7 +10,7 @@
### Opencv
请自行搜索教程安装,没什么特别的,作者当前成功验证过的版本为`4.5.3`版本其他版本应该也没什么问题。仅`Opencv`本体即可,不需要额外安装`opencv_contrib`
请自行搜索教程安装,没什么特别的,作者当前成功验证过的版本为`4.5.3`版本其他版本应该也可以,但仍然推荐使用`4.5.3`版本,与项目保持一致,避免一些不必要的问题。仅`Opencv`本体即可,不需要额外安装`opencv_contrib`
### PaddleOCR
@@ -39,6 +39,16 @@ make shared
使用我魔改了接口的版本https://github.com/MistEO/penguin-stats-recognize-v3
### zlib
Ubuntu 下:
```bash
sudo apt update && sudo apt install zlib1g-dev
sudo ldconfig
```
其他发行版若源中没有 zlib, 也可尝试通过 [源码](https://github.com/madler/zlib) 编译
## MeoAssistant
1. 直接拷贝上面编译的第三方库到 `3rdparty/lib` 或者 手动修改 `CMakeLists.txt` 指定第三方库路径

View File

@@ -26,7 +26,7 @@ namespace asst
void set_task_chain(std::string name) noexcept { m_task_chain = std::move(name); }
const std::string& get_task_chain() const noexcept { return m_task_chain; }
constexpr static int RetryTimesDefault = 20;
constexpr static int RetryTimesDefault = 50;
protected:
virtual bool _run() = 0;
virtual bool on_run_fails() { return true; }

View File

@@ -76,7 +76,7 @@ namespace asst
[[deprecated]] bool set_param(const std::string& type, const std::string& param, const std::string& value);
static constexpr int ProcessTaskRetryTimesDefault = 50;
static constexpr int ProcessTaskRetryTimesDefault = AbstractTask::RetryTimesDefault;
static constexpr int OpenRecruitTaskRetryTimesDefault = 20;
static constexpr int AutoRecruitTaskRetryTimesDefault = 10;

View File

@@ -61,6 +61,9 @@ asst::Controller::Controller()
#endif
m_pipe_buffer = std::make_unique<uchar[]>(PipeBuffSize);
if (!m_pipe_buffer) {
throw "controller pipe buffer allocated failed";
}
auto bind_pipe_working_proc = std::bind(&Controller::pipe_working_proc, this);
m_cmd_thread = std::thread(bind_pipe_working_proc);
@@ -447,11 +450,11 @@ std::pair<bool, std::vector<unsigned char>> asst::Controller::call_command(const
// parent process
// LogTraceScope("Parent process: " + cmd);
do {
ssize_t read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), BuffSize);
ssize_t read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), PipeBuffSize);
while (read_num > 0) {
pipe_data.insert(pipe_data.end(), m_pipe_buffer.get(), m_pipe_buffer.get() + read_num);
read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), BuffSize);
read_num = read(m_pipe_out[PIPE_READ], m_pipe_buffer.get(), PipeBuffSize);
};
} while (::waitpid(m_child, nullptr, WNOHANG) == 0);
}