~michael-sheldon/gst-opencv/trunk

« back to all changes in this revision

Viewing changes to src/gstopencvbasetrans.c

  • Committer: Thiago Santos
  • Date: 2010-06-02 02:13:51 UTC
  • Revision ID: git-v1:b1572d22875dbc1828df9e9a327fd39cce5518b7
Adding gstopencvutils

Adds a file to keep utilitary functions together

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include <gst/gst.h>
51
51
 
52
52
#include "gstopencvbasetrans.h"
 
53
#include "gstopencvutils.h"
53
54
 
54
55
GST_DEBUG_CATEGORY_STATIC (gst_opencv_base_transform_debug);
55
56
#define GST_CAT_DEFAULT gst_opencv_base_transform_debug
210
211
    GstCaps * outcaps)
211
212
{
212
213
  GstOpencvBaseTransform *transform = GST_OPENCV_BASE_TRANSFORM (trans);
213
 
  GstStructure *structure;
214
 
  gint width, height;
215
 
 
216
 
  structure = gst_caps_get_structure (incaps, 0);
217
 
  if (!gst_structure_get_int (structure, "width", &width) ||
218
 
      !gst_structure_get_int (structure, "height", &height)) {
219
 
    GST_WARNING_OBJECT (transform, "No width/height on caps");
 
214
  gint in_width, in_height;
 
215
  gint in_depth, in_type, in_channels;
 
216
  gint out_width, out_height;
 
217
  gint out_depth, out_type, out_channels;
 
218
  GError *in_err = NULL;
 
219
  GError *out_err = NULL;
 
220
 
 
221
  if (!gst_opencv_parse_iplimage_params_from_caps (incaps, &in_width,
 
222
      &in_height, &in_depth, &in_type, &in_channels, &in_err)) {
 
223
    GST_WARNING_OBJECT (transform, "Failed to parse input caps: %s",
 
224
        in_err->message);
 
225
    g_error_free (in_err);
 
226
    return FALSE;
 
227
  }
 
228
 
 
229
  if (!gst_opencv_parse_iplimage_params_from_caps (outcaps, &out_width,
 
230
      &out_height, &out_depth, &out_type, &out_channels, &out_err)) {
 
231
    GST_WARNING_OBJECT (transform, "Failed to parse output caps: %s",
 
232
        out_err->message);
 
233
    g_error_free (out_err);
220
234
    return FALSE;
221
235
  }
222
236
 
227
241
    cvReleaseImage (&transform->out_cvImage);
228
242
  }
229
243
 
230
 
  /* FIXME - how do we know it is IPL_DEPTH_8U? */
231
244
  transform->cvImage =
232
 
      cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, 3);
 
245
      cvCreateImageHeader (cvSize (in_width, in_height), in_depth, in_channels);
233
246
  transform->out_cvImage =
234
 
      cvCreateImageHeader (cvSize (width, height), IPL_DEPTH_8U, 3);
 
247
      cvCreateImageHeader (cvSize (out_width, out_height), out_depth,
 
248
          out_channels);
235
249
 
236
250
  gst_base_transform_set_in_place (GST_BASE_TRANSFORM (transform),
237
251
      transform->in_place);