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
a0805412
Commit
a0805412
authored
Jan 30, 2011
by
Ethan Rublee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a few settings to the camera driver for android.
parent
f6974df2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
3 deletions
+98
-3
Application.mk.in
android/Application.mk.in
+1
-1
CMakeLists.txt
android/CMakeLists.txt
+7
-0
camerasettings.xml
android/android-jni/res/layout/camerasettings.xml
+12
-0
settingnumbers.xml
android/android-jni/res/values/settingnumbers.xml
+12
-0
CameraConfig.java
android/android-jni/src/com/opencv/camera/CameraConfig.java
+48
-0
NativePreviewer.java
...id/android-jni/src/com/opencv/camera/NativePreviewer.java
+18
-2
No files found.
android/Application.mk.in
View file @
a0805412
APP_BUILD_SCRIPT := $(call my-dir)/Android.mk
APP_PROJECT_PATH := $(call my-dir)
# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI :=
armeabi armeabi-v7a
APP_ABI :=
${ARM_TARGETS}
APP_MODULES := png jpeg jasper zlib opencv_lapack opencv_core opencv_imgproc opencv_ml opencv_highgui opencv_features2d \
opencv_legacy opencv_objdetect opencv_calib3d opencv_video opencv_contrib opencv_flann
android/CMakeLists.txt
View file @
a0805412
...
...
@@ -40,6 +40,13 @@ foreach(mdir ${module_includes})
set
(
android_module_include_dirs
"
${
android_module_include_dirs
}
${
n_f
}
/include"
)
endforeach
()
set
(
PossibleArmTargets
"armeabi armeabi-v7a;armeabi;armeabi-v7a"
)
set
(
ARM_TARGETS
"armeabi armeabi-v7a"
CACHE STRING
"the arm targets for android, recommend armeabi-v7a for floating point support and neon"
)
set_property
(
CACHE ARM_TARGETS PROPERTY STRINGS
${
PossibleArmTargets
}
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/Android.mk.master.in"
"
${
CMAKE_BINARY_DIR
}
/Android.mk"
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/Application.mk.in"
"
${
CMAKE_BINARY_DIR
}
/Application.mk"
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/AndroidManifest.xml.in"
"
${
CMAKE_BINARY_DIR
}
/AndroidManifest.xml"
)
...
...
android/android-jni/res/layout/camerasettings.xml
View file @
a0805412
...
...
@@ -27,5 +27,17 @@
android:prompt=
"@string/camera_mode_prompt"
android:entries=
"@array/camera_mode"
>
</Spinner>
</LinearLayout>
<LinearLayout
android:id=
"@+id/LinearLayout01"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/whitebalance_prompt"
/>
<Spinner
android:id=
"@+id/whitebalance"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:saveEnabled=
"true"
android:prompt=
"@string/whitebalance_prompt"
android:entries=
"@array/whitebalance"
>
</Spinner>
</LinearLayout>
</LinearLayout>
android/android-jni/res/values/settingnumbers.xml
View file @
a0805412
...
...
@@ -17,4 +17,15 @@ Image Size:\n(may not be exact)
<string
name=
"camera_mode_prompt"
>
Camera Mode:
</string>
<string-array
name=
"whitebalance"
>
<item>
auto
</item>
<item>
incandescent
</item>
<item>
fluorescent
</item>
<item>
daylight
</item>
<item>
cloudy-daylight
</item>
</string-array>
<string
name=
"whitebalance_prompt"
>
Whitebalance:
</string>
</resources>
\ No newline at end of file
android/android-jni/src/com/opencv/camera/CameraConfig.java
View file @
a0805412
...
...
@@ -19,6 +19,7 @@ public class CameraConfig extends Activity {
public
static
final
String
IMAGE_HEIGHT
=
"IMAGE_HEIGHT"
;
public
static
final
int
CAMERA_MODE_BW
=
0
;
public
static
final
int
CAMERA_MODE_COLOR
=
1
;
private
static
final
String
WHITEBALANCE
=
"WHITEBALANCE"
;
public
static
int
readCameraMode
(
Context
ctx
)
{
// Restore preferences
...
...
@@ -27,6 +28,13 @@ public class CameraConfig extends Activity {
int
mode
=
settings
.
getInt
(
CAMERA_MODE
,
CAMERA_MODE_BW
);
return
mode
;
}
public
static
String
readWhitebalace
(
Context
ctx
)
{
// Restore preferences
SharedPreferences
settings
=
ctx
.
getSharedPreferences
(
CAMERA_SETTINGS
,
0
);
return
settings
.
getString
(
WHITEBALANCE
,
"auto"
);
}
static
public
void
setCameraMode
(
Context
context
,
String
mode
)
{
int
m
=
0
;
...
...
@@ -92,11 +100,14 @@ public class CameraConfig extends Activity {
final
Spinner
size_spinner
;
final
Spinner
mode_spinner
;
final
Spinner
whitebalance_spinner
;
size_spinner
=
(
Spinner
)
findViewById
(
R
.
id
.
image_size
);
mode_spinner
=
(
Spinner
)
findViewById
(
R
.
id
.
camera_mode
);
whitebalance_spinner
=
(
Spinner
)
findViewById
(
R
.
id
.
whitebalance
);
String
strsize
=
sizeToString
(
size
);
String
strmode
=
modeToString
(
mode
);
String
wbmode
=
readWhitebalace
(
getApplicationContext
());
String
sizes
[]
=
getResources
().
getStringArray
(
R
.
array
.
image_sizes
);
...
...
@@ -118,6 +129,16 @@ public class CameraConfig extends Activity {
}
if
(
i
<=
modes
.
length
)
mode_spinner
.
setSelection
(
i
-
1
);
i
=
1
;
String
wbmodes
[]
=
getResources
().
getStringArray
(
R
.
array
.
whitebalance
);
for
(
String
x
:
wbmodes
)
{
if
(
x
.
equals
(
wbmode
))
break
;
i
++;
}
if
(
i
<=
wbmodes
.
length
)
whitebalance_spinner
.
setSelection
(
i
-
1
);
size_spinner
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
...
...
@@ -150,7 +171,34 @@ public class CameraConfig extends Activity {
}
});
whitebalance_spinner
.
setOnItemSelectedListener
(
new
OnItemSelectedListener
()
{
@Override
public
void
onItemSelected
(
AdapterView
<?>
arg0
,
View
spinner
,
int
position
,
long
arg3
)
{
Object
o
=
whitebalance_spinner
.
getItemAtPosition
(
position
);
if
(
o
!=
null
)
setWhitebalance
(
spinner
.
getContext
(),
(
String
)
o
);
}
@Override
public
void
onNothingSelected
(
AdapterView
<?>
arg0
)
{
}
});
}
public
static
void
setWhitebalance
(
Context
ctx
,
String
o
)
{
SharedPreferences
settings
=
ctx
.
getSharedPreferences
(
CAMERA_SETTINGS
,
0
);
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
WHITEBALANCE
,
o
);
editor
.
commit
();
}
private
String
modeToString
(
int
mode
)
{
...
...
android/android-jni/src/com/opencv/camera/NativePreviewer.java
View file @
a0805412
...
...
@@ -23,6 +23,8 @@ import com.opencv.camera.NativeProcessor.PoolCallback;
public
class
NativePreviewer
extends
SurfaceView
implements
SurfaceHolder
.
Callback
,
Camera
.
PreviewCallback
,
NativeProcessorCallback
{
private
String
whitebalance_mode
=
"auto"
;
/** Constructor useful for defining a NativePreviewer in android layout xml
*
* @param context
...
...
@@ -94,6 +96,7 @@ public class NativePreviewer extends SurfaceView implements
int
mode
=
CameraConfig
.
readCameraMode
(
ctx
);
setPreviewSize
(
size
[
0
],
size
[
1
]);
setGrayscale
(
mode
==
CameraConfig
.
CAMERA_MODE_BW
?
true
:
false
);
whitebalance_mode
=
CameraConfig
.
readWhitebalace
(
ctx
);
}
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
...
...
@@ -135,8 +138,20 @@ public class NativePreviewer extends SurfaceView implements
Log
.
d
(
"NativePreviewer"
,
"Determined compatible preview size is: ("
+
preview_width
+
","
+
preview_height
+
")"
);
Log
.
d
(
"NativePreviewer"
,
"Supported params: "
+
mCamera
.
getParameters
().
flatten
());
//this is available in 8+
//parameters.setExposureCompensation(0);
parameters
.
setWhiteBalance
(
whitebalance_mode
);
parameters
.
setAntibanding
(
Camera
.
Parameters
.
ANTIBANDING_OFF
);
List
<
String
>
fmodes
=
mCamera
.
getParameters
().
getSupportedFocusModes
();
//for(String x: fmodes){
//}
if
(
parameters
.
get
(
"meter-mode"
)!=
null
)
parameters
.
set
(
"meter-mode"
,
"meter-average"
);
int
idx
=
fmodes
.
indexOf
(
Camera
.
Parameters
.
FOCUS_MODE_INFINITY
);
if
(
idx
!=
-
1
)
{
parameters
.
setFocusMode
(
Camera
.
Parameters
.
FOCUS_MODE_INFINITY
);
...
...
@@ -151,9 +166,10 @@ public class NativePreviewer extends SurfaceView implements
List
<
String
>
scenemodes
=
mCamera
.
getParameters
()
.
getSupportedSceneModes
();
if
(
scenemodes
!=
null
)
if
(
scenemodes
.
indexOf
(
Camera
.
Parameters
.
SCENE_MODE_
STEADYPHOTO
)
!=
-
1
)
{
if
(
scenemodes
.
indexOf
(
Camera
.
Parameters
.
SCENE_MODE_
ACTION
)
!=
-
1
)
{
parameters
.
setSceneMode
(
Camera
.
Parameters
.
SCENE_MODE_STEADYPHOTO
);
.
setSceneMode
(
Camera
.
Parameters
.
SCENE_MODE_ACTION
);
Log
.
d
(
"NativePreviewer"
,
"set scenemode to action"
);
}
parameters
.
setPreviewSize
(
preview_width
,
preview_height
);
...
...
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