2011-06-16 18:00:41 +00:00
|
|
|
#include <dlfcn.h>
|
2012-09-10 16:28:56 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
2011-06-16 18:00:41 +00:00
|
|
|
#include <android/log.h>
|
2012-12-21 19:58:51 +04:00
|
|
|
#include <cctype>
|
2011-06-16 18:00:41 +00:00
|
|
|
#include <vector>
|
2012-01-18 14:33:39 +00:00
|
|
|
#include <algorithm>
|
2012-09-10 16:28:56 +04:00
|
|
|
#include <opencv2/core/version.hpp>
|
2011-06-16 18:00:41 +00:00
|
|
|
#include "camera_activity.hpp"
|
|
|
|
#include "camera_wrapper.h"
|
2012-11-22 12:40:25 +04:00
|
|
|
#include "EngineCommon.h"
|
2011-06-16 18:00:41 +00:00
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
#include "opencv2/core.hpp"
|
|
|
|
|
2012-08-28 13:30:11 +04:00
|
|
|
#undef LOG_TAG
|
|
|
|
#undef LOGE
|
|
|
|
#undef LOGD
|
|
|
|
#undef LOGI
|
|
|
|
|
|
|
|
#define LOG_TAG "OpenCV::camera"
|
|
|
|
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
2011-06-16 18:00:41 +00:00
|
|
|
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
|
|
|
|
|
|
|
|
///////
|
|
|
|
// Debug
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
2013-04-02 20:59:43 +04:00
|
|
|
struct str_greater
|
|
|
|
{
|
|
|
|
bool operator() (const cv::String& a, const cv::String& b) { return a > b; }
|
|
|
|
};
|
|
|
|
|
2011-06-16 18:00:41 +00:00
|
|
|
class CameraWrapperConnector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static CameraActivity::ErrorCode connect(int cameraId, CameraActivity* pCameraActivity, void** camera);
|
|
|
|
static CameraActivity::ErrorCode disconnect(void** camera);
|
|
|
|
static CameraActivity::ErrorCode setProperty(void* camera, int propIdx, double value);
|
|
|
|
static CameraActivity::ErrorCode getProperty(void* camera, int propIdx, double* value);
|
|
|
|
static CameraActivity::ErrorCode applyProperties(void** ppcamera);
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
static void setPathLibFolder(const cv::String& path);
|
2011-06-16 18:00:41 +00:00
|
|
|
|
|
|
|
private:
|
2013-03-22 18:59:43 +04:00
|
|
|
static cv::String pathLibFolder;
|
2011-06-16 18:00:41 +00:00
|
|
|
static bool isConnectedToLib;
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
static cv::String getPathLibFolder();
|
|
|
|
static cv::String getDefaultPathLibFolder();
|
2011-06-16 18:00:41 +00:00
|
|
|
static CameraActivity::ErrorCode connectToLib();
|
|
|
|
static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol);
|
2013-03-22 18:59:43 +04:00
|
|
|
static void fillListWrapperLibs(const cv::String& folderPath, std::vector<cv::String>& listLibs);
|
2011-06-16 18:00:41 +00:00
|
|
|
|
|
|
|
static InitCameraConnectC pInitCameraC;
|
|
|
|
static CloseCameraConnectC pCloseCameraC;
|
|
|
|
static GetCameraPropertyC pGetPropertyC;
|
|
|
|
static SetCameraPropertyC pSetPropertyC;
|
|
|
|
static ApplyCameraPropertiesC pApplyPropertiesC;
|
|
|
|
|
|
|
|
friend bool nextFrame(void* buffer, size_t bufferSize, void* userData);
|
|
|
|
};
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
cv::String CameraWrapperConnector::pathLibFolder;
|
2011-06-16 18:00:41 +00:00
|
|
|
|
2012-09-10 17:07:21 +04:00
|
|
|
bool CameraWrapperConnector::isConnectedToLib = false;
|
2011-06-16 18:00:41 +00:00
|
|
|
InitCameraConnectC CameraWrapperConnector::pInitCameraC = 0;
|
|
|
|
CloseCameraConnectC CameraWrapperConnector::pCloseCameraC = 0;
|
|
|
|
GetCameraPropertyC CameraWrapperConnector::pGetPropertyC = 0;
|
|
|
|
SetCameraPropertyC CameraWrapperConnector::pSetPropertyC = 0;
|
|
|
|
ApplyCameraPropertiesC CameraWrapperConnector::pApplyPropertiesC = 0;
|
|
|
|
|
|
|
|
#define INIT_CAMERA_SYMBOL_NAME "initCameraConnectC"
|
|
|
|
#define CLOSE_CAMERA_SYMBOL_NAME "closeCameraConnectC"
|
|
|
|
#define SET_CAMERA_PROPERTY_SYMBOL_NAME "setCameraPropertyC"
|
|
|
|
#define GET_CAMERA_PROPERTY_SYMBOL_NAME "getCameraPropertyC"
|
|
|
|
#define APPLY_CAMERA_PROPERTIES_SYMBOL_NAME "applyCameraPropertiesC"
|
|
|
|
#define PREFIX_CAMERA_WRAPPER_LIB "libnative_camera"
|
|
|
|
|
|
|
|
|
|
|
|
bool nextFrame(void* buffer, size_t bufferSize, void* userData)
|
|
|
|
{
|
|
|
|
if (userData == NULL)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return ((CameraActivity*)userData)->onFrameBuffer(buffer, bufferSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::connect(int cameraId, CameraActivity* pCameraActivity, void** camera)
|
|
|
|
{
|
|
|
|
if (pCameraActivity == NULL)
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::connect error: wrong pointer to CameraActivity object");
|
|
|
|
return CameraActivity::ERROR_WRONG_POINTER_CAMERA_WRAPPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode errcode=connectToLib();
|
|
|
|
if (errcode) return errcode;
|
|
|
|
|
|
|
|
void* cmr = (*pInitCameraC)((void*)nextFrame, cameraId, (void*)pCameraActivity);
|
|
|
|
if (!cmr)
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::connectWrapper ERROR: the initializing function returned false");
|
|
|
|
return CameraActivity::ERROR_CANNOT_INITIALIZE_CONNECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
*camera = cmr;
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::disconnect(void** camera)
|
|
|
|
{
|
|
|
|
if (camera == NULL || *camera == NULL)
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::disconnect error: wrong pointer to camera object");
|
|
|
|
return CameraActivity::ERROR_WRONG_POINTER_CAMERA_WRAPPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode errcode=connectToLib();
|
|
|
|
if (errcode) return errcode;
|
|
|
|
|
|
|
|
(*pCloseCameraC)(camera);
|
|
|
|
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::setProperty(void* camera, int propIdx, double value)
|
|
|
|
{
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::setProperty error: wrong pointer to camera object");
|
|
|
|
return CameraActivity::ERROR_WRONG_POINTER_CAMERA_WRAPPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*pSetPropertyC)(camera, propIdx, value);
|
|
|
|
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::getProperty(void* camera, int propIdx, double* value)
|
|
|
|
{
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::getProperty error: wrong pointer to camera object");
|
|
|
|
return CameraActivity::ERROR_WRONG_POINTER_CAMERA_WRAPPER;
|
|
|
|
}
|
2011-07-25 12:32:33 +00:00
|
|
|
LOGE("calling (*pGetPropertyC)(%p, %d)", camera, propIdx);
|
2011-06-16 18:00:41 +00:00
|
|
|
*value = (*pGetPropertyC)(camera, propIdx);
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::applyProperties(void** ppcamera)
|
|
|
|
{
|
|
|
|
if ((ppcamera == NULL) || (*ppcamera == NULL))
|
|
|
|
{
|
|
|
|
LOGE("CameraWrapperConnector::applyProperties error: wrong pointer to camera object");
|
|
|
|
return CameraActivity::ERROR_WRONG_POINTER_CAMERA_WRAPPER;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*pApplyPropertiesC)(ppcamera);
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
|
|
|
|
{
|
|
|
|
if (isConnectedToLib) {
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
dlerror();
|
2013-03-22 18:59:43 +04:00
|
|
|
cv::String folderPath = getPathLibFolder();
|
2012-09-10 16:28:56 +04:00
|
|
|
if (folderPath.empty())
|
|
|
|
{
|
2012-09-10 19:44:59 +04:00
|
|
|
LOGD("Trying to find native camera in default OpenCV packages");
|
|
|
|
folderPath = getDefaultPathLibFolder();
|
2012-09-10 16:28:56 +04:00
|
|
|
}
|
|
|
|
|
2011-06-16 18:00:41 +00:00
|
|
|
LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str());
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
std::vector<cv::String> listLibs;
|
2011-06-16 18:00:41 +00:00
|
|
|
fillListWrapperLibs(folderPath, listLibs);
|
2013-04-02 20:59:43 +04:00
|
|
|
std::sort(listLibs.begin(), listLibs.end(), str_greater());
|
2011-06-16 18:00:41 +00:00
|
|
|
|
|
|
|
void * libHandle=0;
|
2013-03-22 18:59:43 +04:00
|
|
|
cv::String cur_path;
|
2012-01-18 14:33:39 +00:00
|
|
|
for(size_t i = 0; i < listLibs.size(); i++) {
|
2011-06-16 18:00:41 +00:00
|
|
|
cur_path=folderPath + listLibs[i];
|
|
|
|
LOGD("try to load library '%s'", listLibs[i].c_str());
|
|
|
|
libHandle=dlopen(cur_path.c_str(), RTLD_LAZY);
|
|
|
|
if (libHandle) {
|
|
|
|
LOGD("Loaded library '%s'", cur_path.c_str());
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
LOGD("CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library %s, dlerror=\"%s\"",
|
|
|
|
cur_path.c_str(), dlerror());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!libHandle) {
|
|
|
|
LOGE("CameraWrapperConnector::connectToLib ERROR: cannot dlopen camera wrapper library");
|
|
|
|
return CameraActivity::ERROR_CANNOT_OPEN_CAMERA_WRAPPER_LIB;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitCameraConnectC pInit_C;
|
|
|
|
CloseCameraConnectC pClose_C;
|
|
|
|
GetCameraPropertyC pGetProp_C;
|
|
|
|
SetCameraPropertyC pSetProp_C;
|
|
|
|
ApplyCameraPropertiesC pApplyProp_C;
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode res;
|
|
|
|
|
|
|
|
res = getSymbolFromLib(libHandle, (const char*)INIT_CAMERA_SYMBOL_NAME, (void**)(&pInit_C));
|
|
|
|
if (res) return res;
|
|
|
|
|
|
|
|
res = getSymbolFromLib(libHandle, CLOSE_CAMERA_SYMBOL_NAME, (void**)(&pClose_C));
|
|
|
|
if (res) return res;
|
|
|
|
|
|
|
|
res = getSymbolFromLib(libHandle, GET_CAMERA_PROPERTY_SYMBOL_NAME, (void**)(&pGetProp_C));
|
|
|
|
if (res) return res;
|
|
|
|
|
|
|
|
res = getSymbolFromLib(libHandle, SET_CAMERA_PROPERTY_SYMBOL_NAME, (void**)(&pSetProp_C));
|
|
|
|
if (res) return res;
|
2012-09-07 12:43:45 +04:00
|
|
|
|
2011-06-16 18:00:41 +00:00
|
|
|
res = getSymbolFromLib(libHandle, APPLY_CAMERA_PROPERTIES_SYMBOL_NAME, (void**)(&pApplyProp_C));
|
|
|
|
if (res) return res;
|
|
|
|
|
|
|
|
pInitCameraC = pInit_C;
|
|
|
|
pCloseCameraC = pClose_C;
|
|
|
|
pGetPropertyC = pGetProp_C;
|
|
|
|
pSetPropertyC = pSetProp_C;
|
|
|
|
pApplyPropertiesC = pApplyProp_C;
|
|
|
|
isConnectedToLib=true;
|
|
|
|
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraWrapperConnector::getSymbolFromLib(void* libHandle, const char* symbolName, void** ppSymbol)
|
|
|
|
{
|
|
|
|
dlerror();
|
|
|
|
*(void **) (ppSymbol)=dlsym(libHandle, symbolName);
|
|
|
|
|
|
|
|
const char* error_dlsym_init=dlerror();
|
|
|
|
if (error_dlsym_init) {
|
|
|
|
LOGE("CameraWrapperConnector::getSymbolFromLib ERROR: cannot get symbol of the function '%s' from the camera wrapper library, dlerror=\"%s\"",
|
|
|
|
symbolName, error_dlsym_init);
|
|
|
|
return CameraActivity::ERROR_CANNOT_GET_FUNCTION_FROM_CAMERA_WRAPPER_LIB;
|
|
|
|
}
|
|
|
|
return CameraActivity::NO_ERROR;
|
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
void CameraWrapperConnector::fillListWrapperLibs(const cv::String& folderPath, std::vector<cv::String>& listLibs)
|
2011-06-16 18:00:41 +00:00
|
|
|
{
|
|
|
|
DIR *dp;
|
|
|
|
struct dirent *ep;
|
|
|
|
|
|
|
|
dp = opendir (folderPath.c_str());
|
|
|
|
if (dp != NULL)
|
|
|
|
{
|
2011-07-02 15:12:07 +00:00
|
|
|
while ((ep = readdir (dp))) {
|
2011-06-16 18:00:41 +00:00
|
|
|
const char* cur_name=ep->d_name;
|
|
|
|
if (strstr(cur_name, PREFIX_CAMERA_WRAPPER_LIB)) {
|
|
|
|
listLibs.push_back(cur_name);
|
|
|
|
LOGE("||%s", cur_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void) closedir (dp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
cv::String CameraWrapperConnector::getDefaultPathLibFolder()
|
2012-09-10 16:28:56 +04:00
|
|
|
{
|
2013-11-15 19:41:53 +04:00
|
|
|
#define BIN_PACKAGE_NAME(x) "org.opencv.lib_v" CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR) "_" x
|
2012-11-22 12:40:25 +04:00
|
|
|
const char* const packageList[] = {BIN_PACKAGE_NAME("armv7a"), OPENCV_ENGINE_PACKAGE};
|
|
|
|
for (size_t i = 0; i < sizeof(packageList)/sizeof(packageList[0]); i++)
|
2012-09-10 16:28:56 +04:00
|
|
|
{
|
2012-09-10 19:44:59 +04:00
|
|
|
char path[128];
|
2012-11-22 12:40:25 +04:00
|
|
|
sprintf(path, "/data/data/%s/lib/", packageList[i]);
|
|
|
|
LOGD("Trying package \"%s\" (\"%s\")", packageList[i], path);
|
2012-09-10 19:44:59 +04:00
|
|
|
|
|
|
|
DIR* dir = opendir(path);
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
LOGD("Package not found");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
closedir(dir);
|
|
|
|
return path;
|
|
|
|
}
|
2012-09-10 16:28:56 +04:00
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
return cv::String();
|
2012-09-10 16:28:56 +04:00
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
cv::String CameraWrapperConnector::getPathLibFolder()
|
2011-06-16 18:00:41 +00:00
|
|
|
{
|
|
|
|
if (!pathLibFolder.empty())
|
|
|
|
return pathLibFolder;
|
|
|
|
|
|
|
|
Dl_info dl_info;
|
|
|
|
if(0 != dladdr((void *)nextFrame, &dl_info))
|
|
|
|
{
|
|
|
|
LOGD("Library name: %s", dl_info.dli_fname);
|
|
|
|
LOGD("Library base address: %p", dl_info.dli_fbase);
|
|
|
|
|
2012-12-21 19:58:51 +04:00
|
|
|
const char* libName=dl_info.dli_fname;
|
|
|
|
while( ((*libName)=='/') || ((*libName)=='.') )
|
2012-09-10 19:44:59 +04:00
|
|
|
libName++;
|
2011-07-14 18:41:09 +00:00
|
|
|
|
2011-06-16 18:00:41 +00:00
|
|
|
char lineBuf[2048];
|
|
|
|
FILE* file = fopen("/proc/self/smaps", "rt");
|
|
|
|
|
|
|
|
if(file)
|
|
|
|
{
|
2012-12-21 19:58:51 +04:00
|
|
|
while (fgets(lineBuf, sizeof lineBuf, file) != NULL)
|
|
|
|
{
|
|
|
|
//verify that line ends with library name
|
2012-09-10 16:28:56 +04:00
|
|
|
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))
|
|
|
|
{
|
2012-12-21 19:58:51 +04:00
|
|
|
//the line does not contain the library name
|
2012-09-10 16:28:56 +04:00
|
|
|
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;
|
2012-12-21 19:58:51 +04:00
|
|
|
}
|
|
|
|
fclose(file);
|
|
|
|
LOGE("Could not find library path");
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-21 19:58:51 +04:00
|
|
|
LOGE("Could not read /proc/self/smaps");
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-21 19:58:51 +04:00
|
|
|
LOGE("Could not get library name and base address");
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
return cv::String();
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
|
2013-03-22 18:59:43 +04:00
|
|
|
void CameraWrapperConnector::setPathLibFolder(const cv::String& path)
|
2011-06-16 18:00:41 +00:00
|
|
|
{
|
|
|
|
pathLibFolder=path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
CameraActivity::CameraActivity() : camera(0), frameWidth(-1), frameHeight(-1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::~CameraActivity()
|
|
|
|
{
|
|
|
|
if (camera != 0)
|
|
|
|
disconnect();
|
|
|
|
}
|
|
|
|
|
2012-06-20 12:27:02 +00:00
|
|
|
bool CameraActivity::onFrameBuffer(void* /*buffer*/, int /*bufferSize*/)
|
2011-06-16 18:00:41 +00:00
|
|
|
{
|
|
|
|
LOGD("CameraActivity::onFrameBuffer - empty callback");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CameraActivity::disconnect()
|
|
|
|
{
|
|
|
|
CameraWrapperConnector::disconnect(&camera);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CameraActivity::isConnected() const
|
|
|
|
{
|
|
|
|
return camera != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraActivity::ErrorCode CameraActivity::connect(int cameraId)
|
|
|
|
{
|
|
|
|
ErrorCode rescode = CameraWrapperConnector::connect(cameraId, this, &camera);
|
|
|
|
if (rescode) return rescode;
|
|
|
|
|
|
|
|
return NO_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
double CameraActivity::getProperty(int propIdx)
|
|
|
|
{
|
|
|
|
double propVal;
|
|
|
|
ErrorCode rescode = CameraWrapperConnector::getProperty(camera, propIdx, &propVal);
|
|
|
|
if (rescode) return -1;
|
|
|
|
return propVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CameraActivity::setProperty(int propIdx, double value)
|
|
|
|
{
|
|
|
|
CameraWrapperConnector::setProperty(camera, propIdx, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CameraActivity::applyProperties()
|
|
|
|
{
|
|
|
|
frameWidth = -1;
|
|
|
|
frameHeight = -1;
|
|
|
|
CameraWrapperConnector::applyProperties(&camera);
|
2012-09-10 17:07:21 +04:00
|
|
|
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
|
|
|
|
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CameraActivity::getFrameWidth()
|
|
|
|
{
|
2012-09-10 17:07:21 +04:00
|
|
|
if (frameWidth <= 0)
|
2013-08-04 20:19:33 +04:00
|
|
|
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
|
2012-09-10 17:07:21 +04:00
|
|
|
return frameWidth;
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CameraActivity::getFrameHeight()
|
|
|
|
{
|
2012-09-10 17:07:21 +04:00
|
|
|
if (frameHeight <= 0)
|
2013-08-04 20:19:33 +04:00
|
|
|
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
|
2012-09-10 17:07:21 +04:00
|
|
|
return frameHeight;
|
2011-06-16 18:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CameraActivity::setPathLibFolder(const char* path)
|
|
|
|
{
|
|
|
|
CameraWrapperConnector::setPathLibFolder(path);
|
|
|
|
}
|