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
b0e1cb47
Commit
b0e1cb47
authored
Jan 11, 2013
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more tests fixes
parent
c49b1bc6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
55 deletions
+57
-55
OpenCVTestCase.java
...java/android_test/src/org/opencv/test/OpenCVTestCase.java
+10
-13
ORBDescriptorExtractorTest.java
...rg/opencv/test/features2d/ORBDescriptorExtractorTest.java
+6
-2
SIFTDescriptorExtractorTest.java
...g/opencv/test/features2d/SIFTDescriptorExtractorTest.java
+6
-2
OpenCVTestCase.java
...es/java/java_test/src/org/opencv/test/OpenCVTestCase.java
+35
-38
No files found.
modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
View file @
b0e1cb47
package
org
.
opencv
.
test
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.FileChannel
;
...
...
@@ -426,24 +428,19 @@ public class OpenCVTestCase extends TestCase {
}
protected
static
String
readFile
(
String
path
)
{
FileInputStream
stream
=
null
;
try
{
stream
=
new
FileInputStream
(
new
File
(
path
));
FileChannel
fc
=
stream
.
getChannel
();
MappedByteBuffer
bb
=
fc
.
map
(
FileChannel
.
MapMode
.
READ_ONLY
,
0
,
fc
.
size
());
return
Charset
.
defaultCharset
().
decode
(
bb
).
toString
();
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
path
));
String
line
;
StringBuffer
result
=
new
StringBuffer
();
while
((
line
=
br
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
result
.
append
(
"\n"
);
}
return
result
.
toString
();
}
catch
(
IOException
e
)
{
OpenCVTestRunner
.
Log
(
"Failed to read file \""
+
path
+
"\". Exception is thrown: "
+
e
);
return
null
;
}
finally
{
if
(
stream
!=
null
)
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
OpenCVTestRunner
.
Log
(
"Exception is thrown: "
+
e
);
}
}
}
...
...
modules/java/android_test/src/org/opencv/test/features2d/ORBDescriptorExtractorTest.java
View file @
b0e1cb47
...
...
@@ -100,7 +100,9 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
extractor
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.ORB</name>\n<WTA_K>2</WTA_K>\n<edgeThreshold>31</edgeThreshold>\n<firstLevel>0</firstLevel>\n<nFeatures>500</nFeatures>\n<nLevels>8</nLevels>\n<patchSize>31</patchSize>\n<scaleFactor>1.2000000476837158e+00</scaleFactor>\n<scoreType>0</scoreType>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
String
actual
=
readFile
(
filename
);
actual
=
actual
.
replaceAll
(
"e\\+000"
,
"e+00"
);
// NOTE: workaround for different platforms double representation
assertEquals
(
truth
,
actual
);
}
public
void
testWriteYml
()
{
...
...
@@ -109,7 +111,9 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
extractor
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nname: \"Feature2D.ORB\"\nWTA_K: 2\nedgeThreshold: 31\nfirstLevel: 0\nnFeatures: 500\nnLevels: 8\npatchSize: 31\nscaleFactor: 1.2000000476837158e+00\nscoreType: 0\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
String
actual
=
readFile
(
filename
);
actual
=
actual
.
replaceAll
(
"e\\+000"
,
"e+00"
);
// NOTE: workaround for different platforms double representation
assertEquals
(
truth
,
actual
);
}
}
modules/java/android_test/src/org/opencv/test/features2d/SIFTDescriptorExtractorTest.java
View file @
b0e1cb47
...
...
@@ -87,7 +87,9 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
extractor
.
write
(
filename
);
String
truth
=
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.SIFT</name>\n<contrastThreshold>4.0000000000000001e-02</contrastThreshold>\n<edgeThreshold>10.</edgeThreshold>\n<nFeatures>0</nFeatures>\n<nOctaveLayers>3</nOctaveLayers>\n<sigma>1.6000000000000001e+00</sigma>\n</opencv_storage>\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
String
actual
=
readFile
(
filename
);
actual
=
actual
.
replaceAll
(
"e([+-])0(\\d\\d)"
,
"e$1$2"
);
// NOTE: workaround for different platforms double representation
assertEquals
(
truth
,
actual
);
}
public
void
testWriteYml
()
{
...
...
@@ -96,7 +98,9 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
extractor
.
write
(
filename
);
String
truth
=
"%YAML:1.0\nname: \"Feature2D.SIFT\"\ncontrastThreshold: 4.0000000000000001e-02\nedgeThreshold: 10.\nnFeatures: 0\nnOctaveLayers: 3\nsigma: 1.6000000000000001e+00\n"
;
assertEquals
(
truth
,
readFile
(
filename
));
String
actual
=
readFile
(
filename
);
actual
=
actual
.
replaceAll
(
"e([+-])0(\\d\\d)"
,
"e$1$2"
);
// NOTE: workaround for different platforms double representation
assertEquals
(
truth
,
actual
);
}
}
modules/java/java_test/src/org/opencv/test/OpenCVTestCase.java
View file @
b0e1cb47
...
...
@@ -2,9 +2,11 @@
package
org
.
opencv
.
test
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.FileChannel
;
...
...
@@ -94,31 +96,31 @@ public class OpenCVTestCase extends TestCase {
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
try
{
System
.
loadLibrary
(
"opencv_java"
);
}
catch
(
SecurityException
e
)
{
System
.
out
.
println
(
e
.
toString
());
System
.
exit
(-
1
);
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
out
.
println
(
e
.
toString
());
System
.
exit
(-
1
);
}
String
pwd
;
try
{
pwd
=
new
File
(
"."
).
getCanonicalPath
()
+
File
.
separator
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
);
return
;
}
OpenCVTestRunner
.
LENA_PATH
=
pwd
+
"res/drawable/lena.jpg"
;
OpenCVTestRunner
.
CHESS_PATH
=
pwd
+
"res/drawable/chessboard.jpg"
;
OpenCVTestRunner
.
LBPCASCADE_FRONTALFACE_PATH
=
pwd
+
"res/raw/lbpcascade_frontalface.xml"
;
assert
(
new
File
(
OpenCVTestRunner
.
LENA_PATH
).
exists
());
assert
(
new
File
(
OpenCVTestRunner
.
CHESS_PATH
).
exists
());
assert
(
new
File
(
OpenCVTestRunner
.
LBPCASCADE_FRONTALFACE_PATH
).
exists
());
try
{
System
.
loadLibrary
(
"opencv_java"
);
}
catch
(
SecurityException
e
)
{
System
.
out
.
println
(
e
.
toString
());
System
.
exit
(-
1
);
}
catch
(
UnsatisfiedLinkError
e
)
{
System
.
out
.
println
(
e
.
toString
());
System
.
exit
(-
1
);
}
String
pwd
;
try
{
pwd
=
new
File
(
"."
).
getCanonicalPath
()
+
File
.
separator
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
);
return
;
}
OpenCVTestRunner
.
LENA_PATH
=
pwd
+
"res/drawable/lena.jpg"
;
OpenCVTestRunner
.
CHESS_PATH
=
pwd
+
"res/drawable/chessboard.jpg"
;
OpenCVTestRunner
.
LBPCASCADE_FRONTALFACE_PATH
=
pwd
+
"res/raw/lbpcascade_frontalface.xml"
;
assert
(
new
File
(
OpenCVTestRunner
.
LENA_PATH
).
exists
());
assert
(
new
File
(
OpenCVTestRunner
.
CHESS_PATH
).
exists
());
assert
(
new
File
(
OpenCVTestRunner
.
LBPCASCADE_FRONTALFACE_PATH
).
exists
());
dst
=
new
Mat
();
assertTrue
(
dst
.
empty
());
...
...
@@ -452,24 +454,19 @@ public class OpenCVTestCase extends TestCase {
}
protected
static
String
readFile
(
String
path
)
{
FileInputStream
stream
=
null
;
try
{
stream
=
new
FileInputStream
(
new
File
(
path
));
FileChannel
fc
=
stream
.
getChannel
();
MappedByteBuffer
bb
=
fc
.
map
(
FileChannel
.
MapMode
.
READ_ONLY
,
0
,
fc
.
size
());
return
Charset
.
defaultCharset
().
decode
(
bb
).
toString
();
BufferedReader
br
=
new
BufferedReader
(
new
FileReader
(
path
));
String
line
;
StringBuffer
result
=
new
StringBuffer
();
while
((
line
=
br
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
result
.
append
(
"\n"
);
}
return
result
.
toString
();
}
catch
(
IOException
e
)
{
OpenCVTestRunner
.
Log
(
"Failed to read file \""
+
path
+
"\". Exception is thrown: "
+
e
);
return
null
;
}
finally
{
if
(
stream
!=
null
)
try
{
stream
.
close
();
}
catch
(
IOException
e
)
{
OpenCVTestRunner
.
Log
(
"Exception is thrown: "
+
e
);
}
}
}
...
...
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