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
206aa50f
Commit
206aa50f
authored
Jun 16, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Android native camera module
parent
5cae924a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
172 additions
and
23 deletions
+172
-23
libnative_camera_r2.2.2.so
3rdparty/lib/libnative_camera_r2.2.2.so
+0
-0
libnative_camera_r2.3.3.so
3rdparty/lib/libnative_camera_r2.3.3.so
+0
-0
CMakeLists.txt
CMakeLists.txt
+6
-20
OpenCVConfig.cmake.in
OpenCVConfig.cmake.in
+20
-0
android.toolchain.cmake
android/android.toolchain.cmake
+1
-1
CMakeLists.txt
modules/CMakeLists.txt
+2
-0
CMakeLists.txt
modules/androidcamera/CMakeLists.txt
+49
-0
camera_wrapper.cpp
modules/androidcamera/camera_wrapper/camera_wrapper.cpp
+0
-0
camera_wrapper.h
modules/androidcamera/camera_wrapper/camera_wrapper.h
+24
-0
camera_activity.hpp
modules/androidcamera/include/camera_activity.hpp
+49
-0
camera_properties.h
modules/androidcamera/include/camera_properties.h
+10
-0
camera_activity.cpp
modules/androidcamera/src/camera_activity.cpp
+0
-0
CMakeLists.txt
modules/highgui/CMakeLists.txt
+10
-1
cap_android.cpp
modules/highgui/src/cap_android.cpp
+1
-1
No files found.
3rdparty/lib/libnative_camera_r2.2.2.so
0 → 100644
View file @
206aa50f
File added
3rdparty/lib/libnative_camera_r2.3.3.so
0 → 100644
View file @
206aa50f
File added
CMakeLists.txt
View file @
206aa50f
...
...
@@ -553,19 +553,6 @@ if(WITH_JASPER AND NOT JASPER_FOUND)
set
(
JASPER_LIBRARIES libjasper
)
endif
()
if
(
ANDROID
)
#android camera support
set
(
NativeCamera_DIR
"
${
OpenCV_SOURCE_DIR
}
/android/native-camera/build"
)
FIND_PACKAGE
(
NativeCamera QUIET
)
if
(
NativeCamera_FOUND
)
set
(
HAVE_ANDROID_NATIVE_CAMERA TRUE
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
${
NativeCamera_LIBS
}
)
else
()
set
(
HAVE_ANDROID_NATIVE_CAMERA FALSE
)
message
(
STATUS
"Could NOT find NativeCamera for Android"
)
endif
()
endif
()
#message(STATUS "Graphic libraries: ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${JASPER_LIBRARIES}")
if
(
WITH_OPENEXR
)
...
...
@@ -667,7 +654,7 @@ endif()
############################### TBB ################################
if
(
WITH_TBB
)
if
(
UNIX AND NOT APPLE
)
if
(
UNIX AND NOT APPLE
AND NOT ANDROID
)
PKG_CHECK_MODULES
(
TBB tbb
)
message
(
STATUS
"TBB detected:
${
TBBLIB_FOUND
}
"
)
...
...
@@ -682,7 +669,7 @@ if (WITH_TBB)
endif
()
if
(
NOT HAVE_TBB
)
set
(
TBB_DEFAULT_INCLUDE_DIRS
"/opt/intel/tbb"
"/usr/local/include"
"/usr/include"
"C:/Program Files/Intel/TBB"
"C:/Program Files (x86)/Intel/TBB"
"C:/Program Files (x86)/TBB"
)
set
(
TBB_DEFAULT_INCLUDE_DIRS
"/opt/intel/tbb"
"/usr/local/include"
"/usr/include"
"C:/Program Files/Intel/TBB"
"C:/Program Files (x86)/Intel/TBB"
"C:/Program Files (x86)/TBB"
"
${
CMAKE_INSTALL_PREFIX
}
/include"
)
find_path
(
TBB_INCLUDE_DIR
"tbb/tbb.h"
PATHS
${
TBB_DEFAULT_INCLUDE_DIRS
}
DOC
"The path to TBB headers"
)
if
(
TBB_INCLUDE_DIR
)
...
...
@@ -692,6 +679,9 @@ if (WITH_TBB)
endif
()
if
(
APPLE
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
libtbb.dylib
)
elseif
(
ANDROID
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
tbbmalloc tbb
)
add_definitions
(
-DTBB_USE_GCC_BUILTINS
)
elseif
(
UNIX
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
tbb
)
elseif
(
WIN32
)
...
...
@@ -1170,10 +1160,6 @@ set(CMAKE_BASE_INCLUDE_DIRS_CONFIGCMAKE "\"${CMAKE_CURRENT_SOURCE_DIR}\"")
set
(
CMAKE_LIB_DIRS_CONFIGCMAKE
"
${
LIBRARY_OUTPUT_PATH
}
"
)
if
(
HAVE_ANDROID_NATIVE_CAMERA
)
set
(
CMAKE_LIB_DIRS_CONFIGCMAKE
${
CMAKE_LIB_DIRS_CONFIGCMAKE
}
${
NativeCamera_LIB_DIR
}
)
endif
()
configure_file
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/OpenCVConfig.cmake.in"
"
${
CMAKE_BINARY_DIR
}
/OpenCVConfig.cmake"
IMMEDIATE @ONLY
)
# --------------------------------------------------------------------------------------------
...
...
@@ -1467,7 +1453,7 @@ message(STATUS " V4L/V4L2: ${HAVE_CAMV4L}/${HAVE_CAMV4L2}")
endif
()
message
(
STATUS
" Xine:
${
HAVE_XINE
}
"
)
if
(
ANDROID
)
message
(
STATUS
" AndroidNativeCamera:
${
HAVE_ANDROID_NATIVE_CAMERA
}
"
)
message
(
STATUS
" AndroidNativeCamera:
build
"
)
endif
()
endif
()
#if(UNIX AND NOT APPLE)
...
...
OpenCVConfig.cmake.in
View file @
206aa50f
...
...
@@ -58,6 +58,9 @@ if(NOT ANDROID)
else()
#libraries order is very important because linker from Android NDK is one-pass linker
set(OPENCV_LIB_COMPONENTS opencv_contrib opencv_calib3d opencv_objdetect opencv_features2d opencv_imgproc opencv_video opencv_highgui opencv_ml opencv_legacy opencv_flann opencv_core )
IF (NOT @BUILD_SHARED_LIBS@)
set(OPENCV_LIB_COMPONENTS opencv_androidcamera ${OPENCV_LIB_COMPONENTS})
ENDIF()
endif()
SET(OpenCV_LIBS "")
...
...
@@ -114,6 +117,23 @@ IF (NOT @BUILD_SHARED_LIBS@)
ENDIF(NOT @BUILD_SHARED_LIBS@)
# ======================================================
# Android camera helper macro
# ======================================================
IF (ANDROID)
macro( COPY_NATIVE_CAMERA_LIBS target )
get_target_property(target_location ${target} LOCATION)
get_filename_component(target_location "${target_location}" PATH)
file(GLOB camera_wrappers "${OpenCV_LIB_DIR}/libnative_camera_r*.so")
foreach(wrapper ${camera_wrappers})
ADD_CUSTOM_COMMAND(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${wrapper}" "${target_location}"
)
endforeach()
endmacro()
ENDIF(ANDROID)
# ======================================================
# Version variables:
...
...
android/android.toolchain.cmake
View file @
206aa50f
...
...
@@ -321,7 +321,7 @@ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags" )
#-L${LIBCPP_LINK_DIR} -lstdc++ -lsupc++
#Also, this is *required* to use the following linker flags that routes around
#a CPU bug in some Cortex-A8 implementations:
set
(
LINKER_FLAGS
"-Wl,--fix-cortex-a8 -L
${
STL_LIBRARIES_PATH
}
-lstdc++ -lsupc++ "
)
set
(
LINKER_FLAGS
"-Wl,--fix-cortex-a8 -L
${
STL_LIBRARIES_PATH
}
-
L
${
CMAKE_INSTALL_PREFIX
}
/lib -
lstdc++ -lsupc++ "
)
set
(
NO_UNDEFINED ON CACHE BOOL
"Don't all undefined symbols"
)
if
(
NO_UNDEFINED
)
...
...
modules/CMakeLists.txt
View file @
206aa50f
...
...
@@ -3,6 +3,8 @@ if(ANDROID)
if
(
ANDROID_API_LEVEL LESS 8
)
ADD_DEFINITIONS
(
-DGTEST_HAS_CLONE=0
)
endif
()
add_subdirectory
(
androidcamera
)
endif
()
add_subdirectory
(
calib3d
)
...
...
modules/androidcamera/CMakeLists.txt
0 → 100644
View file @
206aa50f
IF
(
NOT ANDROID
)
MESSAGE
(
FATAL_ERROR
"This project is for ANDROID only"
)
ENDIF
()
if
(
BUILD_ANDROID_CAMERA_WRAPPER
)
add_subdirectory
(
camera_wrapper
)
endif
()
project
(
opencv_androidcamera
)
INCLUDE_DIRECTORIES
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/camera_wrapper
)
SET
(
LIBRARY_DEPS
${
LIBRARY_DEPS
}
log dl
)
SET
(
the_target opencv_androidcamera
)
ADD_LIBRARY
(
${
the_target
}
STATIC src/camera_activity.cpp
)
if
(
BUILD_SHARED_LIBS
)
add_definitions
(
-DCVAPI_EXPORTS
)
endif
()
TARGET_LINK_LIBRARIES
(
${
the_target
}
${
LIBRARY_DEPS
}
)
SET_TARGET_PROPERTIES
(
${
the_target
}
PROPERTIES
DEBUG_POSTFIX
"
${
OPENCV_DEBUG_POSTFIX
}
"
OUTPUT_NAME
"
${
the_target
}${
OPENCV_DLLVERSION
}
"
DEFINE_SYMBOL
"CVAPI_EXPORTS"
ARCHIVE_OUTPUT_DIRECTORY
${
LIBRARY_OUTPUT_PATH
}
RUNTIME_OUTPUT_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
)
IF
(
NOT BUILD_SHARED_LIBS
)
install
(
TARGETS
${
the_target
}
RUNTIME DESTINATION bin COMPONENT main
ARCHIVE DESTINATION lib COMPONENT main
LIBRARY DESTINATION lib COMPONENT main
)
ENDIF
()
file
(
GLOB camera_wrappers
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../3rdparty/lib/libnative_camera_r*.so"
)
foreach
(
wrapper
${
camera_wrappers
}
)
ADD_CUSTOM_COMMAND
(
TARGET
${
the_target
}
POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
wrapper
}
"
"
${
LIBRARY_OUTPUT_PATH
}
"
)
endforeach
()
\ No newline at end of file
modules/androidcamera/camera_wrapper/camera_wrapper.cpp
0 → 100644
View file @
206aa50f
This diff is collapsed.
Click to expand it.
modules/androidcamera/camera_wrapper/camera_wrapper.h
0 → 100644
View file @
206aa50f
enum
CameraWrapperErrorCode
{
ERROR_NATIVE_CAMERA_WRAPPER_NOERROR
=
0
,
ERROR_NATIVE_CAMERA_WRAPPER_CANNOT_FIND_CLASS
=
1
,
ERROR_NATIVE_CAMERA_WRAPPER_CANNOT_FIND_FIELD
=
2
,
ERROR_NATIVE_CAMERA_WRAPPER_CANNOT_SET_PREVIEW_DISPLAY
=
3
};
typedef
bool
(
*
CameraCallback
)(
void
*
buffer
,
size_t
bufferSize
,
void
*
userData
);
typedef
void
*
(
*
InitCameraConnectC
)(
void
*
cameraCallback
,
int
cameraId
,
void
*
userData
);
typedef
void
(
*
CloseCameraConnectC
)(
void
**
);
typedef
double
(
*
GetCameraPropertyC
)(
void
*
camera
,
int
propIdx
);
typedef
void
(
*
SetCameraPropertyC
)(
void
*
camera
,
int
propIdx
,
double
value
);
typedef
void
(
*
ApplyCameraPropertiesC
)(
void
**
camera
);
extern
"C"
{
void
*
initCameraConnectC
(
void
*
cameraCallback
,
int
cameraId
,
void
*
userData
);
void
closeCameraConnectC
(
void
**
);
double
getCameraPropertyC
(
void
*
camera
,
int
propIdx
);
void
setCameraPropertyC
(
void
*
camera
,
int
propIdx
,
double
value
);
void
applyCameraPropertiesC
(
void
**
camera
);
}
modules/androidcamera/include/camera_activity.hpp
0 → 100644
View file @
206aa50f
#ifndef _CAMERAACTIVITY_H_
#define _CAMERAACTIVITY_H_
#include <camera_properties.h>
//#include <opencv2/core/core.hpp>
class
CameraActivity
{
public
:
enum
ErrorCode
{
NO_ERROR
=
0
,
ERROR_WRONG_FRAME_SIZE
,
ERROR_WRONG_POINTER_CAMERA_WRAPPER
,
ERROR_CAMERA_CONNECTED
,
ERROR_CANNOT_OPEN_CAMERA_WRAPPER_LIB
,
ERROR_CANNOT_GET_FUNCTION_FROM_CAMERA_WRAPPER_LIB
,
ERROR_CANNOT_INITIALIZE_CONNECTION
,
ERROR_ISNT_CONNECTED
,
ERROR_JAVA_VM_CANNOT_GET_CLASS
,
ERROR_JAVA_VM_CANNOT_GET_FIELD
,
ERROR_CANNOT_SET_PREVIEW_DISPLAY
,
ERROR_UNKNOWN
=
255
};
CameraActivity
();
virtual
~
CameraActivity
();
virtual
bool
onFrameBuffer
(
void
*
buffer
,
int
bufferSize
);
ErrorCode
connect
(
int
cameraId
=
0
);
void
disconnect
();
bool
isConnected
()
const
;
double
getProperty
(
int
propIdx
);
void
setProperty
(
int
propIdx
,
double
value
);
void
applyProperties
();
int
getFrameWidth
();
int
getFrameHeight
();
static
void
setPathLibFolder
(
const
char
*
path
);
private
:
void
*
camera
;
int
frameWidth
;
int
frameHeight
;
};
#endif
\ No newline at end of file
modules/androidcamera/include/camera_properties.h
0 → 100644
View file @
206aa50f
#ifndef CAMERA_PROPERTIES_H
#define CAMERA_PROPERTIES_H
enum
{
ANDROID_CAMERA_PROPERTY_FRAMEWIDTH
=
0
,
ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT
=
1
,
ANDROID_CAMERA_PROPERTY_SUPPORTED_PREVIEW_SIZES_STRING
=
2
};
#endif // CAMERA_PROPERTIES_H
modules/androidcamera/src/camera_activity.cpp
0 → 100644
View file @
206aa50f
This diff is collapsed.
Click to expand it.
modules/highgui/CMakeLists.txt
View file @
206aa50f
...
...
@@ -211,9 +211,11 @@ if(APPLE)
endif
()
endif
(
APPLE
)
if
(
HAVE_ANDROID_NATIVE_CAMERA
)
if
(
ANDROID
)
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../androidcamera/include"
)
set
(
highgui_srcs
${
highgui_srcs
}
src/cap_android.cpp
)
add_definitions
(
-DHAVE_ANDROID_NATIVE_CAMERA
)
set
(
HIGHGUI_LIBRARIES
${
HIGHGUI_LIBRARIES
}
opencv_androidcamera
)
endif
()
if
(
COMMAND get_module_external_sources
)
...
...
@@ -331,6 +333,10 @@ if(NOT ZLIB_FOUND)
add_dependencies
(
${
the_target
}
zlib
)
endif
()
if
(
ANDROID
)
add_dependencies
(
${
the_target
}
opencv_androidcamera
)
endif
()
#message(STATUS "GRFMT: ${GRFMT_LIBS}")
#message(STATUS "HIGHGUI_LIBS: ${HIGHGUI_LIBRARIES}")
#message(STATUS "OPENCV_LIBS: ${OPENCV_LINKER_LIBS}")
...
...
@@ -371,6 +377,9 @@ if(BUILD_TESTS)
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
)
set
(
test_deps opencv_ts opencv_highgui opencv_imgproc
)
if
(
ANDROID
)
set
(
test_deps
${
test_deps
}
opencv_androidcamera
)
endif
()
foreach
(
d
${
test_deps
}
)
if
(
${
d
}
MATCHES
"opencv_"
)
...
...
modules/highgui/src/cap_android.cpp
View file @
206aa50f
...
...
@@ -46,7 +46,7 @@
#include <opencv2/imgproc/imgproc.hpp>
#include <pthread.h>
#include <android/log.h>
#include
"camera_activity.h"
#include
<camera_activity.hpp>
#if !defined(LOGD) && !defined(LOGI) && !defined(LOGE)
#define LOG_TAG "CV_CAP"
...
...
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