Skip to content

Commit

Permalink
fix bugs of autoinit
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulBasic committed Feb 26, 2021
1 parent d78e76e commit 68b95f4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion Detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ Detector::Detector(int threshVal, int minArea) :
_target_ver_offset(0.5f),
_target_hor_offset(0.5f),
_cell_expand_para(0.75f),
_target_offset_angle(0)
_target_offset_angle(0),
_history_read(false)
{
Sleep(15000);
FILE* target = fopen("target_config.ini", "rt");
if (target != nullptr)
{
fscanf(target, "target_ver_offset=%f\ntarget_hor_offset=%f\ntarget_offset_angle=%d\ncell_expand_para=%f", &_target_ver_offset, &_target_hor_offset, &_target_offset_angle, &_cell_expand_para);
fclose(target);
calc_target();
_history_read = true;
}

std::thread tt(std::bind(&Detector::timeThread, this));
Expand Down Expand Up @@ -61,6 +65,17 @@ void Detector::timeThread()
{
if (a != -1 && msg.message == WM_TIMER)
{
if (!_history_read)
{
FILE* target = fopen("target_config.ini", "rt");
if (target != nullptr)
{
fscanf(target, "target_ver_offset=%f\ntarget_hor_offset=%f\ntarget_offset_angle=%d\ncell_expand_para=%f", &_target_ver_offset, &_target_hor_offset, &_target_offset_angle, &_cell_expand_para);
fclose(target);
calc_target();
_history_read = true;
}
}
_fps = _frame_count * 5;
_frame_count = 0;
send_modbus_packet();
Expand Down
1 change: 1 addition & 0 deletions Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Detector
bool _running;
bool _show_ellipse;
bool _show_target;
bool _history_read;
int _ret;
char _recvBuf[256] = {};
};
Expand Down
1 change: 0 additions & 1 deletion detectviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ void DetectViewer::initializeGL()
}

auto adaptor = std::make_shared<AverCaptureAdaptor>();//初始化一个Aver采集卡视频适配器
Sleep(10000);
if (!adaptor->init())//采集卡初始化
{
#ifdef _DEBUG
Expand Down

0 comments on commit 68b95f4

Please sign in to comment.