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
207f4fc5
Commit
207f4fc5
authored
Jun 26, 2012
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sample 1 updated for OpenCV Manager model.
parent
e7c35b18
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
3 deletions
+45
-3
Sample1Java.java
...dopencv/src/org/opencv/samples/tutorial1/Sample1Java.java
+45
-3
No files found.
samples/android/tutorial-1-addopencv/src/org/opencv/samples/tutorial1/Sample1Java.java
View file @
207f4fc5
package
org
.
opencv
.
samples
.
tutorial1
;
import
org.opencv.android.BaseLoaderCallback
;
import
org.opencv.android.LoaderCallbackInterface
;
import
org.opencv.android.OpenCVLoader
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
...
...
@@ -17,6 +21,38 @@ public class Sample1Java extends Activity {
private
MenuItem
mItemPreviewCanny
;
private
Sample1View
mView
;
private
BaseLoaderCallback
mOpenCVCallBack
=
new
BaseLoaderCallback
(
this
)
{
@Override
public
void
onManagerConnected
(
int
status
)
{
switch
(
status
)
{
case
LoaderCallbackInterface
.
SUCCESS
:
{
Log
.
i
(
TAG
,
"OpenCV loaded successfully"
);
// Create and set View
mView
=
new
Sample1View
(
mAppContext
);
setContentView
(
mView
);
// Check native OpenCV camera
if
(
!
mView
.
openCamera
()
)
{
AlertDialog
ad
=
new
AlertDialog
.
Builder
(
mAppContext
).
create
();
ad
.
setCancelable
(
false
);
// This blocks the 'BACK' button
ad
.
setMessage
(
"Fatal error: can't open camera!"
);
ad
.
setButton
(
"OK"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
dialog
.
dismiss
();
finish
();
}
});
ad
.
show
();
}
}
break
;
default
:
{
super
.
onManagerConnected
(
status
);
}
break
;
}
}
};
public
Sample1Java
()
{
Log
.
i
(
TAG
,
"Instantiated new "
+
this
.
getClass
());
}
...
...
@@ -25,6 +61,7 @@ public class Sample1Java extends Activity {
protected
void
onPause
()
{
Log
.
i
(
TAG
,
"onPause"
);
super
.
onPause
();
if
(
null
!=
mView
)
mView
.
releaseCamera
();
}
...
...
@@ -32,7 +69,7 @@ public class Sample1Java extends Activity {
protected
void
onResume
()
{
Log
.
i
(
TAG
,
"onResume"
);
super
.
onResume
();
if
(
!
mView
.
openCamera
()
)
{
if
(
(
null
!=
mView
)
&&
!
mView
.
openCamera
()
)
{
AlertDialog
ad
=
new
AlertDialog
.
Builder
(
this
).
create
();
ad
.
setCancelable
(
false
);
// This blocks the 'BACK' button
ad
.
setMessage
(
"Fatal error: can't open camera!"
);
...
...
@@ -52,8 +89,13 @@ public class Sample1Java extends Activity {
Log
.
i
(
TAG
,
"onCreate"
);
super
.
onCreate
(
savedInstanceState
);
requestWindowFeature
(
Window
.
FEATURE_NO_TITLE
);
mView
=
new
Sample1View
(
this
);
setContentView
(
mView
);
Log
.
i
(
TAG
,
"Trying to load OpenCV library"
);
if
(!
OpenCVLoader
.
initAsync
(
OpenCVLoader
.
OPEN_CV_VERSION_2_4_0
,
this
,
mOpenCVCallBack
))
{
Log
.
e
(
TAG
,
"Cannot connect to OpenCV Manager"
);
finish
();
}
}
@Override
...
...
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