summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--gui/CMakeLists.txt (renamed from tools/gui/CMakeLists.txt)16
-rw-r--r--gui/config.h.in1
-rw-r--r--gui/control.c (renamed from tools/gui/control.c)0
-rw-r--r--gui/control.glade (renamed from tools/gui/control.glade)0
-rw-r--r--gui/egg-histogram-view.c (renamed from tools/gui/egg-histogram-view.c)0
-rw-r--r--gui/egg-histogram-view.h (renamed from tools/gui/egg-histogram-view.h)0
-rw-r--r--gui/egg-property-cell-renderer.c (renamed from tools/gui/egg-property-cell-renderer.c)0
-rw-r--r--gui/egg-property-cell-renderer.h (renamed from tools/gui/egg-property-cell-renderer.h)0
-rw-r--r--gui/egg-property-tree-view.c (renamed from tools/gui/egg-property-tree-view.c)0
-rw-r--r--gui/egg-property-tree-view.h (renamed from tools/gui/egg-property-tree-view.h)0
-rw-r--r--plugins/CMakeLists.txt3
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--tools/CMakeLists.txt15
-rw-r--r--tools/config.h.in1
-rw-r--r--tools/grab.c78
17 files changed, 111 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39c421e..e8aae64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,8 +58,8 @@ pkg_check_modules(GMODULE2 gmodule-2.0>=2.24 REQUIRED)
pkg_check_modules(GIO2 gio-2.0>=2.24 REQUIRED)
include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}/src
- ${CMAKE_CURRENT_SOURCE_DIR}/src
+ # ${CMAKE_CURRENT_BINARY_DIR}/src
+ #${CMAKE_CURRENT_SOURCE_DIR}/src
${GLIB2_INCLUDE_DIRS}
${GOBJECT2_INCLUDE_DIRS}
${GMODULE2_INCLUDE_DIRS}
@@ -75,6 +75,7 @@ add_subdirectory(src)
add_subdirectory(plugins)
add_subdirectory(test)
add_subdirectory(tools)
+add_subdirectory(gui)
include(CPack)
diff --git a/tools/gui/CMakeLists.txt b/gui/CMakeLists.txt
index 07f597b..f0d90c3 100644
--- a/tools/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -10,23 +10,29 @@ pkg_check_modules(GTHREAD2 gthread-2.0)
pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED)
pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade ${CMAKE_CURRENT_BINARY_DIR})
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade
+ ${CMAKE_CURRENT_BINARY_DIR})
# --- Build targets -----------------------------------------------------------
include_directories(
${GLIB2_INCLUDE_DIRS}
${GOBJECT2_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}/../../src/
- ${CMAKE_CURRENT_SOURCE_DIR}/../../src
- ${CMAKE_CURRENT_SOURCE_DIR}/../
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
+ ${CMAKE_CURRENT_SOURCE_DIR}/../tools
)
+message("include: ${CMAKE_CURRENT_BINARY_DIR}")
+
if (GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
add_executable(control
control.c
- ../ring-buffer.c # yes this sucks and should be fixed
+ ../tools/ring-buffer.c # yes this sucks and should be fixed
egg-property-cell-renderer.c
egg-property-tree-view.c
egg-histogram-view.c)
diff --git a/gui/config.h.in b/gui/config.h.in
new file mode 100644
index 0000000..e7de9c6
--- /dev/null
+++ b/gui/config.h.in
@@ -0,0 +1 @@
+#define CONTROL_GLADE_PATH "${CMAKE_INSTALL_PREFIX}/share/libuca/control.glade"
diff --git a/tools/gui/control.c b/gui/control.c
index c177f07..c177f07 100644
--- a/tools/gui/control.c
+++ b/gui/control.c
diff --git a/tools/gui/control.glade b/gui/control.glade
index eec9dde..eec9dde 100644
--- a/tools/gui/control.glade
+++ b/gui/control.glade
diff --git a/tools/gui/egg-histogram-view.c b/gui/egg-histogram-view.c
index 812af7a..812af7a 100644
--- a/tools/gui/egg-histogram-view.c
+++ b/gui/egg-histogram-view.c
diff --git a/tools/gui/egg-histogram-view.h b/gui/egg-histogram-view.h
index 7a62fca..7a62fca 100644
--- a/tools/gui/egg-histogram-view.h
+++ b/gui/egg-histogram-view.h
diff --git a/tools/gui/egg-property-cell-renderer.c b/gui/egg-property-cell-renderer.c
index 9df5cc3..9df5cc3 100644
--- a/tools/gui/egg-property-cell-renderer.c
+++ b/gui/egg-property-cell-renderer.c
diff --git a/tools/gui/egg-property-cell-renderer.h b/gui/egg-property-cell-renderer.h
index d4dbe02..d4dbe02 100644
--- a/tools/gui/egg-property-cell-renderer.h
+++ b/gui/egg-property-cell-renderer.h
diff --git a/tools/gui/egg-property-tree-view.c b/gui/egg-property-tree-view.c
index 52d1e10..52d1e10 100644
--- a/tools/gui/egg-property-tree-view.c
+++ b/gui/egg-property-tree-view.c
diff --git a/tools/gui/egg-property-tree-view.h b/gui/egg-property-tree-view.h
index e8fd0fe..e8fd0fe 100644
--- a/tools/gui/egg-property-tree-view.h
+++ b/gui/egg-property-tree-view.h
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 1cfff78..e02359c 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -1,3 +1,6 @@
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
+
add_subdirectory(mock)
add_subdirectory(pf)
add_subdirectory(pco)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c3a037f..443025d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -59,6 +59,9 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libuca.pc.in"
# --- Build target ------------------------------------------------------------
+include_directories(${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR})
+
add_library(uca SHARED
${uca_SRCS}
${CMAKE_CURRENT_BINARY_DIR}/uca-enums.c)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f98def0..7b98cc4 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 2.8)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
+
add_executable(test-mock test-mock.c)
target_link_libraries(test-mock uca ${UCA_DEPS})
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 66cbd6b..a57fbac 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -4,6 +4,7 @@ add_definitions("--std=c99 -Wall")
# --- Find packages and libraries ---------------------------------------------
find_package(PkgConfig)
+find_package(TIFF)
pkg_check_modules(GLIB2 glib-2.0>=2.24 REQUIRED)
pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED)
@@ -12,12 +13,22 @@ pkg_check_modules(GOBJECT2 gobject-2.0>=2.24 REQUIRED)
include_directories(
${GLIB2_INCLUDE_DIRS}
${GOBJECT2_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}/../src/
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../src
)
set(libs uca ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
+if (TIFF_FOUND)
+ set(HAVE_LIBTIFF "1")
+ list(APPEND libs ${TIFF_LIBRARIES})
+ include_directories(${TIFF_INCLUDE_DIRS})
+endif ()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
add_executable(gen-doc gen-doc.c)
target_link_libraries(gen-doc ${libs})
@@ -32,5 +43,3 @@ target_link_libraries(benchmark ${libs})
add_executable(perf perf-overhead.c)
target_link_libraries(perf ${libs})
-
-add_subdirectory(gui)
diff --git a/tools/config.h.in b/tools/config.h.in
new file mode 100644
index 0000000..aea5237
--- /dev/null
+++ b/tools/config.h.in
@@ -0,0 +1 @@
+#cmakedefine HAVE_LIBTIFF
diff --git a/tools/grab.c b/tools/grab.c
index 325c02f..99fa6ee 100644
--- a/tools/grab.c
+++ b/tools/grab.c
@@ -15,6 +15,8 @@
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin St, Fifth Floor, Boston, MA 02110, USA */
+#include "config.h"
+
#include <glib-object.h>
#include <signal.h>
#include <stdio.h>
@@ -23,6 +25,10 @@
#include "uca-camera.h"
#include "ring-buffer.h"
+#ifdef HAVE_LIBTIFF
+#include <tiffio.h>
+#endif
+
typedef struct {
gint n_frames;
@@ -59,8 +65,63 @@ get_camera_list (void)
return g_string_free (str, FALSE);
}
+static guint
+get_bytes_per_pixel (guint bits_per_pixel)
+{
+ return bits_per_pixel == 8 ? 1 : 2;
+}
+
+#ifdef HAVE_LIBTIFF
+static void
+write_tiff (RingBuffer *buffer,
+ guint width,
+ guint height,
+ guint bits_per_pixel)
+{
+ TIFF *tif;
+ guint32 rows_per_strip;
+ gpointer data;
+ guint n_frames;
+ gsize bytes_per_pixel;
+
+ tif = TIFFOpen ("frames.tif", "w");
+ n_frames = ring_buffer_get_num_blocks (buffer);
+ rows_per_strip = TIFFDefaultStripSize (tif, (guint32) - 1);
+ bytes_per_pixel = get_bytes_per_pixel (bits_per_pixel);
+
+ /* Write multi page TIFF file */
+ TIFFSetField (tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE);
+
+ for (guint i = 0; i < n_frames; i++) {
+ gpointer data;
+ gsize offset = 0;
+
+ data = ring_buffer_get_pointer (buffer, i);
+
+ TIFFSetField (tif, TIFFTAG_IMAGEWIDTH, width);
+ TIFFSetField (tif, TIFFTAG_IMAGELENGTH, height);
+ TIFFSetField (tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel);
+ TIFFSetField (tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);
+ TIFFSetField (tif, TIFFTAG_SAMPLESPERPIXEL, 1);
+ TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+ TIFFSetField (tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip);
+ TIFFSetField (tif, TIFFTAG_PAGENUMBER, i, n_frames);
+ /* start = ((gfloat *) data) + i * width * height; */
+
+ /* for (guint y = 0; y < height; y++, start += width) */
+ /* TIFFWriteScanline (tif, start, y, 0); */
+
+ for (guint y = 0; y < height; y++, offset += width * bytes_per_pixel)
+ TIFFWriteScanline (tif, data + offset, y, 0);
+
+ TIFFWriteDirectory (tif);
+ }
+
+ TIFFClose (tif);
+}
+#else
static void
-store_frames (RingBuffer *buffer)
+write_raw (RingBuffer *buffer)
{
guint n_frames;
gsize size;
@@ -82,6 +143,7 @@ store_frames (RingBuffer *buffer)
g_free (filename);
}
}
+#endif
static GError *
record_frames (UcaCamera *camera, Options *opts)
@@ -103,7 +165,7 @@ record_frames (UcaCamera *camera, Options *opts)
"sensor-bitdepth", &bits,
NULL);
- pixel_size = bits == 8 ? 1 : 2;
+ pixel_size = get_bytes_per_pixel (bits);
size = roi_width * roi_height * pixel_size;
n_allocated = opts->n_frames > 0 ? opts->n_frames : 256;
buffer = ring_buffer_new (size, n_allocated);
@@ -130,11 +192,19 @@ record_frames (UcaCamera *camera, Options *opts)
n_frames++;
}
- g_print ("Stop recording: %3.5f frames/s\n",
+ g_print ("Stop recording: %3.2f frames/s\n",
n_frames / g_timer_elapsed (timer, NULL));
uca_camera_stop_recording (camera, &error);
- store_frames (buffer);
+
+#ifdef HAVE_LIBTIFF
+ write_tiff (buffer, roi_width, roi_height, bits);
+ g_print ("writing tiff\n");
+#else
+ write_raw (buffer);
+ g_print ("writing raw\n");
+#endif
+
ring_buffer_free (buffer);
g_timer_destroy (timer);