forked from xiaozhi/xiaozhi-esp32
remove preview_thread_, cost more time but less memory usage
This commit is contained in:
@@ -64,9 +64,6 @@ void Esp32Camera::SetExplainUrl(const std::string& url, const std::string& token
|
||||
}
|
||||
|
||||
bool Esp32Camera::Capture() {
|
||||
if (preview_thread_.joinable()) {
|
||||
preview_thread_.join();
|
||||
}
|
||||
if (encoder_thread_.joinable()) {
|
||||
encoder_thread_.join();
|
||||
}
|
||||
@@ -84,7 +81,6 @@ bool Esp32Camera::Capture() {
|
||||
}
|
||||
}
|
||||
|
||||
preview_thread_ = std::thread([this]() {
|
||||
// 显示预览图片
|
||||
auto display = Board::GetInstance().GetDisplay();
|
||||
if (display != nullptr) {
|
||||
@@ -97,7 +93,6 @@ bool Esp32Camera::Capture() {
|
||||
}
|
||||
display->SetPreviewImage(&preview_image_);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -109,7 +104,7 @@ bool Esp32Camera::Capture() {
|
||||
* 问题对图像进行AI分析并返回结果。
|
||||
*
|
||||
* 实现特点:
|
||||
* - 使用多线程异步JPEG编码,避免阻塞主线程
|
||||
* - 使用独立线程编码JPEG,与主线程分离
|
||||
* - 采用分块传输编码(chunked transfer encoding)优化内存使用
|
||||
* - 通过队列机制实现编码线程和发送线程的数据同步
|
||||
* - 支持设备ID、客户端ID和认证令牌的HTTP头部配置
|
||||
|
||||
@@ -22,7 +22,6 @@ private:
|
||||
lv_img_dsc_t preview_image_;
|
||||
std::string explain_url_;
|
||||
std::string explain_token_;
|
||||
std::thread preview_thread_;
|
||||
std::thread encoder_thread_;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user