Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
Line-Smart-Workstation
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9c49081f
由
LN
编写于
2024-04-28 09:36:54 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
手势监控增加统计
1 个父辈
2bee034a
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
235 行增加
和
27 行删除
Common/Setting_NInit.cs
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/manager/work/WorkInfo.cs
DeviceLibrary/tool/HVideoManager.cs
DeviceLibrary/tool/HandRecordManager.cs
TSA-V/App.config
TSA-V/Properties/Resource.en-US.resx
TSA-V/Properties/Resource.ru-RU.resx
TSA-V/Properties/Resource.zh-CN.resx
TSA-V/hands/defMTest.py
TSA-V/workForm/FrmTSAV.Designer.cs
TSA-V/workForm/FrmTSAV.cs
Common/Setting_NInit.cs
查看文件 @
9c49081
...
...
@@ -87,7 +87,9 @@ namespace TSA_V.Common
public
static
MyConfig
<
bool
>
Device_HandsVideo
=
false
;
[
MyConfigComment
(
"手势服务器端口"
)]
public
static
MyConfig
<
int
>
Hand_ServerPort
=
8765
;
[
MyConfigComment
(
"手势范围设置:x,y,w,h"
)]
public
static
MyConfig
<
string
[
]>
Hand_RectConfig
=
new
string
[]
{
"0"
,
"0"
,
"1920"
,
"1024"
};
public
static
MyConfig
<
bool
>
Hand_SaveImg
=
true
;
[
MyConfigComment
(
"是否工作区域启动"
)]
...
...
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
9c49081
...
...
@@ -129,6 +129,7 @@
</Compile>
<Compile Include="smf\ServerCommunication.cs" />
<Compile Include="SQLite.cs" />
<Compile Include="tool\HandRecordManager.cs" />
<Compile Include="tool\HVideoManager.cs" />
</ItemGroup>
<ItemGroup>
...
...
DeviceLibrary/manager/work/WorkInfo.cs
查看文件 @
9c49081
...
...
@@ -57,7 +57,8 @@ namespace TSA_V.DeviceLibrary
}
else
{
LogUtil
.
info
(
"开始程序【"
+
boardInfo
.
boardName
+
"】的插件"
);
LogUtil
.
info
(
"开始程序【"
+
boardInfo
.
boardName
+
"】的插件,重置手势统计"
);
HandRecordManager
.
Reset
();
//LedLabelController.CloseAll();
}
IsShowAOI
=
false
;
...
...
DeviceLibrary/tool/HVideoManager.cs
查看文件 @
9c49081
...
...
@@ -17,13 +17,15 @@ namespace TSA_V.DeviceLibrary
{
//private static int ServerPort = 8765;
public
static
string
LastMsg
=
""
;
//public static string LastMsg = "";
public
static
HandInfo
lastInfo
=
new
HandInfo
();
private
static
HttpListener
listener
=
null
;
private
static
bool
mStart
=
false
;
public
static
bool
StartRun
()
{
try
{
{
HandRecordManager
.
Reset
();
if
(
Setting_NInit
.
Hand_ServerPort
>
0
)
{
listener
=
new
HttpListener
();
...
...
@@ -135,14 +137,49 @@ namespace TSA_V.DeviceLibrary
//paramStr = paramStr.Replace("%23", "#");
try
{
Dictionary
<
string
,
string
>
paramMap
=
JsonHelper
.
DeserializeJsonToObject
<
Dictionary
<
string
,
string
>>(
paramStr
);
Dictionary
<
string
,
object
>
paramMap
=
JsonHelper
.
DeserializeJsonToObject
<
Dictionary
<
string
,
object
>>(
paramStr
);
if
(
reqPath
.
Equals
(
ImgUpload
))
{
bool
result
=
paramMap
.
TryGetValue
(
"input"
,
out
string
imgStr
);
HandInfo
obj
=
new
HandInfo
();
bool
result
=
paramMap
.
TryGetValue
(
"input"
,
out
object
imgStr
);
if
(
result
)
{
LastMsg
=
imgStr
;
}
obj
.
ImgStr
=
imgStr
.
ToString
();
}
int
length
=
0
;
result
=
paramMap
.
TryGetValue
(
"pointLen"
,
out
object
lenObj
);
if
(
result
)
{
length
=
Convert
.
ToInt32
(
lenObj
);
obj
.
pointCount
=
length
;
}
result
=
paramMap
.
TryGetValue
(
"points"
,
out
object
pArray
);
if
(
result
&&
length
>
0
)
{
List
<
List
<
int
>>
list
=
JsonHelper
.
DeserializeJsonToList
<
List
<
int
>>(
pArray
.
ToString
());
obj
.
points
=
list
;
//LogUtil.info(pArray.ToString()+"\r\n"+JsonHelper.SerializeObject(pArray));
// foreach (List<int> o in list)
// {
// if (o.Count == 3)
// {
// LogUtil.info($"{o[0]},{o[1]},{o[2]}");
// }
// }
}
lastInfo
=
obj
;
HandRecordManager
.
ProcessPoint
(
lastInfo
.
pointCount
,
lastInfo
.
points
);
//if (Setting_NInit.Hand_SaveImg)
//{
// Bitmap bitmap = Base64StringToImage(obj.ImgStr);
// string fileName = new DateTime().ToString("yyyyMMddHHmmss") + ".jpg";
// bitmap.Save(@"D:\image\" + fileName);
// bitmap.Dispose();
//}
}
else
...
...
@@ -185,8 +222,8 @@ namespace TSA_V.DeviceLibrary
public
static
Bitmap
GetLastImg
(
)
{
string
inputStr
=
LastMsg
;
if
(
LastMsg
!=
""
)
string
inputStr
=
lastInfo
!=
null
?
lastInfo
.
ImgStr
:
""
;
if
(
inputStr
!=
""
)
{
return
Base64StringToImage
(
inputStr
);
}
...
...
@@ -194,4 +231,14 @@ namespace TSA_V.DeviceLibrary
}
}
public
class
HandInfo
{
public
string
ImgStr
{
get
;
set
;
}
public
int
pointCount
{
get
;
set
;
}
public
List
<
List
<
int
>>
points
{
get
;
set
;
}
=
new
List
<
List
<
int
>>();
}
}
DeviceLibrary/tool/HandRecordManager.cs
0 → 100644
查看文件 @
9c49081
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
TSA_V.Common
;
namespace
TSA_V.DeviceLibrary
{
public
class
HandRecordManager
{
/// <summary>
/// 开始统计时间
/// </summary>
private
static
DateTime
startTime
{
get
;
set
;
}
=
DateTime
.
Now
;
/// <summary>
/// 当前状态,0=无手势,>0有手势
/// </summary>
public
static
bool
currHasPoint
=
false
;
private
static
DateTime
currStartTime
=
DateTime
.
Now
;
public
static
int
recordCount
=
0
;
public
static
TimeSpan
recordSpan
=
TimeSpan
.
Zero
;
private
static
Rectangle
currRectangle
=
new
Rectangle
(
0
,
0
,
0
,
0
);
private
static
void
LoadRect
()
{
try
{
string
[]
configs
=
Setting_NInit
.
Hand_RectConfig
;
if
(
configs
.
Length
==
4
)
{
int
x
=
Convert
.
ToInt32
(
configs
[
0
]);
int
y
=
Convert
.
ToInt32
(
configs
[
1
]);
int
w
=
Convert
.
ToInt32
(
configs
[
2
]);
int
h
=
Convert
.
ToInt32
(
configs
[
3
]);
currRectangle
=
new
Rectangle
(
x
,
y
,
w
,
h
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错:"
+
ex
.
ToString
());
}
}
public
static
void
Reset
()
{
LogUtil
.
info
(
$
"重置手势统计,当前已统计:{recordCount}次,共{recordSpan.TotalSeconds}秒,当前状态:{currHasPoint}"
);
//重置
startTime
=
DateTime
.
Now
;
currHasPoint
=
false
;
currStartTime
=
DateTime
.
Now
;
recordCount
=
0
;
recordSpan
=
TimeSpan
.
Zero
;
}
public
static
void
ProcessPoint
(
int
pCount
,
List
<
List
<
int
>>
points
)
{
try
{
if
(
currRectangle
.
Width
<=
0
||
currRectangle
.
Height
<=
0
)
{
LoadRect
();
}
bool
isHas
=
false
;
if
(
pCount
>
0
&&
pCount
==
points
.
Count
)
{
foreach
(
List
<
int
>
point
in
points
)
{
if
(
point
.
Count
==
3
)
{
int
index
=
point
[
0
];
int
x
=
point
[
1
];
int
y
=
point
[
2
];
if
(
x
>
currRectangle
.
X
&&
x
<
currRectangle
.
X
+
currRectangle
.
Width
&&
y
>
currRectangle
.
Y
&&
y
<
currRectangle
.
Y
+
currRectangle
.
Height
)
{
isHas
=
true
;
break
;
}
}
}
}
if
(
isHas
)
{
if
(
currHasPoint
)
{
return
;
}
else
{
currHasPoint
=
true
;
currStartTime
=
DateTime
.
Now
;
}
}
else
{
if
(
currHasPoint
)
{
TimeSpan
span
=
DateTime
.
Now
-
currStartTime
;
recordCount
++;
recordSpan
+=
span
;
currHasPoint
=
false
;
}
else
{
currHasPoint
=
false
;
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错:"
+
ex
.
ToString
());
}
}
}
}
TSA-V/App.config
查看文件 @
9c49081
...
...
@@ -21,7 +21,7 @@
<!--元器件配置路径-->
<
add
key
=
"Component_ConfigPath"
value
=
"\config\componentData.txt"
/>
<!--元器件库模板地址-->
<
add
key
=
"Componet_Template"
value
=
"\config\
元器件信息模板
.csv"
/>
<
add
key
=
"Componet_Template"
value
=
"\config\
BOM-US
.csv"
/>
<
add
key
=
"Componet_Template_zh-CN"
value
=
"\config\元器件信息模板.csv"
/>
<
add
key
=
"Componet_Template_en-US"
value
=
"\config\BOM-US.csv"
/>
<
add
key
=
"ComPath_Config"
value
=
"\config\componet\"
/>
...
...
@@ -158,7 +158,7 @@
</
layout
>
</
appender
>
<
logger
name
=
"defaultAppender"
>
<
level
value
=
"
All
"
/>
<
level
value
=
"
Info
"
/>
<
appender
-
ref
ref
=
"defaultAppender"
/>
</
logger
>
<
logger
name
=
"MetcalLogAppender"
>
...
...
TSA-V/Properties/Resource.en-US.resx
查看文件 @
9c49081
...
...
@@ -2713,5 +2713,8 @@
<data name = "SureDeleteSel" xml:space = "preserve"> <value> OK to delete the selected data? </value> </data>
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> Batch Delete </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> modified </value> </data>
<data name = "FrmWork_groupHand_Text" xml:space = "preserve"> <value> hand gesture monitoring </value> </data>
<data name = "FrmWork_groupHand_Text" xml:space = "preserve"> <value> hand gesture monitoring </value> </data>
<data name = "handWork" xml:space = "preserve"> <value> Assembling </value> </data>
<data name = "handCount" xml:space = "preserve"> <value> Number </value> </data>
<data name = "handTime" xml:space = "preserve"> <value> Total Time </value> </data>
</root>
\ No newline at end of file
TSA-V/Properties/Resource.ru-RU.resx
查看文件 @
9c49081
...
...
@@ -2697,5 +2697,8 @@
<data name = "SureDeleteSel" xml:space = "preserve"> <value> 确定删除选中的数据? </value> </data>
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> 批量删除 </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> 是否修改 </value> </data>
<data name = "FrmWork_groupHand_Text" xml:space = "preserve"> <value> 手势监控 </value> </data>
<data name = "FrmWork_groupHand_Text" xml:space = "preserve"> <value> 手势监控 </value> </data>
<data name = "handWork" xml:space = "preserve"> <value> 组装中 </value> </data>
<data name = "handCount" xml:space = "preserve"> <value> 次数 </value> </data>
<data name = "handTime" xml:space = "preserve"> <value> 总时长 </value> </data>
</root>
\ No newline at end of file
TSA-V/Properties/Resource.zh-CN.resx
查看文件 @
9c49081
...
...
@@ -2713,5 +2713,8 @@
<data name = "FrmBomViewer_linkDelete_Text" xml:space = "preserve"> <value> 批量删除 </value> </data>
<data name = "Column_ISUpdate" xml:space = "preserve"> <value> 是否修改 </value> </data>
<data name = "FrmWork_groupHand_Text" xml:space = "preserve"> <value> 手势监控 </value> </data>
<data name = "handWork" xml:space = "preserve"> <value> 组装中 </value> </data>
<data name = "handCount" xml:space = "preserve"> <value> 次数 </value> </data>
<data name = "handTime" xml:space = "preserve"> <value> 总时长 </value> </data>
</root>
\ No newline at end of file
TSA-V/hands/defMTest.py
查看文件 @
9c49081
...
...
@@ -92,10 +92,13 @@ class handDetector:
print
(
"数据已成功保存到txt文件中。"
)
except
Exception
as
e
:
print
(
f
"保存数据到txt文件时出错:{str(e)}"
)
def
post_string_to_http_api
(
self
,
input_str
,
api_url
):
def
post_string_to_http_api
(
self
,
api_url
,
input_str
,
points
):
try
:
headers
=
{
'Content-Type'
:
'application/json'
}
data
=
{
'input'
:
input_str
}
json_str
=
json
.
dumps
(
points
)
length
=
len
(
points
)
data
=
{
'input'
:
input_str
,
"points"
:
json_str
,
"pointLen"
:
length
}
# print(input_str)
response
=
requests
.
post
(
api_url
,
headers
=
headers
,
data
=
json
.
dumps
(
data
))
...
...
@@ -172,7 +175,7 @@ def main():
input_str
=
detector
.
image_to_base64
(
img
)
# detector.save_input_to_txt(input_str, "input.txt")
# detector.base64_to_image(input_str,"input.jpg")
detector
.
post_string_to_http_api
(
input_str
,
api_url
)
detector
.
post_string_to_http_api
(
api_url
,
input_str
,
lmList
)
# cv2.imshow("Image", img)
# cv2.waitKey(1)
else
:
...
...
@@ -180,6 +183,5 @@ def main():
break
time
.
sleep
(
0.2
)
if
__name__
==
"__main__"
:
main
()
TSA-V/workForm/FrmTSAV.Designer.cs
查看文件 @
9c49081
...
...
@@ -76,6 +76,7 @@
this
.
picBoard
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
groupHand
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
panHand
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
lblHandInfo
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
picHandsVideo
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
lblNotices
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnStartWorking
=
new
System
.
Windows
.
Forms
.
Button
();
...
...
@@ -670,6 +671,7 @@
//
// panHand
//
this
.
panHand
.
Controls
.
Add
(
this
.
lblHandInfo
);
this
.
panHand
.
Controls
.
Add
(
this
.
picHandsVideo
);
this
.
panHand
.
Controls
.
Add
(
this
.
lblNotices
);
this
.
panHand
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
...
...
@@ -678,12 +680,25 @@
this
.
panHand
.
Size
=
new
System
.
Drawing
.
Size
(
636
,
199
);
this
.
panHand
.
TabIndex
=
0
;
//
// lblHandInfo
//
this
.
lblHandInfo
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
lblHandInfo
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblHandInfo
.
ForeColor
=
System
.
Drawing
.
Color
.
Cyan
;
this
.
lblHandInfo
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
3
);
this
.
lblHandInfo
.
Name
=
"lblHandInfo"
;
this
.
lblHandInfo
.
Size
=
new
System
.
Drawing
.
Size
(
630
,
23
);
this
.
lblHandInfo
.
TabIndex
=
278
;
//
// picHandsVideo
//
this
.
picHandsVideo
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
picHandsVideo
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
picHandsVideo
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
picHandsVideo
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
29
);
this
.
picHandsVideo
.
Name
=
"picHandsVideo"
;
this
.
picHandsVideo
.
Size
=
new
System
.
Drawing
.
Size
(
636
,
1
99
);
this
.
picHandsVideo
.
Size
=
new
System
.
Drawing
.
Size
(
636
,
1
67
);
this
.
picHandsVideo
.
SizeMode
=
System
.
Windows
.
Forms
.
PictureBoxSizeMode
.
StretchImage
;
this
.
picHandsVideo
.
TabIndex
=
277
;
this
.
picHandsVideo
.
TabStop
=
false
;
...
...
@@ -693,9 +708,9 @@
this
.
lblNotices
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)));
this
.
lblNotices
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblNotices
.
ForeColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
0
)))),
((
int
)(((
byte
)(
192
)))),
((
int
)(((
byte
)(
192
)))));
this
.
lblNotices
.
Location
=
new
System
.
Drawing
.
Point
(
15
,
1
3
);
this
.
lblNotices
.
Location
=
new
System
.
Drawing
.
Point
(
573
,
3
);
this
.
lblNotices
.
Name
=
"lblNotices"
;
this
.
lblNotices
.
Size
=
new
System
.
Drawing
.
Size
(
568
,
23
);
this
.
lblNotices
.
Size
=
new
System
.
Drawing
.
Size
(
60
,
23
);
this
.
lblNotices
.
TabIndex
=
276
;
this
.
lblNotices
.
Visible
=
false
;
//
...
...
@@ -894,6 +909,7 @@
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1479
,
652
);
this
.
Controls
.
Add
(
this
.
btnStartWorking
);
this
.
Controls
.
Add
(
this
.
groupBoard
);
this
.
Controls
.
Add
(
this
.
groupHand
);
this
.
Controls
.
Add
(
this
.
btnCodeTest
);
...
...
@@ -901,7 +917,6 @@
this
.
Controls
.
Add
(
this
.
groupBox3
);
this
.
Controls
.
Add
(
this
.
btnStart
);
this
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
Controls
.
Add
(
this
.
btnStartWorking
);
this
.
Controls
.
Add
(
this
.
btnGoHome
);
this
.
Controls
.
Add
(
this
.
btnPrePoint
);
this
.
Controls
.
Add
(
this
.
btnNextPoint
);
...
...
@@ -1011,5 +1026,6 @@
private
System
.
Windows
.
Forms
.
GroupBox
groupHand
;
private
System
.
Windows
.
Forms
.
Panel
panHand
;
private
System
.
Windows
.
Forms
.
PictureBox
picHandsVideo
;
private
System
.
Windows
.
Forms
.
Label
lblHandInfo
;
}
}
\ No newline at end of file
TSA-V/workForm/FrmTSAV.cs
查看文件 @
9c49081
...
...
@@ -130,7 +130,7 @@ namespace TSA_V
btnNextPoint
.
Visible
=
Visible
;
btnGoHome
.
Visible
=
Visible
;
}
HandRecordManager
.
Reset
();
isInitOk
=
true
;
// string ip = ConfigAppSettings.GetValue(Setting_Init.StatusServerIp);
// bool result = StatusClient.instance.Connect();
...
...
@@ -1180,7 +1180,7 @@ namespace TSA_V
{
try
{
if
(!
HVideoManager
.
LastMsg
.
Equals
(
lastMsg
))
if
(!
HVideoManager
.
lastInfo
.
ImgStr
.
Equals
(
lastMsg
))
{
Bitmap
bitmap
=
HVideoManager
.
GetLastImg
();
if
(
bitmap
!=
null
)
...
...
@@ -1191,7 +1191,12 @@ namespace TSA_V
picHandsVideo
.
Image
=
null
;
}
picHandsVideo
.
Image
=
bitmap
;
}
}
string
curr
=
(
HandRecordManager
.
currHasPoint
?
ResourceCulture
.
GetString
(
"handWork"
,
"组装中"
):
""
);
lblHandInfo
.
ForeColor
=
Color
.
Cyan
;
lblHandInfo
.
Text
=
$
"{ResourceCulture.GetString("
handCount
","
次数
")}: {HandRecordManager.recordCount},\t"
+
$
" {ResourceCulture.GetString("
handTime
", "
总时长
")}:{FormUtil.GetSpanStr(HandRecordManager.recordSpan)} \t {curr}"
;
}
Thread
.
Sleep
(
200
);
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论