summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/FindClSerMe4.cmake44
-rw-r--r--cmake/FindFgLib5.cmake43
-rw-r--r--cmake/FindPCO.cmake19
-rw-r--r--cmake/SisoLibDir.cmake108
-rw-r--r--src/CMakeLists.txt49
-rw-r--r--src/cameras/uca_pco.c30
-rw-r--r--src/cameras/uca_pco.h8
-rw-r--r--src/config.h.in4
-rw-r--r--src/uca.c49
-rw-r--r--src/uca.h32
11 files changed, 390 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..37efe2e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8)
+project(uca)
+
+add_subdirectory(src)
diff --git a/cmake/FindClSerMe4.cmake b/cmake/FindClSerMe4.cmake
new file mode 100644
index 0000000..2251c9a
--- /dev/null
+++ b/cmake/FindClSerMe4.cmake
@@ -0,0 +1,44 @@
+FILE(TO_CMAKE_PATH "$ENV{SISODIR5}" SISODIR5)
+FILE(TO_CMAKE_PATH "$ENV{SISODIR4}" SISODIR4)
+FILE(TO_CMAKE_PATH "$ENV{SISODIR}" SISODIRME4)
+
+IF (CLSERME4_INCLUDE_DIR AND CLSERME4_LIBRARY)
+ SET(CLSERME4_FIND_QUIETLY TRUE)
+ENDIF (CLSERME4_INCLUDE_DIR AND CLSERME4_LIBRARY)
+
+FIND_PATH(CLSERME4_INCLUDE_DIR clser.h
+ PATHS
+ $ENV{CLSERME4}/include
+ ${SISODIR5}/include
+ ${SISODIR4}/include
+ ${SISODIRME4}/include
+ ${CMAKE_INSTALL_PREFIX}/include
+)
+
+INCLUDE(SisoLibDir)
+SISO_LIB_DIR("${SISODIR5}/lib" LIB_DIRS COMPILER_LIB_DIR)
+SISO_LIB_DIR("${SISODIR4}/lib" LIB_DIRS)
+SISO_LIB_DIR("${SISODIRME4}/lib" LIB_DIRS)
+
+FIND_LIBRARY(CLSERME4_LIBRARY NAMES clserme4 clsersisome4
+ PATHS
+ $ENV{CLSERME4}/lib
+ $ENV{CLSERME4}
+ ${LIB_DIRS}
+ ${CMAKE_INSTALL_PREFIX}/lib
+)
+
+IF(CLSERME4_INCLUDE_DIR AND CLSERME4_LIBRARY)
+ SET(CLSERME4_FOUND TRUE)
+ENDIF(CLSERME4_INCLUDE_DIR AND CLSERME4_LIBRARY)
+
+IF(CLSERME4_FOUND)
+ IF(NOT CLSERME4_FIND_QUIETLY)
+ MESSAGE(STATUS "Found clser library for meIV: ${CLSERME4_LIBRARY}")
+ ENDIF(NOT CLSERME4_FIND_QUIETLY)
+ SET(CLSERME4_LIBRARIES ${CLSERME4_LIBRARY})
+ELSE(CLSERME4_FOUND)
+ IF(CLSERME4_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "clser library not found")
+ ENDIF(CLSERME4_FIND_REQUIRED)
+ENDIF(CLSERME4_FOUND)
diff --git a/cmake/FindFgLib5.cmake b/cmake/FindFgLib5.cmake
new file mode 100644
index 0000000..cba0002
--- /dev/null
+++ b/cmake/FindFgLib5.cmake
@@ -0,0 +1,43 @@
+FILE(TO_CMAKE_PATH "$ENV{SISODIR5}" SISODIR5)
+
+IF (FGLIB5_INCLUDE_DIR AND FGLIB5_LIBRARY)
+ SET(FGLIB5_FIND_QUIETLY TRUE)
+ENDIF (FGLIB5_INCLUDE_DIR AND FGLIB5_LIBRARY)
+
+FIND_PATH(FGLIB5_INCLUDE_DIR fgrab_define.h
+ PATHS
+ "$ENV{FGLIB5}/include"
+ "${CMAKE_INSTALL_PREFIX}/include"
+ "${SISODIR5}/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Silicon Software GmbH\\Runtime5;Info]/include"
+)
+
+INCLUDE(SisoLibDir)
+SISO_LIB_DIR("${SISODIR5}/lib" LIB_DIRS COMPILER_LIB_DIR)
+
+FIND_LIBRARY(FGLIB5_LIBRARY NAMES fglib5
+ PATHS
+ "$ENV{FGLIB5}/lib"
+ "$ENV{FGLIB5}"
+ "${CMAKE_INSTALL_PREFIX}/lib"
+ ${LIB_DIRS}
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Silicon Software GmbH\\Runtime5;Info]/lib/${COMPILER_LIB_DIR}"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Silicon Software GmbH\\Runtime5;Info]/lib"
+)
+
+IF(FGLIB5_INCLUDE_DIR AND FGLIB5_LIBRARY)
+ SET(FGLIB5_FOUND TRUE)
+ENDIF(FGLIB5_INCLUDE_DIR AND FGLIB5_LIBRARY)
+
+IF(FGLIB5_FOUND)
+ IF(NOT FGLIB5_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Framegrabber library version 5: ${FGLIB5_LIBRARY}")
+ ENDIF(NOT FGLIB5_FIND_QUIETLY)
+ SET(FGLIB5_LIBRARIES ${FGLIB5_LIBRARY})
+ELSE(FGLIB5_FOUND)
+ IF(FGLIB5_FIND_REQUIRED)
+ IF(NOT FGLIB5_LIBRARY)
+ MESSAGE(FATAL_ERROR "Framegrabber library version 5 not found")
+ ENDIF(NOT FGLIB5_LIBRARY)
+ ENDIF(FGLIB5_FIND_REQUIRED)
+ENDIF(FGLIB5_FOUND)
diff --git a/cmake/FindPCO.cmake b/cmake/FindPCO.cmake
new file mode 100644
index 0000000..86bbe9a
--- /dev/null
+++ b/cmake/FindPCO.cmake
@@ -0,0 +1,19 @@
+# Try to find libpco.so
+#
+# Defines
+#
+# PCO_FOUND - system has libpco
+# PCO_INCLUDE_DIRS - libpco include directory
+# PCO_LIBRARIES - pco library
+
+find_package(PackageHandleStandardArgs)
+
+find_path(PCO_INCLUDE_DIRS libpco/libpco.h)
+find_library(PCO_LIBRARIES pco)
+
+find_package_handle_standard_args(PCO DEFAULT_MSG PCO_LIBRARIES PCO_INCLUDE_DIRS)
+
+mark_as_advanced(
+ PCO_INCLUDE_DIRS
+ PCO_LIBRARIES
+)
diff --git a/cmake/SisoLibDir.cmake b/cmake/SisoLibDir.cmake
new file mode 100644
index 0000000..371735e
--- /dev/null
+++ b/cmake/SisoLibDir.cmake
@@ -0,0 +1,108 @@
+# This makro sets up additional library directories depending on the compiler.
+# The reason behind this are the binary incompatible libraries generated by
+# different compilers on Windows (e.g. Microsoft Visual Studio vs. Borland).
+#
+# Although newer versions of MSVC can operate with older libraries there may
+# be libs compiled for a more recent version as MSVC6. Scan through all the
+# possible directories for the matching lib.
+#
+# This makro expects the /lib directory (usually $ENV{SISODIRsomething}) as
+# argument BASEDIR and will append a list of all valid library paths to
+# variable LIB_DIRS. This may or may not include BASE_DIR depending on the
+# platform. If BASEDIR is empty or is just "/lib" nothing will happen to
+# LIB_DIRS.
+#
+# An optional variable name may be passed as third argument. If that argument
+# is given the best matching suffix will be stored in that variable (e.g.
+# "visualc2008" if you are using MSVC9). This will even work if LIB_DIRS would
+# not be touched.
+
+MACRO (SISO_LIB_DIR BASE_DIR LIB_DIRS)
+ IF (WIN32)
+ IF (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
+ IF ("${BASE_DIR}" AND NOT "${BASE_DIR}" STREQUAL "/lib")
+ LIST(APPEND ${LIB_DIRS} "borland")
+ ENDIF ("${BASE_DIR}" AND NOT "${BASE_DIR}" STREQUAL "/lib")
+ IF (${ARGC} EQUAL 3)
+ set(${ARGV2} "borland")
+ ENDIF (${ARGC} EQUAL 3)
+ ELSE (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
+ # assume MSVC
+ SET(TMP_MSVC 0)
+ SET(TMP_MSVC_64 0)
+
+ IF (CMAKE_GENERATOR STREQUAL "Visual Studio 6")
+ SET(TMP_MSVC 6)
+ SET(TMP_MSVC_64 0)
+ ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005")
+ SET(TMP_MSVC 8)
+ SET(TMP_MSVC_64 0)
+ ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 8 2005 Win64")
+ SET(TMP_MSVC 8)
+ SET(TMP_MSVC_64 1)
+ ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
+ SET(TMP_MSVC 9)
+ SET(TMP_MSVC_64 0)
+ ELSEIF (CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008 Win64")
+ SET(TMP_MSVC 9)
+ SET(TMP_MSVC_64 1)
+ ELSEIF (CMAKE_GENERATOR STREQUAL "NMake Makefiles" OR CMAKE_GENERATOR STREQUAL "MinGW Makefiles")
+ SET(TMP_MSVC_64 ${CMAKE_CL_64})
+ IF (MSVC_VERSION EQUAL 1400)
+ SET(TMP_MSVC 8)
+ ELSEIF (MSVC_VERSION GREATER 1599)
+ SET(TMP_MSVC 10)
+ ELSEIF (MSVC_VERSION GREATER 1499)
+ SET(TMP_MSVC 9)
+ ELSEIF (CMAKE_COMPILER_2005)
+ SET(TMP_MSVC 8)
+ ELSE (MSVC_VERSION EQUAL 1400)
+ SET(TMP_MSVC 6)
+ ENDIF (MSVC_VERSION EQUAL 1400)
+ ENDIF (CMAKE_GENERATOR STREQUAL "Visual Studio 6")
+
+ SET(TMP_DIRS "")
+
+ IF (TMP_MSVC GREATER 9)
+ LIST(APPEND TMP_DIRS "visualc2010")
+ ENDIF (TMP_MSVC GREATER 9)
+ IF (TMP_MSVC GREATER 8)
+ LIST(APPEND TMP_DIRS "visualc2008")
+ ENDIF (TMP_MSVC GREATER 8)
+ IF (TMP_MSVC GREATER 7)
+ LIST(APPEND TMP_DIRS "visualc2005")
+ ENDIF (TMP_MSVC GREATER 7)
+ IF (TMP_MSVC GREATER 5 AND NOT TMP_MSVC_64)
+ LIST(APPEND TMP_DIRS "visualc")
+ ENDIF (TMP_MSVC GREATER 5 AND NOT TMP_MSVC_64)
+
+ IF (${ARGC} EQUAL 3)
+ LIST(GET TMP_DIRS 0 TMPSTR)
+ IF (TMP_MSVC_64)
+ SET(TMPSTR "${TMPSTR}_amd64")
+ ENDIF (TMP_MSVC_64)
+ set(${ARGV2} ${TMPSTR})
+ ENDIF (${ARGC} EQUAL 3)
+
+ IF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
+ FOREACH (TMP_ITEM ${TMP_DIRS})
+ IF (TMP_MSVC_64)
+ LIST(APPEND ${LIB_DIRS} "${BASE_DIR}/${TMP_ITEM}_amd64")
+ ELSE (TMP_MSVC_64)
+ LIST(APPEND ${LIB_DIRS} "${BASE_DIR}/${TMP_ITEM}")
+ ENDIF (TMP_MSVC_64)
+ ENDFOREACH (TMP_ITEM ${TMP_DIRS})
+ ENDIF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
+ ENDIF (CMAKE_GENERATOR STREQUAL "Borland Makefiles")
+ ELSE (WIN32)
+ IF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
+ LIST(APPEND ${LIB_DIRS} ${BASE_DIR})
+ ENDIF (NOT BASE_DIR STREQUAL "" AND NOT BASE_DIR STREQUAL "/lib")
+ IF (${ARGC} EQUAL 3)
+ set(${ARGV2} "")
+ ENDIF (${ARGC} EQUAL 3)
+ ENDIF (WIN32)
+ IF (${LIB_DIRS})
+ LIST(REMOVE_ITEM ${LIB_DIRS} "/lib")
+ ENDIF (${LIB_DIRS})
+ENDMACRO (SISO_LIB_DIR BASE_DIR LIB_DIRS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..0d6ce94
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,49 @@
+cmake_minimum_required(VERSION 2.8)
+
+# --- Set sources -------------------------------------------------------------
+set(uca_SRCS
+ uca.c
+ )
+
+set(uca_HDRS
+ uca.h
+ )
+
+set(uca_LIBS "")
+
+# --- Find packages and libraries ---------------------------------------------
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+
+find_package(PCO)
+find_package(ClSerMe4)
+
+# --- Add sources if camera access sources are available ----------------------
+if(PCO_FOUND AND CLSERME4_FOUND)
+ set(HAVE_PCO_EDGE TRUE)
+
+ set(uca_SRCS
+ ${uca_SRCS}
+ cameras/uca_pco.c
+ )
+
+ set(uca_LIBS
+ ${uca_LIBS}
+ ${CLSERME4_LIBRARY}
+ ${PCO_LIBRARIES}
+ )
+
+ include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CLSERME4_INCLUDE_DIR}
+ ${PCO_INCLUDE_DIRS}
+ )
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+
+# --- Build target ------------------------------------------------------------
+add_library(uca SHARED ${uca_SRCS})
+
+target_link_libraries(uca ${uca_LIBS})
diff --git a/src/cameras/uca_pco.c b/src/cameras/uca_pco.c
new file mode 100644
index 0000000..daba6f6
--- /dev/null
+++ b/src/cameras/uca_pco.c
@@ -0,0 +1,30 @@
+
+#include <clser.h>
+#include <libpco/libpco.h>
+#include "uca.h"
+#include "uca_pco.h"
+
+struct pco_edge_t *pco;
+
+static void uca_pco_destroy(struct uca_t *uca)
+{
+ pco_destroy(pco);
+}
+
+uint8_t uca_pco_init(struct uca_t *uca)
+{
+ pco = pco_init();
+ if (!pco_active(pco)) {
+ pco_destroy(pco);
+ return 0;
+ }
+
+ pco_scan_and_set_baud_rate(pco);
+
+ /* Camera found, set function pointers... */
+ uca->cam_destroy = &uca_pco_destroy;
+
+ /* ... and some properties */
+ pco_get_actual_size(pco, &uca->image_width, &uca->image_height);
+ return 1;
+}
diff --git a/src/cameras/uca_pco.h b/src/cameras/uca_pco.h
new file mode 100644
index 0000000..c314ffe
--- /dev/null
+++ b/src/cameras/uca_pco.h
@@ -0,0 +1,8 @@
+#ifndef __UNIFIED_CAMERA_ACCESS_PCO_H
+#define __UNIFIED_CAMERA_ACCESS_PCO_H
+
+struct uca_t;
+
+uint8_t uca_pco_init(struct uca_t *uca);
+
+#endif
diff --git a/src/config.h.in b/src/config.h.in
new file mode 100644
index 0000000..2a4abbb
--- /dev/null
+++ b/src/config.h.in
@@ -0,0 +1,4 @@
+
+#cmakedefine HAVE_PCO_EDGE
+#cmakedefine HAVE_PHOTON_FOCUS
+#cmakedefine HAVE_IPE_CAMERA
diff --git a/src/uca.c b/src/uca.c
new file mode 100644
index 0000000..7889fe2
--- /dev/null
+++ b/src/uca.c
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+
+#include "uca.h"
+
+#ifdef HAVE_PCO_EDGE
+#include "cameras/uca_pco.h"
+#endif
+
+#ifdef HAVE_PHOTON_FOCUS
+#include "cameras/uca_pf.h"
+#endif
+
+#ifdef HAVE_IPE_CAM
+#include "cameras/uca_ipe.h"
+#endif
+
+
+struct uca_t *uca_init()
+{
+ struct uca_t *uca = (struct uca_t *) malloc(sizeof(struct uca_t));
+
+ uca_cam_init inits[] = {
+#ifdef HAVE_PCO_EDGE
+ uca_pco_init,
+#elif HAVE_PHOTON_FOCUS
+ uca_pf_init,
+#elif HAVE_IPE_CAM
+ uca_ipe_init,
+#endif
+ NULL };
+
+ int i = 0;
+ while (inits[i] != NULL) {
+ uca_cam_init init = inits[i];
+ if (init(uca))
+ return uca;
+ i++;
+ }
+
+ /* No camera found then return nothing */
+ free(uca);
+ return NULL;
+}
+
+void uca_destroy(struct uca_t *uca)
+{
+ uca->cam_destroy(uca);
+ free(uca);
+}
diff --git a/src/uca.h b/src/uca.h
new file mode 100644
index 0000000..2f93093
--- /dev/null
+++ b/src/uca.h
@@ -0,0 +1,32 @@
+#ifndef __UNIFIED_CAMERA_ACCESS_H
+#define __UNIFIED_CAMERA_ACCESS_H
+
+struct uca_t;
+
+/*
+ * \brief Camera probing and initialization
+ * \return 0 if camera is not found or could not be initialized
+ */
+typedef int (*uca_cam_init) (struct uca_t *uca);
+
+typedef void (*uca_cam_destroy) (struct uca_t *uca);
+
+#define UCA_BIG_ENDIAN 1
+#define UCA_LITTLE_ENDIAN 2
+
+struct uca_t {
+ /* These must be written by uca_cam_init() */
+ unsigned int image_width;
+ unsigned int image_height;
+ unsigned int image_bitdepth;
+ unsigned int image_flags;
+
+ /* Function pointers to camera-specific methods */
+ uca_cam_destroy cam_destroy;
+};
+
+struct uca_t *uca_init();
+void uca_destroy(struct uca_t *uca);
+
+
+#endif