Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
7845f6d9
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7845f6d9
编写于
8月 30, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12345 from berak:fix_java_list_string
上级
be48cdc7
72f422c7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
120 addition
and
1 deletion
+120
-1
modules/dnn/misc/java/test/DnnListRegressionTest.java
modules/dnn/misc/java/test/DnnListRegressionTest.java
+119
-0
modules/java/generator/src/cpp/opencv_java.hpp
modules/java/generator/src/cpp/opencv_java.hpp
+1
-1
未找到文件。
modules/dnn/misc/java/test/DnnListRegressionTest.java
0 → 100644
浏览文件 @
7845f6d9
package
org.opencv.test.dnn
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.opencv.core.Core
;
import
org.opencv.core.Mat
;
import
org.opencv.core.MatOfInt
;
import
org.opencv.core.MatOfFloat
;
import
org.opencv.core.MatOfByte
;
import
org.opencv.core.Scalar
;
import
org.opencv.core.Size
;
import
org.opencv.dnn.DictValue
;
import
org.opencv.dnn.Dnn
;
import
org.opencv.dnn.Layer
;
import
org.opencv.dnn.Net
;
import
org.opencv.imgcodecs.Imgcodecs
;
import
org.opencv.imgproc.Imgproc
;
import
org.opencv.test.OpenCVTestCase
;
/*
* regression test for #12324,
* testing various java.util.List invocations,
* which use the LIST_GET macro
*/
public
class
DnnListRegressionTest
extends
OpenCVTestCase
{
private
final
static
String
ENV_OPENCV_DNN_TEST_DATA_PATH
=
"OPENCV_DNN_TEST_DATA_PATH"
;
private
final
static
String
ENV_OPENCV_TEST_DATA_PATH
=
"OPENCV_TEST_DATA_PATH"
;
String
modelFileName
=
""
;
String
sourceImageFile
=
""
;
Net
net
;
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
String
envDnnTestDataPath
=
System
.
getenv
(
ENV_OPENCV_DNN_TEST_DATA_PATH
);
if
(
envDnnTestDataPath
==
null
){
isTestCaseEnabled
=
false
;
return
;
}
File
dnnTestDataPath
=
new
File
(
envDnnTestDataPath
);
modelFileName
=
new
File
(
dnnTestDataPath
,
"dnn/tensorflow_inception_graph.pb"
).
toString
();
String
envTestDataPath
=
System
.
getenv
(
ENV_OPENCV_TEST_DATA_PATH
);
if
(
envTestDataPath
==
null
)
throw
new
Exception
(
ENV_OPENCV_TEST_DATA_PATH
+
" has to be defined!"
);
File
testDataPath
=
new
File
(
envTestDataPath
);
File
f
=
new
File
(
testDataPath
,
"dnn/grace_hopper_227.png"
);
sourceImageFile
=
f
.
toString
();
if
(!
f
.
exists
())
throw
new
Exception
(
"Test image is missing: "
+
sourceImageFile
);
net
=
Dnn
.
readNetFromTensorflow
(
modelFileName
);
Mat
image
=
Imgcodecs
.
imread
(
sourceImageFile
);
assertNotNull
(
"Loading image from file failed!"
,
image
);
Mat
inputBlob
=
Dnn
.
blobFromImage
(
image
,
1.0
,
new
Size
(
224
,
224
),
new
Scalar
(
0
),
true
,
true
);
assertNotNull
(
"Converting image to blob failed!"
,
inputBlob
);
net
.
setInput
(
inputBlob
,
"input"
);
}
public
void
testSetInputsNames
()
{
List
<
String
>
inputs
=
new
ArrayList
();
inputs
.
add
(
"input"
);
try
{
net
.
setInputsNames
(
inputs
);
}
catch
(
Exception
e
)
{
fail
(
"Net setInputsNames failed: "
+
e
.
getMessage
());
}
}
public
void
testForward
()
{
List
<
Mat
>
outs
=
new
ArrayList
();
List
<
String
>
outNames
=
new
ArrayList
();
outNames
.
add
(
"softmax2"
);
try
{
net
.
forward
(
outs
,
outNames
);
}
catch
(
Exception
e
)
{
fail
(
"Net forward failed: "
+
e
.
getMessage
());
}
}
public
void
testGetMemoryConsumption
()
{
int
layerId
=
1
;
List
<
MatOfInt
>
netInputShapes
=
new
ArrayList
();
netInputShapes
.
add
(
new
MatOfInt
(
1
,
3
,
224
,
224
));
long
[]
weights
=
null
;
long
[]
blobs
=
null
;
try
{
net
.
getMemoryConsumption
(
layerId
,
netInputShapes
,
weights
,
blobs
);
}
catch
(
Exception
e
)
{
fail
(
"Net getMemoryConsumption failed: "
+
e
.
getMessage
());
}
}
public
void
testGetFLOPS
()
{
int
layerId
=
1
;
List
<
MatOfInt
>
netInputShapes
=
new
ArrayList
();
netInputShapes
.
add
(
new
MatOfInt
(
1
,
3
,
224
,
224
));
try
{
net
.
getFLOPS
(
layerId
,
netInputShapes
);
}
catch
(
Exception
e
)
{
fail
(
"Net getFLOPS failed: "
+
e
.
getMessage
());
}
}
}
modules/java/generator/src/cpp/opencv_java.hpp
浏览文件 @
7845f6d9
...
...
@@ -29,7 +29,7 @@
#define ARRAYLIST(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("java/util/ArrayList")))
#define LIST_ADD(ENV, LIST) ENV->GetMethodID(LIST, "add", "(Ljava/lang/Object;)Z")
#define LIST_GET(ENV, LIST) ENV->GetMethodID(LIST, "get", "(
(
I)Ljava/lang/Object;")
#define LIST_GET(ENV, LIST) ENV->GetMethodID(LIST, "get", "(I)Ljava/lang/Object;")
#define LIST_SIZE(ENV, LIST) ENV->GetMethodID(LIST, "size", "()I")
#define LIST_CLEAR(ENV, LIST) ENV->GetMethodID(LIST, "clear", "()V")
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录