[aravis] viewer: add a snapshot button.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] viewer: add a snapshot button.
- Date: Tue, 11 Oct 2011 12:19:32 +0000 (UTC)
commit f5a34fe3f14c9f699a16b4af1ea41f8485bc8fcb
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Tue Oct 11 14:16:37 2011 +0200
viewer: add a snapshot button.
Image are saved as raw data in ~/Pictures/Aravis directory.
ImageJ is a nice tool for viewing or processing of the raw data.
NEWS | 6 ++++
viewer/arv-viewer.ui | 45 +++++++++++++++++++++++++++---
viewer/arvviewer.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 116 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 8c30cbf..61c91f4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Release 0.1.11
+==============
+
+ * viewer: add a snapshot button.
+ * documentation: more GigE Vision protocol.
+
Release 0.1.10
==============
diff --git a/viewer/arv-viewer.ui b/viewer/arv-viewer.ui
index a409be2..cb226c3 100644
--- a/viewer/arv-viewer.ui
+++ b/viewer/arv-viewer.ui
@@ -3,25 +3,30 @@
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="main_window">
+ <property name="can_focus">False</property>
<property name="title" translatable="yes">Aravis</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="spacing">6</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <object class="GtkButton" id="play_button">
- <property name="sensitive">False</property>
+ <object class="GtkButton" id="snapshot_button">
+ <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
<child>
- <object class="GtkImage" id="play_image">
+ <object class="GtkImage" id="image1">
<property name="visible">True</property>
- <property name="stock">gtk-media-play</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">camera-photo</property>
</object>
</child>
</object>
@@ -34,8 +39,11 @@
<child>
<object class="GtkComboBox" id="camera_combobox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@@ -51,8 +59,11 @@
<property name="width_request">320</property>
<property name="height_request">240</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
@@ -63,6 +74,7 @@
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">5</property>
<property name="column_spacing">6</property>
@@ -70,6 +82,7 @@
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Frame rate:</property>
</object>
@@ -82,6 +95,7 @@
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Exposure:</property>
</object>
@@ -96,6 +110,7 @@
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Gain:</property>
</object>
@@ -113,6 +128,10 @@
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
<property name="width_chars">10</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">2</property>
@@ -123,6 +142,7 @@
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Hz</property>
</object>
@@ -135,6 +155,7 @@
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Âs</property>
</object>
@@ -149,6 +170,7 @@
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -189,6 +211,10 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">2</property>
@@ -203,6 +229,10 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">2</property>
@@ -213,7 +243,9 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="trigger_combobox"/>
+ <object class="GtkComboBox" id="trigger_combobox">
+ <property name="can_focus">False</property>
+ </object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
@@ -224,6 +256,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
</object>
<packing>
<property name="top_attach">1</property>
@@ -237,6 +270,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
</object>
<packing>
<property name="top_attach">2</property>
@@ -252,6 +286,7 @@
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="label" translatable="yes">Settings</property>
</object>
</child>
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index 458a0b7..a68121a 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -26,6 +26,7 @@
#include <gst/interfaces/xoverlay.h>
#include <gdk/gdkx.h>
#include <arv.h>
+#include <arvenumtypes.h>
#include <stdlib.h>
#include <math.h>
@@ -39,6 +40,7 @@ typedef struct {
ArvCamera *camera;
ArvDevice *device;
ArvStream *stream;
+ ArvBuffer *last_buffer;
GstElement *pipeline;
GstElement *appsrc;
@@ -47,7 +49,7 @@ typedef struct {
guint64 last_timestamp;
GtkWidget *main_window;
- GtkWidget *play_button;
+ GtkWidget *snapshot_button;
GtkWidget *drawing_area;
GtkWidget *camera_combo_box;
GtkWidget *trigger_combo_box;
@@ -148,7 +150,9 @@ arv_viewer_new_buffer_cb (ArvStream *stream, ArvViewer *viewer)
gst_app_src_push_buffer (GST_APP_SRC (viewer->appsrc), buffer);
}
- arv_stream_push_buffer (stream, arv_buffer);
+ if (viewer->last_buffer != NULL)
+ arv_stream_push_buffer (stream, viewer->last_buffer);
+ viewer->last_buffer = arv_buffer;
}
void
@@ -329,10 +333,72 @@ arv_viewer_release_camera (ArvViewer *viewer)
viewer->appsrc = NULL;
}
+ if (viewer->last_buffer != NULL) {
+ g_object_unref (viewer->last_buffer);
+ viewer->last_buffer = NULL;
+ }
+
viewer->timestamp_offset = 0;
viewer->last_timestamp = 0;
}
+static const char *
+arv_enum_to_string (GType type,
+ guint enum_value)
+{
+ GEnumClass *enum_class;
+ GEnumValue *value;
+ const char *retval = NULL;
+
+ enum_class = g_type_class_ref (type);
+
+ value = g_enum_get_value (enum_class, enum_value);
+ if (value)
+ retval = value->value_nick;
+
+ g_type_class_unref (enum_class);
+
+ return retval;
+}
+
+void
+arv_viewer_snapshot_cb (GtkButton *button, ArvViewer *viewer)
+{
+ GFile *file;
+ char *path;
+ char *filename;
+ GDateTime *date;
+ char *date_string;
+
+ g_return_if_fail (ARV_IS_CAMERA (viewer->camera));
+ g_return_if_fail (ARV_IS_BUFFER (viewer->last_buffer));
+
+ path = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES),
+ "Aravis", NULL);
+ file = g_file_new_for_path (path);
+ g_free (path);
+ g_file_make_directory (file, NULL, NULL);
+ g_object_unref (file);
+
+ date = g_date_time_new_now_local ();
+ date_string = g_date_time_format (date, "%Y-%m-%d-%H:%M:%S");
+ filename = g_strdup_printf ("%s-%s-%d-%d-%s-%s.raw",
+ arv_camera_get_vendor_name (viewer->camera),
+ arv_camera_get_device_id (viewer->camera),
+ viewer->last_buffer->width,
+ viewer->last_buffer->height,
+ arv_enum_to_string (ARV_TYPE_PIXEL_FORMAT,
+ viewer->last_buffer->pixel_format),
+ date_string);
+ path = g_build_filename (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES),
+ "Aravis", filename, NULL);
+ g_file_set_contents (path, viewer->last_buffer->data, viewer->last_buffer->size, NULL);
+ g_free (path);
+ g_free (filename);
+ g_free (date_string);
+ g_date_time_unref (date);
+}
+
void
arv_viewer_select_camera_cb (GtkComboBox *combo_box, ArvViewer *viewer)
{
@@ -515,7 +581,7 @@ arv_viewer_new (void)
g_free (ui_filename);
viewer->camera_combo_box = GTK_WIDGET (gtk_builder_get_object (builder, "camera_combobox"));
- viewer->play_button = GTK_WIDGET (gtk_builder_get_object (builder, "play_button"));
+ viewer->snapshot_button = GTK_WIDGET (gtk_builder_get_object (builder, "snapshot_button"));
viewer->main_window = GTK_WIDGET (gtk_builder_get_object (builder, "main_window"));
viewer->drawing_area = GTK_WIDGET (gtk_builder_get_object (builder, "video_drawingarea"));
viewer->trigger_combo_box = GTK_WIDGET (gtk_builder_get_object (builder, "trigger_combobox"));
@@ -533,12 +599,12 @@ arv_viewer_new (void)
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (viewer->camera_combo_box), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (viewer->camera_combo_box), cell, "text", 0, NULL);
- gtk_widget_set_no_show_all (viewer->play_button, TRUE);
gtk_widget_set_no_show_all (viewer->trigger_combo_box, TRUE);
gtk_widget_show_all (viewer->main_window);
g_signal_connect (viewer->main_window, "destroy", G_CALLBACK (arv_viewer_quit_cb), viewer);
+ g_signal_connect (viewer->snapshot_button, "clicked", G_CALLBACK (arv_viewer_snapshot_cb), viewer);
g_signal_connect (viewer->camera_combo_box, "changed", G_CALLBACK (arv_viewer_select_camera_cb), viewer);
g_signal_connect (viewer->frame_rate_entry, "changed", G_CALLBACK (arv_viewer_frame_rate_entry_cb), viewer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]