Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
86c7e183
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
994
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
86c7e183
编写于
9月 10, 2012
作者:
A
Alexander Smorkalov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Issue #2316 Change default libnative_camera path implemented.
上级
e564a53c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
73 addition
and
39 deletion
+73
-39
modules/androidcamera/CMakeLists.txt
modules/androidcamera/CMakeLists.txt
+1
-1
modules/androidcamera/src/camera_activity.cpp
modules/androidcamera/src/camera_activity.cpp
+72
-38
未找到文件。
modules/androidcamera/CMakeLists.txt
浏览文件 @
86c7e183
...
...
@@ -5,7 +5,7 @@ ENDIF()
set
(
the_description
"Auxiliary module for Android native camera support"
)
set
(
OPENCV_MODULE_TYPE STATIC
)
ocv_define_module
(
androidcamera INTERNAL log dl
)
ocv_define_module
(
androidcamera INTERNAL
opencv_core
log dl
)
ocv_include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/camera_wrapper"
)
# Android source tree for native camera
...
...
modules/androidcamera/src/camera_activity.cpp
浏览文件 @
86c7e183
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <android/log.h>
#include <string>
#include <vector>
#include <algorithm>
#include <opencv2/core/version.hpp>
#include "camera_activity.hpp"
#include "camera_wrapper.h"
...
...
@@ -41,6 +45,7 @@ private:
static
bool
isConnectedToLib
;
static
std
::
string
getPathLibFolder
();
static
std
::
string
getDefaultPathLibFolder
();
static
CameraActivity
::
ErrorCode
connectToLib
();
static
CameraActivity
::
ErrorCode
getSymbolFromLib
(
void
*
libHandle
,
const
char
*
symbolName
,
void
**
ppSymbol
);
static
void
fillListWrapperLibs
(
const
string
&
folderPath
,
vector
<
string
>&
listLibs
);
...
...
@@ -55,8 +60,6 @@ private:
};
std
::
string
CameraWrapperConnector
::
pathLibFolder
;
#define DEFAULT_WRAPPER_PACKAGE_NAME "com.NativeCamera"
#define DEFAULT_PATH_LIB_FOLDER "/data/data/" DEFAULT_WRAPPER_PACKAGE_NAME "/lib/"
bool
CameraWrapperConnector
::
isConnectedToLib
=
false
;
InitCameraConnectC
CameraWrapperConnector
::
pInitCameraC
=
0
;
...
...
@@ -163,7 +166,13 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
}
dlerror
();
string
folderPath
=
getPathLibFolder
();
string
folderPath
=
getPathLibFolder
();
if
(
folderPath
.
empty
())
{
LOGD
(
"Trying to find native camera in default OpenCV packages"
);
folderPath
=
getDefaultPathLibFolder
();
}
LOGD
(
"CameraWrapperConnector::connectToLib: folderPath=%s"
,
folderPath
.
c_str
());
vector
<
string
>
listLibs
;
...
...
@@ -256,6 +265,31 @@ void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vecto
}
}
std
::
string
CameraWrapperConnector
::
getDefaultPathLibFolder
()
{
const
string
packageList
[]
=
{
"tegra3"
,
"armv7a_neon"
,
"armv7a"
,
"armv5"
,
"x86"
};
for
(
size_t
i
=
0
;
i
<
5
;
i
++
)
{
char
path
[
128
];
sprintf
(
path
,
"/data/data/org.opencv.lib_v%d%d_%s/lib/"
,
CV_MAJOR_VERSION
,
CV_MINOR_VERSION
,
packageList
[
i
].
c_str
());
LOGD
(
"Trying package
\"
%s
\"
(
\"
%s
\"
)"
,
packageList
[
i
],
path
);
DIR
*
dir
=
opendir
(
path
);
if
(
!
dir
)
{
LOGD
(
"Package not found"
);
continue
;
}
else
{
closedir
(
dir
);
return
path
;
}
}
return
string
();
}
std
::
string
CameraWrapperConnector
::
getPathLibFolder
()
{
if
(
!
pathLibFolder
.
empty
())
...
...
@@ -278,41 +312,41 @@ std::string CameraWrapperConnector::getPathLibFolder()
{
while
(
fgets
(
lineBuf
,
sizeof
lineBuf
,
file
)
!=
NULL
)
{
//verify that line ends with library name
int
lineLength
=
strlen
(
lineBuf
);
int
libNameLength
=
strlen
(
libName
);
//trim end
for
(
int
i
=
lineLength
-
1
;
i
>=
0
&&
isspace
(
lineBuf
[
i
]);
--
i
)
{
lineBuf
[
i
]
=
0
;
--
lineLength
;
}
if
(
0
!=
strncmp
(
lineBuf
+
lineLength
-
libNameLength
,
libName
,
libNameLength
))
{
//the line does not contain the library name
continue
;
}
//extract path from smaps line
char
*
pathBegin
=
strchr
(
lineBuf
,
'/'
);
if
(
0
==
pathBegin
)
{
LOGE
(
"Strange error: could not find path beginning in lin
\"
%s
\"
"
,
lineBuf
);
continue
;
}
char
*
pathEnd
=
strrchr
(
pathBegin
,
'/'
);
pathEnd
[
1
]
=
0
;
LOGD
(
"Libraries folder found: %s"
,
pathBegin
);
fclose
(
file
);
return
pathBegin
;
//verify that line ends with library name
int
lineLength
=
strlen
(
lineBuf
);
int
libNameLength
=
strlen
(
libName
);
//trim end
for
(
int
i
=
lineLength
-
1
;
i
>=
0
&&
isspace
(
lineBuf
[
i
]);
--
i
)
{
lineBuf
[
i
]
=
0
;
--
lineLength
;
}
if
(
0
!=
strncmp
(
lineBuf
+
lineLength
-
libNameLength
,
libName
,
libNameLength
))
{
//the line does not contain the library name
continue
;
}
//extract path from smaps line
char
*
pathBegin
=
strchr
(
lineBuf
,
'/'
);
if
(
0
==
pathBegin
)
{
LOGE
(
"Strange error: could not find path beginning in lin
\"
%s
\"
"
,
lineBuf
);
continue
;
}
char
*
pathEnd
=
strrchr
(
pathBegin
,
'/'
);
pathEnd
[
1
]
=
0
;
LOGD
(
"Libraries folder found: %s"
,
pathBegin
);
fclose
(
file
);
return
pathBegin
;
}
fclose
(
file
);
LOGE
(
"Could not find library path
.
"
);
LOGE
(
"Could not find library path"
);
}
else
{
...
...
@@ -321,10 +355,10 @@ std::string CameraWrapperConnector::getPathLibFolder()
}
else
{
LOGE
(
"Could not get library name and base address.
"
);
LOGE
(
"Could not get library name and base address
"
);
}
return
DEFAULT_PATH_LIB_FOLDER
;
return
string
()
;
}
void
CameraWrapperConnector
::
setPathLibFolder
(
const
string
&
path
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录