Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张士柳
/
eyemLib
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 1d76f9a7
由
张士柳
编写于
2023-04-12 10:16:16 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
无
1 个父辈
6b410e45
全部展开
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
341 行增加
和
57 行删除
eyemLib-Sharp/EyemLib.cs
eyemLib-Sharp/Program.cs
eyemLib-Sharp/eyemLib-Sharp.csproj
eyemLib.Control/eyemLib.Control/eyemLib.Control.csproj
eyemLib.sln
eyemLib/azONNXWrapper.cpp
eyemLib/azONNXWrapper.h
eyemLib/eyemBin.cpp
eyemLib/eyemLib.h
eyemLib/eyemLib.rc
eyemLib/eyemLib.vcxproj
eyemLib/eyemMisc.cpp
eyemLib/eyemMisc.h
eyemLib/eyemNNDetector.cpp
eyemLib/eyemNNDetector.h
eyemLib/eyemSmooth.cpp
eyemLib-Sharp/EyemLib.cs
查看文件 @
1d76f9a
此文件的差异被折叠,
点击展开。
eyemLib-Sharp/Program.cs
查看文件 @
1d76f9a
...
...
@@ -20,8 +20,11 @@ namespace eyemLib_Sharp
string
[]
fileNames
=
Directory
.
GetFiles
(
@"D:\批量测试图像\", "
*.*
", SearchOption.AllDirectories);
foreach
(
var
item
in
fileNames
)
{
if
(
item
.
EndsWith
(
"png"
)
||
item
.
EndsWith
(
"jpg"
)
||
item
.
EndsWith
(
"bmp"
))
{
EyemLib
.
eyemReadImageTool
(
item
);
}
}
EyemLib
.
Free
();
Console
.
Write
(
"请按任意键继续。。。"
);
Console
.
ReadKey
();
...
...
eyemLib-Sharp/eyemLib-Sharp.csproj
查看文件 @
1d76f9a
...
...
@@ -68,6 +68,18 @@
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_V455Qisda|AnyCPU'">
<OutputPath>..\x64\Release_V455Qisda\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
...
...
eyemLib.Control/eyemLib.Control/eyemLib.Control.csproj
查看文件 @
1d76f9a
...
...
@@ -31,6 +31,16 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_V455Qisda|AnyCPU'">
<OutputPath>bin\Release_V455Qisda\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
...
...
eyemLib.sln
查看文件 @
1d76f9a
...
...
@@ -27,6 +27,9 @@ Global
Release_V455|Any CPU = Release_V455|Any CPU
Release_V455|x64 = Release_V455|x64
Release_V455|x86 = Release_V455|x86
Release_V455Qisda|Any CPU = Release_V455Qisda|Any CPU
Release_V455Qisda|x64 = Release_V455Qisda|x64
Release_V455Qisda|x86 = Release_V455Qisda|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
...
...
@@ -52,6 +55,11 @@ Global
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455|x64.Build.0 = ReleaseV455|x64
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455|x86.ActiveCfg = ReleaseV455|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455|x86.Build.0 = ReleaseV455|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455Qisda|Any CPU.ActiveCfg = Release_V455Qisda|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455Qisda|x64.ActiveCfg = Release_V455Qisda|x64
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455Qisda|x64.Build.0 = Release_V455Qisda|x64
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455Qisda|x86.ActiveCfg = Release_V455Qisda|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release_V455Qisda|x86.Build.0 = Release_V455Qisda|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release|Any CPU.ActiveCfg = Release|Win32
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release|x64.ActiveCfg = Release|x64
{33D5F550-C799-4B05-8E14-ACA390DF5442}.Release|x64.Build.0 = Release|x64
...
...
@@ -81,6 +89,12 @@ Global
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455|x64.Build.0 = ReleaseV455|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455|x86.ActiveCfg = ReleaseV455|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455|x86.Build.0 = ReleaseV455|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|Any CPU.ActiveCfg = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|Any CPU.Build.0 = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|x64.ActiveCfg = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|x64.Build.0 = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|x86.ActiveCfg = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release_V455Qisda|x86.Build.0 = Release_V455Qisda|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release|Any CPU.Build.0 = Release|Any CPU
{C5284403-D4FD-4D83-BBAE-7A4020F1C01F}.Release|x64.ActiveCfg = Release|Any CPU
...
...
@@ -111,6 +125,12 @@ Global
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455|x64.Build.0 = Release|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455|x86.ActiveCfg = Release|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455|x86.Build.0 = Release|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|Any CPU.ActiveCfg = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|Any CPU.Build.0 = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|x64.ActiveCfg = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|x64.Build.0 = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|x86.ActiveCfg = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release_V455Qisda|x86.Build.0 = Release_V455Qisda|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release|Any CPU.Build.0 = Release|Any CPU
{E46DBA02-311F-417A-9221-6F4172498595}.Release|x64.ActiveCfg = Release|Any CPU
...
...
eyemLib/azONNXWrapper.cpp
查看文件 @
1d76f9a
...
...
@@ -130,7 +130,7 @@ float* AZONNXWrapper::forward(cv::Mat& img, cv::Scalar& mean, cv::Scalar& std)
return
predictions
;
}
void
AZONNXWrapper
::
forward
(
cv
::
Mat
&
img
,
cv
::
Mat
&
labels
,
cv
::
Mat
&
stats
,
cv
::
Mat
&
drawResult
,
cv
::
Scalar
&
mean
,
cv
::
Scalar
&
std
)
void
AZONNXWrapper
::
forward
(
cv
::
Mat
&
img
,
cv
::
Mat
&
labels
,
cv
::
Scalar
&
mean
,
cv
::
Scalar
&
std
)
{
#pragma warning( disable : 26451 )
CV_Assert
(
!
img
.
empty
());
...
...
@@ -216,7 +216,6 @@ void AZONNXWrapper::forward(cv::Mat& img, cv::Mat& labels, cv::Mat& stats, cv::M
std
::
vector
<
int
>
indices
;
cv
::
dnn
::
NMSBoxes
(
boxes
,
confidences
,
fConfThreshold
,
fNmsThreshold
,
indices
,
1.
f
,
200
);
//输出结果
labels
=
cv
::
Mat
(
Y
,
X
,
CV_32S
,
cv
::
Scalar
(
-
1
)),
stats
=
cv
::
Mat
(
indices
.
size
(),
5
,
CV_32FC1
,
cv
::
Scalar
(
0
));
for
(
int
i
=
0
;
i
<
indices
.
size
();
++
i
)
{
int
idx
=
indices
[
i
];
...
...
@@ -230,55 +229,53 @@ void AZONNXWrapper::forward(cv::Mat& img, cv::Mat& labels, cv::Mat& stats, cv::M
cv
::
Mat
mask
(
this
->
mask_h
,
this
->
mask_w
,
CV_32FC1
,
cv
::
Scalar
(
0.
f
));
create_protomask
(
blobs
,
mask
,
this
->
mask_h
,
this
->
mask_w
,
maskIds
[
idx
]);
//位置信息
stats
.
ptr
<
float_t
>
(
i
)[
0
]
=
box
.
x
;
stats
.
ptr
<
float_t
>
(
i
)[
1
]
=
box
.
y
;
stats
.
ptr
<
float_t
>
(
i
)[
2
]
=
xmax
;
stats
.
ptr
<
float_t
>
(
i
)[
3
]
=
ymax
;
stats
.
ptr
<
float_t
>
(
i
)[
4
]
=
confidences
[
idx
];
//恢复真实尺度
cv
::
resize
(
mask
,
mask
,
cv
::
Size
(
X
,
Y
));
cv
::
Mat
mask0
(
Y
,
X
,
CV_8UC1
,
cv
::
Scalar
(
0
));
cv
::
rectangle
(
mask0
,
cv
::
Point
(
box
.
x
,
box
.
y
),
cv
::
Point
(
xmax
,
ymax
),
cv
::
Scalar
(
255
),
-
1
);
cv
::
parallel_for_
(
cv
::
Range
(
0
,
Y
),
[
&
](
const
cv
::
Range
range
)
->
void
{
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
y
++
)
{
uchar
*
ptrmask
=
mask0
.
ptr
<
uchar
>
(
y
);
for
(
int
x
=
0
;
x
<
X
;
x
++
)
{
if
(
mask
.
ptr
<
float
>
(
y
)[
x
]
>
fConfThreshold
&&
ptrmask
[
x
]
>
0
)
{
labels
.
ptr
<
int32_t
>
(
y
)[
x
]
=
label
;
}
}
}
});
//标签与置信度
char
text
[
256
];
sprintf
(
text
,
"%s: %.2f"
,
class_namesd
[
classIds
[
idx
]
+
1
].
c_str
(),
confidences
[
idx
]);
int
baseLine
;
cv
::
Size
labelSize
=
cv
::
getTextSize
(
text
,
cv
::
FONT_HERSHEY_SIMPLEX
,
0.5
,
1
,
&
baseLine
);
int
ymin
=
MAX
(
box
.
y
,
labelSize
.
height
);
cv
::
rectangle
(
cc
,
cv
::
Point
(
box
.
x
,
box
.
y
-
int
(
1.5
*
labelSize
.
height
)
-
1
),
cv
::
Point
(
box
.
x
+
int
(
1.5
*
labelSize
.
width
),
box
.
y
-
1
),
cv
::
Scalar
(
0
,
255
,
255
),
cv
::
FILLED
);
cv
::
putText
(
cc
,
text
,
cv
::
Point
(
box
.
x
,
ymin
-
2
),
cv
::
FONT_HERSHEY_SIMPLEX
,
0.75
,
cv
::
Scalar
(
0
,
0
,
0
,
255
),
2
);
}
//绘制mask
cv
::
parallel_for_
(
cv
::
Range
(
0
,
Y
),
[
&
](
const
cv
::
Range
range
)
->
void
{
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
y
++
)
{
for
(
int
x
=
0
;
x
<
X
;
x
++
)
{
int
label
=
labels
.
ptr
<
int32_t
>
(
y
)[
x
];
if
(
label
!=
-
1
)
{
transpMask
.
ptr
<
cv
::
Vec3b
>
(
y
)[
x
]
=
cv
::
Vec3b
(
colors
[
label
][
0
],
colors
[
label
][
1
],
colors
[
label
][
2
]);
}
}
}
});
cv
::
addWeighted
(
cc
,
0.7
,
transpMask
,
0.3
,
0
,
cc
);
mask
.
copyTo
(
labels
);
//cv::Mat mask0(Y, X, CV_8UC1, cv::Scalar(0));
//cv::rectangle(mask0, cv::Point(box.x, box.y), cv::Point(xmax, ymax), cv::Scalar(255), -1);
//cv::parallel_for_(cv::Range(0, Y), [&](const cv::Range range)->void {
// for (int y = range.start; y < range.end; y++)
// {
// uchar* ptrmask = mask0.ptr<uchar>(y);
// for (int x = 0; x < X; x++)
// {
// if (mask.ptr<float>(y)[x] > fConfThreshold && ptrmask[x] > 0) {
// labels.ptr<int32_t>(y)[x] = label;
// }
// }
// }
// });
////标签与置信度
//char text[256];
//sprintf(text, "%s: %.2f", class_namesd[classIds[idx] + 1].c_str(), confidences[idx]);
//int baseLine;
//cv::Size labelSize = cv::getTextSize(text, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
//int ymin = MAX(box.y, labelSize.height);
//cv::rectangle(cc, cv::Point(box.x, box.y - int(1.5 * labelSize.height) - 1), cv::Point(box.x + int(1.5 * labelSize.width), box.y - 1), cv::Scalar(0, 255, 255), cv::FILLED);
//cv::putText(cc, text, cv::Point(box.x, ymin - 2), cv::FONT_HERSHEY_SIMPLEX, 0.75, cv::Scalar(0, 0, 0, 255), 2);
break
;
}
labels
.
convertTo
(
labels
,
CV_8UC1
,
255
);
////绘制mask
//cv::parallel_for_(cv::Range(0, Y), [&](const cv::Range range)->void {
// for (int y = range.start; y < range.end; y++)
// {
// for (int x = 0; x < X; x++)
// {
// int label = labels.ptr<int32_t>(y)[x];
// if (label != -1) {
// transpMask.ptr<cv::Vec3b>(y)[x] = cv::Vec3b(colors[label][0], colors[label][1], colors[label][2]);
// }
// }
// }
// });
//cv::addWeighted(cc, 0.7, transpMask, 0.3, 0, cc);
//
cc
.
copyTo
(
drawResult
);
//
cc.copyTo(drawResult);
//释放资源
delete
[]
priorbox
;
priorbox
=
NULL
;
...
...
eyemLib/azONNXWrapper.h
查看文件 @
1d76f9a
...
...
@@ -15,7 +15,7 @@ public:
~
AZONNXWrapper
();
int
init
(
const
std
::
string
&
model_path
);
float
*
forward
(
cv
::
Mat
&
img
,
cv
::
Scalar
&
mean
,
cv
::
Scalar
&
std
);
//ResNet18提取特征[1,512]
void
forward
(
cv
::
Mat
&
img
,
cv
::
Mat
&
labels
,
cv
::
Mat
&
stats
,
cv
::
Mat
&
drawResult
,
cv
::
Scalar
&
mean
,
cv
::
Scalar
&
std
);
//Yolact实例分割
void
forward
(
cv
::
Mat
&
img
,
cv
::
Mat
&
labels
,
cv
::
Scalar
&
mean
,
cv
::
Scalar
&
std
);
//Yolact实例分割
std
::
vector
<
cv
::
Rect
>
forward
(
cv
::
Mat
&
img
);
//YOLOv7
void
setInputParams
(
float
,
float
,
int
);
private
:
...
...
eyemLib/eyemBin.cpp
查看文件 @
1d76f9a
...
...
@@ -1514,6 +1514,7 @@ int eyemBinBlob(EyemImage tpImage, IntPtr* hObject, EyemBlobParams tpParams, Eye
return
FUNC_OK
;
}
bool
eyemBinFree
(
IntPtr
hObject
)
{
std
::
vector
<
EyemBinBlob
>*
tpResult
=
reinterpret_cast
<
std
::
vector
<
EyemBinBlob
>*>
(
hObject
);
...
...
eyemLib/eyemLib.h
查看文件 @
1d76f9a
...
...
@@ -9,14 +9,14 @@
#ifndef FILEVERSION
#ifdef VQISDA
#define FILEVERSION "2.4.9.
8
(Only Qisda)"
#define FILEVERSION "2.4.9.
13
(Only Qisda)"
#else
#define FILEVERSION "2.4.9.1
1
"
#define FILEVERSION "2.4.9.1
3
"
#endif
#endif
#ifndef COPYRIGHT
#define COPYRIGHT "Copyright (C) 2020-2025 Neo
Tel. All Rights Reserved
"
#define COPYRIGHT "Copyright (C) 2020-2025 Neo
tel Technology Co., Ltd. All rights reserved.
"
#endif
#ifndef ORIGINALFILENAME
...
...
@@ -899,6 +899,13 @@ typedef struct {
EyemRect
bboxes
[
100
];
}
BboxContainer
;
typedef
struct
{
EyemOcsIXY
p1
[
25
];
EyemOcsIXY
p2
[
25
];
EyemOcsIXY
p3
[
25
];
EyemOcsIXY
p4
[
25
];
}
RotateBox
;
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -907,8 +914,9 @@ extern "C" {
EXPORTS
int
eyemInitNNDetector
(
const
char
*
detectorConfigPath
,
const
char
*
detectorModelPath
,
int
iNetSizew
,
int
iNetSizeh
);
EXPORTS
int
eyemNNDetectorParams
(
float
fConfidence
,
float
fNMSThreshold
);
EXPORTS
int
eyemNNDetector
(
EyemImage
tpImage
,
int
*
ipNum
,
BboxContainer
&
container
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemInitClassifier
(
const
char
*
classifierConfigPath
,
const
char
*
classifierModelPath
,
int
ntype
);
EXPORTS
int
eyemClassifier
(
EyemImage
tpImage
);
EXPORTS
int
eyemNNInstanceSegment
(
EyemImage
tpImage
,
float
fThreshold
,
RotateBox
&
container
,
EyemImage
*
tpDstImg
);
//EXPORTS int eyemInitClassifier(const char* classifierConfigPath, const char* classifierModelPath, int ntype);
//EXPORTS int eyemClassifier(EyemImage tpImage);
EXPORTS
int
eyemInitONNXModel
(
const
char
*
extractorModelPath
);
EXPORTS
int
eyemExtractWithONNX
(
EyemImage
tpImage
,
float
*
fFeatures
);
...
...
@@ -970,7 +978,7 @@ extern "C" {
EXPORTS
int
eyemMarkerTracing
(
EyemImage
tpImage
,
EyemHSVModel
tpHSVModel
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
,
bool
bHighAccuracy
=
false
);
EXPORTS
int
eyemDetectCircleUseHough
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
EyemRect
limRoi
,
EyemOcsDXYR
*
tpCircle
,
EyemImage
*
tpDstImg
,
double
dp
,
double
dMinDist
,
double
dParam1
,
double
dParam2
,
double
dMinRadius
,
double
dMaxRadius
,
int
iMethod
=
3
,
bool
useValLimit
=
false
);
EXPORTS
int
eyemMulFuncTool
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
const
char
*
funcName
,
double
dThreshold
,
int
iNumToIgnore
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemLibImpl
(
EyemImage
tpImage
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemLibImpl
(
EyemImage
tpImage
,
const
char
*
fileName
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemDrawLine
(
EyemImage
tpImage
,
EyemOcsDABC
tpLine
);
EXPORTS
int
eyemDrawCircle
(
EyemImage
tpImage
,
EyemOcsDXYR
tpCircle
);
EXPORTS
int
eyemDrawRectangle
(
EyemImage
tpImag
,
EyemRect
tpRect
);
...
...
@@ -980,6 +988,8 @@ extern "C" {
EXPORTS
int
eyemAchvMaskImage
(
EyemImage
tpImage
,
EyemImage
*
tpDstImg
,
EyemImage
*
tpPrevImg
);
EXPORTS
int
eyemSplitMask
(
EyemImage
tpImage
,
EyemImage
tpMask
,
const
char
*
ccToPath
,
const
char
*
ccClassName
);
EXPORTS
int
eyemCalcReelTHK
(
EyemImage
tpImage
,
EyemImage
tpMask
,
EyemOcsIXY
*
,
double
&
dThickness
);
EXPORTS
int
eyemCkReelStatus
(
EyemImage
tpImage
,
const
char
*
lpszConfigPath
,
int
&
iStatus
);
EXPORTS
int
eyemAchvRotateImage
(
EyemImage
tpImage
,
EyemOcsIXY
p1
,
EyemOcsIXY
p2
,
EyemOcsIXY
p3
,
EyemOcsIXY
p4
,
EyemImage
*
tpDstImg
);
#ifdef __cplusplus
...
...
eyemLib/eyemLib.rc
查看文件 @
1d76f9a
此文件类型无法预览
eyemLib/eyemLib.vcxproj
查看文件 @
1d76f9a
...
...
@@ -29,6 +29,14 @@
<Configuration>Release_V420Qisda</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release_V455Qisda|Win32">
<Configuration>Release_V455Qisda</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release_V455Qisda|x64">
<Configuration>Release_V455Qisda</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
...
...
@@ -82,6 +90,13 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
...
...
@@ -115,6 +130,13 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
...
...
@@ -135,6 +157,9 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseV455|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
...
...
@@ -150,6 +175,9 @@
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseV455|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
...
...
@@ -178,6 +206,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseV455|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>D:\3rdparty\opencv420\build\include;D:\3rdparty\opencv420\build\include\opencv2;D:\3rdparty\tbb2017_20170604oss\include;D:\3rdparty\zxing-cpp-master\core\src;D:\3rdparty\zxing-cpp-master\opencv\src;$(IncludePath)</IncludePath>
...
...
@@ -196,6 +227,12 @@
<LibraryPath>D:\3rdparty\opencv455\build\x64\vc14\lib;D:\3rdparty\tbb2017_20170604oss\lib\intel64\vc14;D:\3rdparty\zxing-cpp-master\build\Release;$(LibraryPath)</LibraryPath>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>D:\3rdparty\opencv455\build\include;D:\3rdparty\opencv455\build\include\opencv2;D:\3rdparty\tbb2017_20170604oss\include;D:\3rdparty\zxing-cpp-master\core\src;D:\3rdparty\zxing-cpp-master\opencv\src;$(IncludePath)</IncludePath>
<LibraryPath>D:\3rdparty\opencv455\build\x64\vc14\lib;D:\3rdparty\tbb2017_20170604oss\lib\intel64\vc14;D:\3rdparty\zxing-cpp-master\build\Release;$(LibraryPath)</LibraryPath>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
...
...
@@ -327,6 +364,25 @@
<ModuleDefinitionFile>eyemLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>eyemLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
...
...
@@ -402,6 +458,31 @@
<ModuleDefinitionFile>eyemLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_V455Qisda|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_V455;_CONSOLE;_CRT_SECURE_NO_WARNINGS;HAVE_STRUCT_TIMESPEC;VQISDA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<OpenMPSupport>false</OpenMPSupport>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libdmtx.lib;libzxing.lib;libdecode.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>eyemLib.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="azONNXWrapper.h" />
<ClInclude Include="barcodeDetector.h" />
...
...
eyemLib/eyemMisc.cpp
查看文件 @
1d76f9a
此文件的差异被折叠,
点击展开。
eyemLib/eyemMisc.h
查看文件 @
1d76f9a
...
...
@@ -7,6 +7,7 @@
#include <numeric>
#include <tbb\tbb.h>
#include <queue>
#include "eyemLib.h"
#include "azONNXWrapper.h"
...
...
eyemLib/eyemNNDetector.cpp
查看文件 @
1d76f9a
...
...
@@ -6,6 +6,8 @@ public:
~
Impl
()
{}
//目标检测
std
::
vector
<
cv
::
Rect
>
detect
(
const
cv
::
Mat
&
img
);
//实例分割器
void
instance
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
dst
);
//目标检测器
#ifdef _V455
std
::
shared_ptr
<
AZONNXWrapper
>
detector_
;
...
...
@@ -70,6 +72,19 @@ std::vector<cv::Rect> NNDetector::Impl::detect(const cv::Mat& img) {
#endif
}
void
NNDetector
::
instance
(
cv
::
InputArray
img
,
cv
::
Mat
&
dst
)
{
p
->
instance
(
img
.
getMat
(),
dst
);
}
void
NNDetector
::
Impl
::
instance
(
const
cv
::
Mat
&
img
,
cv
::
Mat
&
dst
)
{
#ifdef _V455
detector_
->
setInputParams
(
_fConfidence
,
_fNMSThreshold
,
550
);
cv
::
Mat
input
;
img
.
copyTo
(
input
);
detector_
->
forward
(
input
,
dst
,
cv
::
Scalar
(
123.68
,
116.78
,
103.94
),
cv
::
Scalar
(
58.40
,
57.12
,
57.38
));
#endif
}
int
eyemInitNNDetector
(
const
char
*
detectorConfigPath
,
const
char
*
detectorModelPath
,
int
iNetSizew
,
int
iNetSizeh
)
{
try
{
...
...
@@ -138,6 +153,140 @@ int eyemNNDetector(EyemImage tpImage, int* ipNum, BboxContainer& container, Eyem
return
FUNC_OK
;
}
int
eyemNNInstanceSegment
(
EyemImage
tpImage
,
float
fThreshold
,
RotateBox
&
container
,
EyemImage
*
tpDstImg
)
{
cv
::
Mat
src
=
cv
::
Mat
(
tpImage
.
iHeight
,
tpImage
.
iWidth
,
MAKETYPE
(
tpImage
.
iDepth
,
tpImage
.
iChannels
),
tpImage
.
vpImage
).
clone
();
if
(
src
.
empty
())
{
return
FUNC_IMAGE_NOT_EXIST
;
}
//
if
(
src
.
channels
()
>
3
)
{
cv
::
cvtColor
(
src
,
src
,
cv
::
COLOR_BGRA2BGR
);
}
//如果不满足尺寸给补齐
if
(
src
.
cols
!=
5472
||
src
.
rows
!=
3648
)
{
cv
::
Mat
temp
;
cv
::
copyMakeBorder
(
src
,
temp
,
0
,
5472
-
src
.
cols
,
0
,
5472
-
src
.
rows
,
cv
::
BORDER_REPLICATE
);
src
=
temp
(
cv
::
Rect
(
0
,
0
,
5472
,
3648
)).
clone
();
}
//画图
cv
::
Mat
showResult
;
if
(
src
.
channels
()
<=
1
)
{
cv
::
cvtColor
(
src
,
showResult
,
cv
::
COLOR_GRAY2BGR
);
}
else
{
src
.
copyTo
(
showResult
);
}
cv
::
Mat
transpMask
;
showResult
.
copyTo
(
transpMask
);
//
cv
::
Mat
input
;
cv
::
resize
(
src
,
input
,
cv
::
Size
(
1024
,
683
));
try
{
//
float
factorX
=
5472
/
1024
,
factorY
=
3648
/
683
;
cv
::
Mat
dst
;
pNNDetector
->
instance
(
input
,
dst
);
//恢复真实尺度
cv
::
resize
(
dst
,
dst
,
cv
::
Size
(
5472
,
3648
));
//
cv
::
Mat
label
;
cv
::
threshold
(
dst
,
label
,
190
,
255
,
cv
::
THRESH_BINARY
);
//判断矩形
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
;
findContours
(
label
,
contours
,
cv
::
RETR_EXTERNAL
,
cv
::
CHAIN_APPROX_SIMPLE
);
//多边形拟合
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
poly
(
contours
.
size
());
std
::
vector
<
std
::
vector
<
cv
::
Point2f
>>
rotateBoxes
;
for
(
int
i
=
0
;
i
<
contours
.
size
();
i
++
)
{
if
(
cv
::
contourArea
(
contours
[
i
])
>
cvRound
(
180000
*
fThreshold
))
{
cv
::
approxPolyDP
(
cv
::
Mat
(
contours
[
i
]),
poly
[
i
],
cv
::
arcLength
(
contours
[
i
],
true
)
*
0.03
,
true
);
//最小外包矩形
cv
::
RotatedRect
rRect
;
cv
::
Point2f
pts
[
4
];
rRect
=
cv
::
minAreaRect
(
poly
[
i
]);
rRect
.
points
(
pts
);
//
cv
::
Rect
bbox
=
cv
::
boundingRect
(
contours
[
i
]);
//计算矩形度
cv
::
Mat
mask
(
cv
::
Size
(
bbox
.
width
,
bbox
.
height
),
CV_8UC1
,
cv
::
Scalar
(
0
));
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
tmpContours
;
std
::
vector
<
cv
::
Point
>
border
;
for
(
int
n
=
0
;
n
<
4
;
n
++
)
{
border
.
push_back
(
pts
[
n
]);
}
tmpContours
.
push_back
(
border
);
//
cv
::
drawContours
(
mask
,
tmpContours
,
0
,
cv
::
Scalar
(
255
),
-
1
,
8
,
cv
::
noArray
(),
2147483647
,
cv
::
Point
(
-
bbox
.
tl
()));
cv
::
Mat
mask0
;
label
(
bbox
).
copyTo
(
mask0
);
//计算有效区域
cv
::
bitwise_and
(
mask0
,
mask
,
mask
);
if
((
float
)
cv
::
countNonZero
(
mask
)
/
rRect
.
size
.
area
()
>
fThreshold
)
{
//绘制
std
::
vector
<
cv
::
Point2f
>
rotateBox
;
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
rotateBox
.
push_back
(
pts
[
j
]);
cv
::
line
(
showResult
,
pts
[
j
],
pts
[(
j
+
1
)
%
4
],
cv
::
Scalar
(
0
,
255
,
255
),
3
);
}
rotateBoxes
.
push_back
(
rotateBox
);
std
::
cout
<<
(
float
)
cv
::
countNonZero
(
mask
)
/
rRect
.
size
.
area
()
<<
std
::
endl
;
cv
::
drawContours
(
showResult
,
poly
,
i
,
cv
::
Scalar
(
0
,
0
,
255
),
3
);
}
else
{
cv
::
drawContours
(
label
,
contours
,
i
,
cv
::
Scalar
(
0
,
0
,
0
),
-
1
);
}
}
else
{
cv
::
drawContours
(
label
,
contours
,
i
,
cv
::
Scalar
(
0
,
0
,
0
),
-
1
);
}
}
memset
(
&
container
,
0
,
sizeof
(
RotateBox
));
//结果
for
(
int
i
=
0
;
i
<
rotateBoxes
.
size
()
&&
i
<
100
;
++
i
)
{
container
.
p1
[
i
].
iX
=
cvRound
(
rotateBoxes
[
i
][
0
].
x
),
container
.
p1
[
i
].
iY
=
cvRound
(
rotateBoxes
[
i
][
0
].
y
);
container
.
p2
[
i
].
iX
=
cvRound
(
rotateBoxes
[
i
][
1
].
x
),
container
.
p2
[
i
].
iY
=
cvRound
(
rotateBoxes
[
i
][
1
].
y
);
container
.
p3
[
i
].
iX
=
cvRound
(
rotateBoxes
[
i
][
2
].
x
),
container
.
p3
[
i
].
iY
=
cvRound
(
rotateBoxes
[
i
][
2
].
y
);
container
.
p4
[
i
].
iX
=
cvRound
(
rotateBoxes
[
i
][
3
].
x
),
container
.
p4
[
i
].
iY
=
cvRound
(
rotateBoxes
[
i
][
3
].
y
);
}
//绘制mask
cv
::
parallel_for_
(
cv
::
Range
(
0
,
label
.
rows
),
[
&
](
const
cv
::
Range
range
)
->
void
{
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
y
++
)
{
for
(
int
x
=
0
;
x
<
label
.
cols
;
x
++
)
{
if
(
label
.
ptr
<
uint8_t
>
(
y
)[
x
]
==
255
)
{
transpMask
.
ptr
<
cv
::
Vec3b
>
(
y
)[
x
]
=
cv
::
Vec3b
(
255
,
255
,
0
);
}
}
}
});
cv
::
addWeighted
(
showResult
,
0.7
,
transpMask
,
0.3
,
0
,
showResult
);
}
catch
(...)
{
return
FUNC_ILLEGAL_ARGUMENT
;
}
//<输出计数结果标记图像
tpDstImg
->
iWidth
=
showResult
.
cols
;
tpDstImg
->
iHeight
=
showResult
.
rows
;
tpDstImg
->
iDepth
=
showResult
.
depth
();
tpDstImg
->
iChannels
=
showResult
.
channels
();
//内存尺寸
int
_Size
=
tpDstImg
->
iWidth
*
tpDstImg
->
iHeight
*
tpDstImg
->
iChannels
*
sizeof
(
uint8_t
);
//分配初始化内存
tpDstImg
->
vpImage
=
(
uint8_t
*
)
malloc
(
_Size
);
if
(
NULL
==
tpDstImg
->
vpImage
)
return
FUNC_NOT_ENOUGH_MEM
;
memset
(
tpDstImg
->
vpImage
,
0
,
_Size
);
//拷贝数据
memcpy
(
tpDstImg
->
vpImage
,
showResult
.
data
,
_Size
);
return
FUNC_OK
;
}
#ifdef _DEBUG
//int eyemInitClassifier(const char *classifierConfigPath, const char *classifierModelPath, int ntype)
//{
...
...
eyemLib/eyemNNDetector.h
查看文件 @
1d76f9a
...
...
@@ -20,7 +20,7 @@ public:
//ü
void
setInputParams
(
float
fConfidence
,
float
fNMSThreshold
);
std
::
vector
<
cv
::
Rect
>
detect
(
cv
::
InputArray
img
);
void
instance
(
cv
::
InputArray
img
,
cv
::
Mat
&
dst
);
protected
:
class
Impl
;
cv
::
Ptr
<
Impl
>
p
;
...
...
eyemLib/eyemSmooth.cpp
查看文件 @
1d76f9a
...
...
@@ -380,7 +380,7 @@ int eyemNonLocalMeansFilter(EyemImage tpImage, int iCMPSize, int iSearchSize, do
return
FUNC_IMAGE_NOT_EXIST
;
}
cv
::
Mat
dest
;
nonLocalMeansFilter_SSE
(
image
,
dest
,
cv
::
Size
(
3
,
3
),
cv
::
Size
(
3
,
3
),
5.0
,
-
1
,
0
);
nonLocalMeansFilter_SSE
(
image
,
dest
,
cv
::
Size
(
5
,
5
),
cv
::
Size
(
5
,
5
),
25.0
,
5
,
0
);
return
FUNC_OK
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论