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
c1c1a376
Commit
c1c1a376
authored
Apr 28, 2012
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bad changes reverted.
parent
a9d9eb1a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
211 deletions
+11
-211
AsyncServiceHelper.java
modules/java/src/java/AsyncServiceHelper.java
+0
-165
LoaderCallbackInterface.java
modules/java/src/java/LoaderCallbackInterface.java
+0
-6
OpenCVLoader.java
modules/java/src/java/OpenCVLoader.java
+0
-40
android+Utils.java
modules/java/src/java/android+Utils.java
+5
-0
core+Mat.java
modules/java/src/java/core+Mat.java
+0
-0
highgui+VideoCapture.java
modules/java/src/java/highgui+VideoCapture.java
+6
-0
utils+Converters.java
modules/java/src/java/utils+Converters.java
+0
-0
No files found.
modules/java/src/java/AsyncServiceHelper.java
deleted
100644 → 0
View file @
a9d9eb1a
package
org
.
opencv
.
android
;
import
java.io.File
;
import
java.util.StringTokenizer
;
import
org.opencv.engine.OpenCVEngineInterface
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.ServiceConnection
;
import
android.os.IBinder
;
import
android.os.RemoteException
;
import
android.util.Log
;
public
class
AsyncServiceHelper
{
public
static
int
initOpenCV
(
String
Version
,
Context
AppContext
,
LoaderCallbackInterface
Callback
)
{
AsyncServiceHelper
helper
=
new
AsyncServiceHelper
(
Version
,
AppContext
,
Callback
);
if
(
AppContext
.
bindService
(
new
Intent
(
"org.opencv.engine.BIND"
),
helper
.
mServiceConnection
,
Context
.
BIND_AUTO_CREATE
))
{
return
OpenCVLoader
.
Success
;
}
else
{
return
OpenCVLoader
.
NoService
;
}
}
protected
AsyncServiceHelper
(
String
Version
,
Context
AppContext
,
LoaderCallbackInterface
Callback
)
{
mOpenCVersion
=
Version
;
mUserAppCallback
=
Callback
;
mAppContext
=
AppContext
;
}
protected
static
final
String
TAG
=
"OpenCvEngine/Helper"
;
protected
OpenCVEngineInterface
mEngineService
;
protected
LoaderCallbackInterface
mUserAppCallback
;
protected
String
mOpenCVersion
;
protected
Context
mAppContext
;
protected
int
mStatus
=
OpenCVLoader
.
Success
;
protected
ServiceConnection
mServiceConnection
=
new
ServiceConnection
()
{
public
void
onServiceConnected
(
ComponentName
className
,
IBinder
service
)
{
Log
.
d
(
TAG
,
"Service connection created"
);
mEngineService
=
OpenCVEngineInterface
.
Stub
.
asInterface
(
service
);
if
(
null
==
mEngineService
)
{
Log
.
d
(
TAG
,
"Engine connection fails. May be service was not installed?"
);
mStatus
=
OpenCVLoader
.
NoService
;
}
else
{
try
{
Log
.
d
(
TAG
,
"Trying to get library path"
);
String
path
=
mEngineService
.
getLibPathByVersion
(
mOpenCVersion
);
if
((
null
==
path
)
||
(
path
.
length
()
==
0
))
{
if
(
mEngineService
.
installVersion
(
mOpenCVersion
))
{
mStatus
=
OpenCVLoader
.
RestartRequired
;
}
else
{
Log
.
d
(
TAG
,
"OpenCV package was not installed!"
);
mStatus
=
OpenCVLoader
.
MarketError
;
}
}
else
{
Log
.
d
(
TAG
,
"Trying to get library list"
);
String
libs
=
mEngineService
.
getLibraryList
(
mOpenCVersion
);
Log
.
d
(
TAG
,
"Library list: \""
+
libs
+
"\""
);
Log
.
d
(
TAG
,
"First attempt to load libs"
);
if
(
initOpenCVLibs
(
path
,
libs
))
{
Log
.
d
(
TAG
,
"First attempt to load libs is OK"
);
mStatus
=
OpenCVLoader
.
Success
;
}
else
{
Log
.
d
(
TAG
,
"First attempt to load libs fails"
);
mStatus
=
OpenCVLoader
.
InitFailed
;
}
}
}
catch
(
RemoteException
e
)
{
e
.
printStackTrace
();
mStatus
=
OpenCVLoader
.
InitFailed
;
}
}
Log
.
d
(
TAG
,
"Init finished with status "
+
mStatus
);
Log
.
d
(
TAG
,
"Unbind from service"
);
mAppContext
.
unbindService
(
mServiceConnection
);
Log
.
d
(
TAG
,
"Calling using callback"
);
mUserAppCallback
.
onEngineConnected
(
mStatus
);
}
private
boolean
loadLibrary
(
String
AbsPath
)
{
boolean
result
=
true
;
Log
.
d
(
TAG
,
"Trying to load library "
+
AbsPath
);
try
{
System
.
load
(
AbsPath
);
Log
.
d
(
TAG
,
"OpenCV libs init was ok!"
);
}
catch
(
Exception
e
)
{
Log
.
d
(
TAG
,
"Cannot load library \""
+
AbsPath
+
"\""
);
e
.
printStackTrace
();
result
&=
false
;
}
return
result
;
}
private
boolean
initOpenCVLibs
(
String
Path
,
String
Libs
)
{
Log
.
d
(
TAG
,
"Trying to init OpenCV libs"
);
if
((
null
!=
Path
)
&&
(
Path
.
length
()
!=
0
))
{
boolean
result
=
true
;
if
((
null
!=
Libs
)
&&
(
Libs
.
length
()
!=
0
))
{
Log
.
d
(
TAG
,
"Trying to load libs by dependency list"
);
StringTokenizer
splitter
=
new
StringTokenizer
(
Libs
,
";"
);
while
(
splitter
.
hasMoreTokens
())
{
String
AbsLibraryPath
=
Path
+
File
.
separator
+
splitter
.
nextToken
();
result
&=
loadLibrary
(
AbsLibraryPath
);
}
}
else
{
// If dependencies list is not defined or empty
String
AbsLibraryPath
=
Path
+
File
.
separator
+
"libopencv_java.so"
;
result
&=
loadLibrary
(
AbsLibraryPath
);
}
return
result
;
}
else
{
Log
.
d
(
TAG
,
"Library path \""
+
Path
+
"\" is empty"
);
return
false
;
}
}
public
void
onServiceDisconnected
(
ComponentName
className
)
{
mEngineService
=
null
;
}
};
}
modules/java/src/java/LoaderCallbackInterface.java
deleted
100644 → 0
View file @
a9d9eb1a
package
org
.
opencv
.
android
;
public
interface
LoaderCallbackInterface
{
public
void
onEngineConnected
(
int
status
);
};
modules/java/src/java/OpenCVLoader.java
deleted
100644 → 0
View file @
a9d9eb1a
package
org
.
opencv
.
android
;
import
android.content.Context
;
import
android.util.Log
;
public
class
OpenCVLoader
{
public
static
final
int
Success
=
0
;
public
static
final
int
NoService
=
1
;
public
static
final
int
RestartRequired
=
2
;
public
static
final
int
MarketError
=
3
;
public
static
final
int
InitFailed
=
0xff
;
public
static
int
initStatic
()
{
int
result
;
try
{
System
.
loadLibrary
(
"opencv_java"
);
result
=
Success
;
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"OpenCV error: Cannot load native library"
);
e
.
printStackTrace
();
result
=
InitFailed
;
}
return
result
;
}
public
static
int
initAsync
(
String
Version
,
Context
AppContext
,
LoaderCallbackInterface
Callback
)
{
return
AsyncServiceHelper
.
initOpenCV
(
Version
,
AppContext
,
Callback
);
}
private
static
final
String
TAG
=
"OpenCV/Helper"
;
}
modules/java/src/java/android+Utils.java
View file @
c1c1a376
...
...
@@ -113,6 +113,11 @@ public class Utils {
nMatToBitmap
(
m
.
nativeObj
,
b
);
}
// native stuff
static
{
System
.
loadLibrary
(
"opencv_java"
);
}
private
static
native
void
nBitmapToMat
(
Bitmap
b
,
long
m_addr
);
private
static
native
void
nMatToBitmap
(
long
m_addr
,
Bitmap
b
);
...
...
modules/java/src/java/core+Mat.java
View file @
c1c1a376
This diff is collapsed.
Click to expand it.
modules/java/src/java/highgui+VideoCapture.java
View file @
c1c1a376
...
...
@@ -194,6 +194,12 @@ public class VideoCapture {
super
.
finalize
();
}
// native stuff
static
{
System
.
loadLibrary
(
"opencv_java"
);
}
// C++: VideoCapture::VideoCapture()
private
static
native
long
n_VideoCapture
();
...
...
modules/java/src/java/utils+Converters.java
View file @
c1c1a376
This diff is collapsed.
Click to expand it.
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