2 * Copyright (C) <2017> Philippe Renon <philippe_renon@yahoo.fr>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include "cameraevent.hpp"
22 #include <opencv2/opencv.hpp>
25 * gst_camera_event_new_calibrated:
28 * Creates a new calibrated event.
30 * To parse an event created by gst_camera_event_new_calibrated() use
31 * gst_camera_event_parse_calibrated().
33 * Returns: The new GstEvent
36 gst_camera_event_new_calibrated (gchar * settings)
38 GstEvent *calibrated_event;
41 s = gst_structure_new (GST_CAMERA_EVENT_CALIBRATED_NAME,
42 "undistort-settings", G_TYPE_STRING, g_strdup (settings), NULL);
44 calibrated_event = gst_event_new_custom (GST_EVENT_CUSTOM_BOTH, s);
46 return calibrated_event;
50 * gst_camera_event_parse_calibrated:
51 * @event: A #GstEvent to parse
52 * @in_still: A boolean to receive the still-frame status from the event, or NULL
54 * Parse a #GstEvent, identify if it is a calibrated event, and
57 * Create a calibrated event using gst_camera_event_new_calibrated()
59 * Returns: %TRUE if the event is a valid calibrated event. %FALSE if not
62 gst_camera_event_parse_calibrated (GstEvent * event, gchar ** settings)
64 const GstStructure *s;
66 g_return_val_if_fail (event != NULL, FALSE);
68 if (GST_EVENT_TYPE (event) != GST_EVENT_CUSTOM_BOTH)
69 return FALSE; /* Not a calibrated event */
71 s = gst_event_get_structure (event);
73 || !gst_structure_has_name (s, GST_CAMERA_EVENT_CALIBRATED_NAME))
74 return FALSE; /* Not a calibrated event */
76 const gchar *str = gst_structure_get_string (s, "undistort-settings");
78 return FALSE; /* Not calibrated frame event */
80 *settings = g_strdup (str);