summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-21 15:06:42 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@ipe.fzk.de>2011-02-21 15:06:42 +0100
commit28619821bc90ed4c15844b2e6b6a5a2971ef5f2e (patch)
treec313b5b77087c18027d152c4c69c49b8ea0254d9 /src
downloaduca-28619821bc90ed4c15844b2e6b6a5a2971ef5f2e.tar.gz
uca-28619821bc90ed4c15844b2e6b6a5a2971ef5f2e.tar.bz2
uca-28619821bc90ed4c15844b2e6b6a5a2971ef5f2e.tar.xz
uca-28619821bc90ed4c15844b2e6b6a5a2971ef5f2e.zip
Initial commit
Diffstat (limited to 'src')
-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
6 files changed, 172 insertions, 0 deletions
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