Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
AccAOI
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit dbc6add8
由
SK
编写于
2019-07-26 16:13:54 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
选择框拖动
1 个父辈
90fb296f
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
53 行增加
和
14 行删除
AOI/AoiMethod.cs
AOI/blob/AoiBlobMethod.cs
AccAOI/FrmAoiSetting.Designer.cs
ImageBox/AccImageBox.cs
ImageBox/ImageBox.cs
AOI/AoiMethod.cs
查看文件 @
dbc6add
...
...
@@ -89,8 +89,10 @@ namespace AOI
var
srcRect
=
new
RectangleF
(
srcLocation
.
X
,
srcLocation
.
Y
,
resultWidth
,
resultHeight
);
using
(
Graphics
g
=
Graphics
.
FromImage
(
result
))
{
//g.Clear(Color.Transparent);
g
.
DrawImage
(
maskImg
,
dstRect
,
srcRect
,
GraphicsUnit
.
Pixel
);
}
result
.
MakeTransparent
(
Color
.
White
);
return
result
;
}
return
null
;
...
...
AOI/blob/AoiBlobMethod.cs
查看文件 @
dbc6add
...
...
@@ -53,13 +53,13 @@ namespace AOI
int
num
=
GetBlobNum
(
imageToCheck
,
out
cutImg
,
out
Image
dstImg
,
out
List
<
CvBlob
>
blobList
);
resultBean
.
currentRoiImage
=
cutImg
;
bool
result
=
false
;
if
(
num
>
minNum
)
if
(
num
>
=
minNum
)
{
if
(
maxNum
<=
0
)
{
result
=
true
;
}
else
if
(
num
<
maxNum
)
else
if
(
num
<
=
maxNum
)
{
result
=
true
;
}
...
...
@@ -107,13 +107,13 @@ namespace AOI
blobList
=
blobs
.
Values
.
ToList
();
dstCutImg
=
ImageUtil
.
ToImage
(
threshMat
);
List
<
CvBlob
>
resultBlobs
=
blobList
.
Where
(
b
=>
{
if
(
b
.
Area
>
minArea
)
if
(
b
.
Area
>
=
minArea
)
{
if
(
maxArea
<=
0
)
{
return
true
;
}
else
if
(
b
.
Area
<
maxArea
)
else
if
(
b
.
Area
<
=
maxArea
)
{
return
true
;
}
...
...
AccAOI/FrmAoiSetting.Designer.cs
查看文件 @
dbc6add
...
...
@@ -167,6 +167,7 @@ namespace AccAOI
this
.
imageBox1
.
DragHandleSize
=
9
;
this
.
imageBox1
.
Location
=
new
System
.
Drawing
.
Point
(
625
,
40
);
this
.
imageBox1
.
Name
=
"imageBox1"
;
this
.
imageBox1
.
SelectionColor
=
System
.
Drawing
.
Color
.
Blue
;
this
.
imageBox1
.
SelectionMode
=
Acc
.
ImageBox
.
ImageBoxSelectionMode
.
Rectangle
;
this
.
imageBox1
.
Size
=
new
System
.
Drawing
.
Size
(
637
,
592
);
this
.
imageBox1
.
TabIndex
=
4
;
...
...
ImageBox/AccImageBox.cs
查看文件 @
dbc6add
...
...
@@ -78,7 +78,9 @@ namespace Acc.ImageBox
PointF
[]
points
=
this
.
SelectionRegion
.
PathPoints
;
foreach
(
PointF
p
in
points
)
{
RectangleF
recf
=
new
RectangleF
(
p
.
X
-
this
.
DragHandleSize
/
2
,
p
.
Y
-
this
.
DragHandleSize
/
2
,
this
.
DragHandleSize
,
this
.
DragHandleSize
);
float
size
=(
float
)
(
this
.
DragHandleSize
/
this
.
ZoomFactor
);
//size = (float)this.DragHandleSize;
RectangleF
recf
=
new
RectangleF
(
p
.
X
-
size
/
2
,
p
.
Y
-
size
/
2
,
size
,
size
);
if
(
recf
.
Contains
(
imagePoint
))
{
pathPoint
=
p
;
...
...
@@ -407,10 +409,11 @@ namespace Acc.ImageBox
/// <param name="pointf"></param>
protected
virtual
void
DrawDragHandle
(
Graphics
graphics
,
PointF
pointf
)
{
float
left
=
pointf
.
X
-
this
.
DragHandleSize
/
2
;
float
top
=
pointf
.
Y
-
this
.
DragHandleSize
/
2
;
float
width
=
this
.
DragHandleSize
;
float
height
=
this
.
DragHandleSize
;
float
size
=
(
float
)(
this
.
DragHandleSize
);
float
left
=
pointf
.
X
-
size
/
2
;
float
top
=
pointf
.
Y
-
size
/
2
;
float
width
=
size
;
float
height
=
size
;
Pen
outerPen
=
SystemPens
.
WindowFrame
;
Brush
innerBrush
=
SystemBrushes
.
Window
;
...
...
@@ -669,10 +672,21 @@ namespace Acc.ImageBox
Point
startPoint
=
this
.
PointToImage
(
this
.
DragOrigin
,
true
);
Point
endPoint
=
this
.
PointToImage
(
cursorPosition
,
true
);
Matrix
matrix
=
new
Matrix
();
float
scaleX
=
endPoint
.
X
*
1.0f
/
startPoint
.
X
;
float
scaleY
=
endPoint
.
Y
*
1.0f
/
startPoint
.
Y
;
//float scaleX = endPoint.X * 1.0f / startPoint.X;
//float scaleY = endPoint.Y * 1.0f / startPoint.Y;
//靠近中心点为缩小
var
selectionBounds
=
this
.
SelectionRegion
.
GetBounds
();
float
centerX
=
selectionBounds
.
X
+
selectionBounds
.
Width
/
2
;
float
centerY
=
selectionBounds
.
Y
+
selectionBounds
.
Height
/
2
;
double
endToCenter
=
Math
.
Sqrt
(
Math
.
Pow
(
endPoint
.
X
-
centerX
,
2
)
+
Math
.
Pow
(
endPoint
.
Y
-
centerY
,
2
));
double
startToCenter
=
Math
.
Sqrt
(
Math
.
Pow
(
startPoint
.
X
-
centerX
,
2
)
+
Math
.
Pow
(
startPoint
.
Y
-
centerY
,
2
));
float
scale
=
scale
=
(
float
)(
endToCenter
/
startToCenter
);
//if (endToCenter > startToCenter)
//{
// scale = (float)(startToCenter/endToCenter);
//}
matrix
.
Scale
(
scale
X
,
scaleY
);
matrix
.
Scale
(
scale
,
scale
);
path
.
Transform
(
matrix
);
var
oldBounds
=
this
.
SelectionRegion
.
GetBounds
();
...
...
ImageBox/ImageBox.cs
查看文件 @
dbc6add
...
...
@@ -82,6 +82,8 @@ namespace Acc.ImageBox
private
Color
_selectionColor
;
private
bool
_selectionFill
;
private
ImageBoxSelectionMode
_selectionMode
;
private
GraphicsPath
_selectionRegion
=
new
GraphicsPath
();
...
...
@@ -1503,6 +1505,26 @@ namespace Acc.ImageBox
}
/// <summary>
/// Gets or sets the color of selection regions.
/// </summary>
/// <value>
/// The color of selection regions.
/// </value>
[
Category
(
"Appearance"
)]
[
DefaultValue
(
false
)]
public
virtual
bool
SelectionFill
{
get
{
return
_selectionFill
;
}
set
{
if
(
this
.
_selectionFill
!=
value
)
{
_selectionFill
=
value
;
}
}
}
/// <summary>
/// Gets or sets the selection mode.
/// </summary>
/// <value>
...
...
@@ -3196,9 +3218,9 @@ namespace Acc.ImageBox
matrix
.
Translate
(
offsetX
,
offsetY
);
newPath
.
Transform
(
matrix
);
if
(
needFill
)
if
(
needFill
&&
this
.
SelectionFill
)
{
using
(
Brush
brush
=
new
SolidBrush
(
Color
.
FromArgb
(
128
,
color
)))
using
(
Brush
brush
=
new
SolidBrush
(
Color
.
FromArgb
(
80
,
color
)))
{
g
.
FillPath
(
brush
,
newPath
);
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论