|
@@ -21,19 +21,6 @@ using boost::asio::ip::tcp;
|
|
|
#include "../tool/CAppEnv.h"
|
|
#include "../tool/CAppEnv.h"
|
|
|
#include "../tool/CVideoCapture.h"
|
|
#include "../tool/CVideoCapture.h"
|
|
|
|
|
|
|
|
-namespace
|
|
|
|
|
-{
|
|
|
|
|
- //摄像头拍摄的图片的原始尺寸,本系统里面默认为800*600
|
|
|
|
|
- const int kVideoWidth = 800;
|
|
|
|
|
- const int kVideoHeight = 600;
|
|
|
|
|
-
|
|
|
|
|
- //红色边框的最小尺寸
|
|
|
|
|
- const int kVideoBorderMinWidth = 400;
|
|
|
|
|
- const int kVideoBorderMinHeight = 300;
|
|
|
|
|
-
|
|
|
|
|
- const int kVideoGripSize = 8;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
CSettingPageUI::CSettingPageUI()
|
|
CSettingPageUI::CSettingPageUI()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -3626,42 +3613,7 @@ void CSettingPageUI::StopVideoThread()
|
|
|
|
|
|
|
|
void CSettingPageUI::LoadVideoBorderRect()
|
|
void CSettingPageUI::LoadVideoBorderRect()
|
|
|
{
|
|
{
|
|
|
- if (m_videoBorderLoaded)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- auto readInt = [](const std::string& value, int defaultValue) -> int
|
|
|
|
|
- {
|
|
|
|
|
- if (value.empty())
|
|
|
|
|
- {
|
|
|
|
|
- return defaultValue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return atoi(value.c_str());
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- int x = readInt(CSetting::GetInstance()->GetParam("setting_ai_video_rect_x"), 0);
|
|
|
|
|
- int y = readInt(CSetting::GetInstance()->GetParam("setting_ai_video_rect_y"), 0);
|
|
|
|
|
- int w = readInt(CSetting::GetInstance()->GetParam("setting_ai_video_rect_w"), kVideoWidth);
|
|
|
|
|
- int h = readInt(CSetting::GetInstance()->GetParam("setting_ai_video_rect_h"), kVideoHeight);
|
|
|
|
|
-
|
|
|
|
|
- if (w < kVideoBorderMinWidth) w = kVideoBorderMinWidth;
|
|
|
|
|
- if (h < kVideoBorderMinHeight) h = kVideoBorderMinHeight;
|
|
|
|
|
- if (w > kVideoWidth) w = kVideoWidth;
|
|
|
|
|
- if (h > kVideoHeight) h = kVideoHeight;
|
|
|
|
|
-
|
|
|
|
|
- if (x < 0) x = 0;
|
|
|
|
|
- if (y < 0) y = 0;
|
|
|
|
|
- if (x + w > kVideoWidth) x = kVideoWidth - w;
|
|
|
|
|
- if (y + h > kVideoHeight) y = kVideoHeight - h;
|
|
|
|
|
-
|
|
|
|
|
- m_videoBorderRect.left = x;
|
|
|
|
|
- m_videoBorderRect.top = y;
|
|
|
|
|
- m_videoBorderRect.right = x + w;
|
|
|
|
|
- m_videoBorderRect.bottom = y + h;
|
|
|
|
|
-
|
|
|
|
|
- m_videoBorderLoaded = true;
|
|
|
|
|
|
|
+ m_videoBorderRect = CVideoCapture::GetInstance()->GetVideoBorderRect();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CSettingPageUI::SaveVideoBorderRect()
|
|
void CSettingPageUI::SaveVideoBorderRect()
|
|
@@ -3675,6 +3627,9 @@ void CSettingPageUI::SaveVideoBorderRect()
|
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_y", std::to_string(y));
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_y", std::to_string(y));
|
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_w", std::to_string(w));
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_w", std::to_string(w));
|
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_h", std::to_string(h));
|
|
CSetting::GetInstance()->SetParam("setting_ai_video_rect_h", std::to_string(h));
|
|
|
|
|
+
|
|
|
|
|
+ //把这个保存到AI识别的worker里面
|
|
|
|
|
+ CVideoCapture::GetInstance()->SetVideoBorderRect(m_videoBorderRect);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
RECT CSettingPageUI::GetVideoImageRect()
|
|
RECT CSettingPageUI::GetVideoImageRect()
|
|
@@ -3701,31 +3656,31 @@ RECT CSettingPageUI::GetVideoBorderDisplayRect(const RECT& imageRect)
|
|
|
return rc;
|
|
return rc;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- rc.left = imageRect.left + MulDiv(m_videoBorderRect.left, imageWidth, kVideoWidth);
|
|
|
|
|
- rc.top = imageRect.top + MulDiv(m_videoBorderRect.top, imageHeight, kVideoHeight);
|
|
|
|
|
- rc.right = imageRect.left + MulDiv(m_videoBorderRect.right, imageWidth, kVideoWidth);
|
|
|
|
|
- rc.bottom = imageRect.top + MulDiv(m_videoBorderRect.bottom, imageHeight, kVideoHeight);
|
|
|
|
|
|
|
+ rc.left = imageRect.left + MulDiv(m_videoBorderRect.left, imageWidth, CVideoCapture::GetInstance()->GetVideoWidth());
|
|
|
|
|
+ rc.top = imageRect.top + MulDiv(m_videoBorderRect.top, imageHeight, CVideoCapture::GetInstance()->GetVideoHeight());
|
|
|
|
|
+ rc.right = imageRect.left + MulDiv(m_videoBorderRect.right, imageWidth, CVideoCapture::GetInstance()->GetVideoWidth());
|
|
|
|
|
+ rc.bottom = imageRect.top + MulDiv(m_videoBorderRect.bottom, imageHeight, CVideoCapture::GetInstance()->GetVideoHeight());
|
|
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int CSettingPageUI::HitTestVideoBorder(POINT pt, const RECT& borderRect)
|
|
int CSettingPageUI::HitTestVideoBorder(POINT pt, const RECT& borderRect)
|
|
|
{
|
|
{
|
|
|
- bool nearLeft = (std::abs(pt.x - borderRect.left) <= kVideoGripSize) &&
|
|
|
|
|
- (pt.y >= borderRect.top - kVideoGripSize) &&
|
|
|
|
|
- (pt.y <= borderRect.bottom + kVideoGripSize);
|
|
|
|
|
|
|
+ bool nearLeft = (std::abs(pt.x - borderRect.left) <= m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.y >= borderRect.top - m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.y <= borderRect.bottom + m_kVideoGripSize);
|
|
|
|
|
|
|
|
- bool nearRight = (std::abs(pt.x - borderRect.right) <= kVideoGripSize) &&
|
|
|
|
|
- (pt.y >= borderRect.top - kVideoGripSize) &&
|
|
|
|
|
- (pt.y <= borderRect.bottom + kVideoGripSize);
|
|
|
|
|
|
|
+ bool nearRight = (std::abs(pt.x - borderRect.right) <= m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.y >= borderRect.top - m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.y <= borderRect.bottom + m_kVideoGripSize);
|
|
|
|
|
|
|
|
- bool nearTop = (std::abs(pt.y - borderRect.top) <= kVideoGripSize) &&
|
|
|
|
|
- (pt.x >= borderRect.left - kVideoGripSize) &&
|
|
|
|
|
- (pt.x <= borderRect.right + kVideoGripSize);
|
|
|
|
|
|
|
+ bool nearTop = (std::abs(pt.y - borderRect.top) <= m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.x >= borderRect.left - m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.x <= borderRect.right + m_kVideoGripSize);
|
|
|
|
|
|
|
|
- bool nearBottom = (std::abs(pt.y - borderRect.bottom) <= kVideoGripSize) &&
|
|
|
|
|
- (pt.x >= borderRect.left - kVideoGripSize) &&
|
|
|
|
|
- (pt.x <= borderRect.right + kVideoGripSize);
|
|
|
|
|
|
|
+ bool nearBottom = (std::abs(pt.y - borderRect.bottom) <= m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.x >= borderRect.left - m_kVideoGripSize) &&
|
|
|
|
|
+ (pt.x <= borderRect.right + m_kVideoGripSize);
|
|
|
|
|
|
|
|
if (nearLeft && nearTop) return HTTOPLEFT;
|
|
if (nearLeft && nearTop) return HTTOPLEFT;
|
|
|
if (nearRight && nearTop) return HTTOPRIGHT;
|
|
if (nearRight && nearTop) return HTTOPRIGHT;
|
|
@@ -3837,6 +3792,11 @@ bool CSettingPageUI::HandleVideoBorderMouseMessage(UINT uMsg, WPARAM wParam, LPA
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ int kVideoWidth = CVideoCapture::GetInstance()->GetVideoWidth();
|
|
|
|
|
+ int kVideoHeight = CVideoCapture::GetInstance()->GetVideoHeight();
|
|
|
|
|
+ int kVideoBorderMinWidth = CVideoCapture::GetInstance()->GetVideoBorderMinWidth();
|
|
|
|
|
+ int kVideoBorderMinHeight = CVideoCapture::GetInstance()->GetVideoBorderMinHeight();
|
|
|
|
|
+
|
|
|
int dx = MulDiv(pt.x - m_videoBorderDragStartPt.x, kVideoWidth, imageWidth);
|
|
int dx = MulDiv(pt.x - m_videoBorderDragStartPt.x, kVideoWidth, imageWidth);
|
|
|
int dy = MulDiv(pt.y - m_videoBorderDragStartPt.y, kVideoHeight, imageHeight);
|
|
int dy = MulDiv(pt.y - m_videoBorderDragStartPt.y, kVideoHeight, imageHeight);
|
|
|
|
|
|