Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
72f422c7
Commit
72f422c7
authored
Aug 30, 2018
by
berak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
java: fix LIST_GET macro
parent
6477262e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
1 deletion
+120
-1
DnnListRegressionTest.java
modules/dnn/misc/java/test/DnnListRegressionTest.java
+119
-0
opencv_java.hpp
modules/java/generator/src/cpp/opencv_java.hpp
+1
-1
No files found.
modules/dnn/misc/java/test/DnnListRegressionTest.java
0 → 100644
View file @
72f422c7
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
View file @
72f422c7
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#define ARRAYLIST(ENV) static_cast<jclass>(ENV->NewGlobalRef(ENV->FindClass("java/util/ArrayList")))
#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_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_SIZE(ENV, LIST) ENV->GetMethodID(LIST, "size", "()I")
#define LIST_CLEAR(ENV, LIST) ENV->GetMethodID(LIST, "clear", "()V")
#define LIST_CLEAR(ENV, LIST) ENV->GetMethodID(LIST, "clear", "()V")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment