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
22484872
Commit
22484872
authored
Nov 30, 2012
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sample Tutorial-5 improved
Aditional toasts added; Exception handling improved; Bitmap recycling added.
parent
f6ca38a5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
Sample5CameraControl.java
...rc/org/opencv/samples/tutorial5/Sample5CameraControl.java
+10
-1
SampleJavaCameraView.java
...rc/org/opencv/samples/tutorial5/SampleJavaCameraView.java
+5
-0
No files found.
samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/Sample5CameraControl.java
View file @
22484872
...
...
@@ -20,6 +20,7 @@ import android.view.SurfaceView;
import
android.view.View
;
import
android.view.View.OnTouchListener
;
import
android.view.WindowManager
;
import
android.widget.Toast
;
public
class
Sample5CameraControl
extends
Activity
implements
CvCameraViewListener
,
OnTouchListener
{
private
static
final
String
TAG
=
"OCVSample::Activity"
;
...
...
@@ -100,6 +101,11 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen
public
boolean
onCreateOptionsMenu
(
Menu
menu
)
{
List
<
String
>
effects
=
mOpenCvCameraView
.
getEffectList
();
if
(
effects
==
null
)
{
Log
.
e
(
TAG
,
"Color effects are not supported by device!"
);
return
true
;
}
mEffectMenuItems
=
new
MenuItem
[
effects
.
size
()];
int
idx
=
0
;
...
...
@@ -115,13 +121,16 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
Log
.
i
(
TAG
,
"called onOptionsItemSelected; selected item: "
+
item
);
mOpenCvCameraView
.
setEffect
((
String
)
item
.
getTitle
());
Toast
.
makeText
(
this
,
mOpenCvCameraView
.
getEffect
(),
Toast
.
LENGTH_SHORT
).
show
();
return
true
;
}
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
Log
.
i
(
TAG
,
"onTouch event"
);
mOpenCvCameraView
.
takePicture
(
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/sample_picture.jpg"
);
String
fileName
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/sample_picture.jpg"
;
mOpenCvCameraView
.
takePicture
(
fileName
);
Toast
.
makeText
(
this
,
fileName
+
" saved"
,
Toast
.
LENGTH_SHORT
).
show
();
return
false
;
}
}
samples/android/tutorial-5-cameracontrol/src/org/opencv/samples/tutorial5/SampleJavaCameraView.java
View file @
22484872
...
...
@@ -25,6 +25,10 @@ public class SampleJavaCameraView extends JavaCameraView {
return
mCamera
.
getParameters
().
getSupportedColorEffects
();
}
public
boolean
isEffectSupported
()
{
return
(
mCamera
.
getParameters
().
getColorEffect
()
!=
null
);
}
public
String
getEffect
()
{
return
mCamera
.
getParameters
().
getColorEffect
();
}
...
...
@@ -48,6 +52,7 @@ public class SampleJavaCameraView extends JavaCameraView {
try
{
FileOutputStream
out
=
new
FileOutputStream
(
mPictureFileName
);
picture
.
compress
(
Bitmap
.
CompressFormat
.
JPEG
,
90
,
out
);
picture
.
recycle
();
mCamera
.
startPreview
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
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