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
79cf292d
Commit
79cf292d
authored
Feb 28, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Feb 28, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #590 from apavlenko:java_fixes
parents
1018d110
d18b2c25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
13 deletions
+38
-13
CMakeLists.txt
modules/java/CMakeLists.txt
+9
-3
gen_java.py
modules/java/generator/gen_java.py
+19
-7
SimpleSample.java
samples/java/ant/src/SimpleSample.java
+3
-1
Main.java
samples/java/eclipse/HelloCV/src/Main.java
+3
-1
Main.scala
samples/java/sbt/src/main/scala/Main.scala
+4
-1
No files found.
modules/java/CMakeLists.txt
View file @
79cf292d
...
...
@@ -217,6 +217,12 @@ endif(ANDROID AND ANDROID_EXECUTABLE)
set
(
step3_depends
${
step2_depends
}
${
step3_input_files
}
${
copied_files
}
)
if
(
ANDROID
)
set
(
LIB_NAME_SUFIX
""
)
else
()
set
(
LIB_NAME_SUFIX
"
${
OPENCV_VERSION_MAJOR
}${
OPENCV_VERSION_MINOR
}${
OPENCV_VERSION_PATCH
}
"
)
endif
()
# step 4: build jar
if
(
ANDROID
)
set
(
JAR_FILE
"
${
OpenCV_BINARY_DIR
}
/bin/classes.jar"
)
...
...
@@ -241,7 +247,7 @@ if(ANDROID)
)
endif
()
else
(
ANDROID
)
set
(
JAR_NAME opencv-
${
OPENCV_VERSION
}
.jar
)
set
(
JAR_NAME opencv-
${
LIB_NAME_SUFIX
}
.jar
)
set
(
JAR_FILE
"
${
OpenCV_BINARY_DIR
}
/bin/
${
JAR_NAME
}
"
)
configure_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/build.xml.in"
"
${
OpenCV_BINARY_DIR
}
/build.xml"
IMMEDIATE @ONLY
)
list
(
APPEND step3_depends
"
${
OpenCV_BINARY_DIR
}
/build.xml"
)
...
...
@@ -294,8 +300,8 @@ endif()
# Additional target properties
set_target_properties
(
${
the_module
}
PROPERTIES
OUTPUT_NAME
"
${
the_module
}${
OPENCV_DLLVERSION
}
"
DEBUG_POSTFIX
"
${
OPENCV_DEBUG_POSTFIX
}
"
OUTPUT_NAME
"
${
the_module
}${
LIB_NAME_SUFIX
}
"
#
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY
${
LIBRARY_OUTPUT_PATH
}
RUNTIME_OUTPUT_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
INSTALL_NAME_DIR
${
OPENCV_LIB_INSTALL_PATH
}
...
...
modules/java/generator/gen_java.py
View file @
79cf292d
...
...
@@ -559,6 +559,15 @@ func_arg_fix = {
},
# '', i.e. no class
}
# func_arg_fix
def
getLibVersion
(
version_hpp_path
):
version_file
=
open
(
version_hpp_path
,
"rt"
)
.
read
()
epoch
=
re
.
search
(
"^W*#
\
W*define
\
W+CV_VERSION_EPOCH
\
W+(
\
d+)
\
W*$"
,
version_file
,
re
.
MULTILINE
)
.
group
(
1
)
major
=
re
.
search
(
"^W*#
\
W*define
\
W+CV_VERSION_MAJOR
\
W+(
\
d+)
\
W*$"
,
version_file
,
re
.
MULTILINE
)
.
group
(
1
)
minor
=
re
.
search
(
"^W*#
\
W*define
\
W+CV_VERSION_MINOR
\
W+(
\
d+)
\
W*$"
,
version_file
,
re
.
MULTILINE
)
.
group
(
1
)
revision
=
re
.
search
(
"^W*#
\
W*define
\
W+CV_VERSION_REVISION
\
W+(
\
d+)
\
W*$"
,
version_file
,
re
.
MULTILINE
)
.
group
(
1
)
return
(
epoch
,
major
,
minor
,
revision
)
class
ConstInfo
(
object
):
def
__init__
(
self
,
cname
,
name
,
val
,
addedManually
=
False
):
self
.
cname
=
cname
...
...
@@ -721,13 +730,16 @@ $imports
public class
%(jc)
s {
"""
%
{
'm'
:
self
.
module
,
'jc'
:
jname
}
)
# self.java_code[class_name]["jn_code"].write("""
# //
# // native stuff
# //
# static { System.loadLibrary("opencv_java"); }
#""" )
if
class_name
==
'Core'
:
(
epoch
,
major
,
minor
,
revision
)
=
getLibVersion
(
(
os
.
path
.
dirname
(
__file__
)
or
'.'
)
+
'/../../core/include/opencv2/core/version.hpp'
)
version_str
=
'.'
.
join
(
(
epoch
,
major
,
minor
,
revision
)
)
version_suffix
=
''
.
join
(
(
epoch
,
major
,
minor
)
)
self
.
classes
[
class_name
]
.
imports
.
add
(
"java.lang.String"
)
self
.
java_code
[
class_name
][
"j_code"
]
.
write
(
"""
public static final String VERSION = "
%(v)
s", NATIVE_LIBRARY_NAME = "opencv_java
%(vs)
s";
public static final int VERSION_EPOCH =
%(ep)
s, VERSION_MAJOR =
%(ma)
s, VERSION_MINOR =
%(mi)
s, VERSION_REVISION =
%(re)
s;
"""
%
{
'v'
:
version_str
,
'vs'
:
version_suffix
,
'ep'
:
epoch
,
'ma'
:
major
,
'mi'
:
minor
,
're'
:
revision
}
)
def
add_class
(
self
,
decl
):
...
...
samples/java/ant/src/SimpleSample.java
View file @
79cf292d
import
org.opencv.core.Core
;
import
org.opencv.core.Mat
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Scalar
;
class
SimpleSample
{
static
{
System
.
loadLibrary
(
"opencv_java244"
);
}
static
{
System
.
loadLibrary
(
Core
.
NATIVE_LIBRARY_NAME
);
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Welcome to OpenCV "
+
Core
.
VERSION
);
Mat
m
=
new
Mat
(
5
,
10
,
CvType
.
CV_8UC1
,
new
Scalar
(
0
));
System
.
out
.
println
(
"OpenCV Mat: "
+
m
);
Mat
mr1
=
m
.
row
(
1
);
...
...
samples/java/eclipse/HelloCV/src/Main.java
View file @
79cf292d
import
org.opencv.core.Core
;
import
org.opencv.core.CvType
;
import
org.opencv.core.Mat
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
System
.
loadLibrary
(
"opencv_java244"
);
System
.
out
.
println
(
"Welcome to OpenCV "
+
Core
.
VERSION
);
System
.
loadLibrary
(
Core
.
NATIVE_LIBRARY_NAME
);
Mat
m
=
Mat
.
eye
(
3
,
3
,
CvType
.
CV_8UC1
);
System
.
out
.
println
(
"m = "
+
m
.
dump
());
}
...
...
samples/java/sbt/src/main/scala/Main.scala
View file @
79cf292d
...
...
@@ -8,11 +8,14 @@
* You're invited to submit your own examples, in any JVM language of
* your choosing so long as you can get them to build.
*/
import
org.opencv.core.Core
object
Main
extends
App
{
// We must load the native library before using any OpenCV functions.
// You must load this library _exactly once_ per Java invocation.
// If you load it more than once, you will get a java.lang.UnsatisfiedLinkError.
System
.
loadLibrary
(
"opencv_java"
)
System
.
loadLibrary
(
Core
.
NATIVE_LIBRARY_NAME
)
ScalaCorrespondenceMatchingDemo
.
run
()
ScalaDetectFaceDemo
.
run
()
...
...
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