[236/906] import sobel edge detector from cvs branch

This commit is contained in:
Filippo Argiolas 2008-09-23 10:37:58 +02:00 committed by Matthew Waters
parent 8a2d3e3874
commit a80fecd888
6 changed files with 424 additions and 127 deletions

View file

@ -23,6 +23,7 @@ add_library (gstopengl SHARED
gstglupload.c
gstgldownload.c
gstglfilterblur.c
gstglfiltersobel.c
gstglfiltercube.c
gstglfilterlaplacian.c
gstglfilterglass.c

View file

@ -13,6 +13,7 @@ libgstopengl_la_SOURCES = \
gstgldownload.c \
gstgldownload.h \
gstglfilterblur.c \
gstglfiltersobel.c \
gstglfiltercube.c \
gstglfiltercube.h \
gstglfilterlaplacian.c \

View file

@ -187,164 +187,188 @@ const gchar *luma_threshold_fragment_source =
" gl_FragColor = vec4 (vec3 (smoothstep (0.30, 0.50, luma)), color.a);"
"}";
const gchar *sobel_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform float hkern[9];"
"uniform float vkern[9];"
"void main () {"
" vec2 offset[9] = vec2[9] ( vec2(-1.0,-1.0), vec2( 0.0,-1.0), vec2( 1.0,-1.0),"
" vec2(-1.0, 0.0), vec2( 0.0, 0.0), vec2( 1.0, 0.0),"
" vec2(-1.0, 1.0), vec2( 0.0, 1.0), vec2( 1.0, 1.0) );"
" vec2 texturecoord = gl_TexCoord[0].st;"
" int i;"
" float luma;"
" float gx = 0.0;"
" float gy = 0.0 ;"
" for (i = 0; i < 9; i++) { "
" if(hkern[i] != 0.0 || vkern[i] != 0.0) {"
" vec4 neighbor = texture2DRect(tex, texturecoord + vec2(offset[i])); "
" luma = dot(neighbor, vec4(0.2125, 0.7154, 0.0721, neighbor.a));"
" gx += luma * hkern[i]; "
" gy += luma * vkern[i]; "
" }"
" }"
" float g = sqrt(gx*gx + gy*gy);"
" gl_FragColor = vec4(vec3(g), 1.0);"
"}";
/* horizontal convolution */
const gchar *hconv9_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform float norm_const;"
"uniform float norm_offset;"
"uniform float kernel[9];"
"void main () {"
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform float norm_const;"
"uniform float norm_offset;"
"uniform float kernel[9];"
"void main () {"
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
/* don't use array constructor so we don't have to depend on #version 120 */
" float offset[9];"
" offset[0] = -4.0;"
" offset[1] = -3.0;"
" offset[2] = -2.0;"
" offset[3] = -1.0;"
" offset[4] = 0.0;"
" offset[5] = 1.0;"
" offset[6] = 2.0;"
" offset[7] = 3.0;"
" offset[8] = 4.0;"
" vec2 texturecoord = gl_TexCoord[0].st;"
" int i;"
" vec4 sum = vec4 (0.0);"
" for (i = 0; i < 9; i++) { "
" if (kernel[i] != 0.0) {"
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); "
" sum += neighbor * kernel[i]/norm_const; "
" }"
" }"
" gl_FragColor = sum + norm_offset;"
"}";
" float offset[9];"
" offset[0] = -4.0;"
" offset[1] = -3.0;"
" offset[2] = -2.0;"
" offset[3] = -1.0;"
" offset[4] = 0.0;"
" offset[5] = 1.0;"
" offset[6] = 2.0;"
" offset[7] = 3.0;"
" offset[8] = 4.0;"
" vec2 texturecoord = gl_TexCoord[0].st;"
" int i;"
" vec4 sum = vec4 (0.0);"
" for (i = 0; i < 9; i++) { "
" if (kernel[i] != 0.0) {"
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); "
" sum += neighbor * kernel[i]/norm_const; "
" }"
" }"
" gl_FragColor = sum + norm_offset;"
"}";
/* vertical convolution */
const gchar *vconv9_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform float norm_const;"
"uniform float norm_offset;"
"uniform float kernel[9];"
"void main () {"
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform float norm_const;"
"uniform float norm_offset;"
"uniform float kernel[9];"
"void main () {"
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
/* don't use array constructor so we don't have to depend on #version 120 */
" float offset[9];"
" offset[0] = -4.0;"
" offset[1] = -3.0;"
" offset[2] = -2.0;"
" offset[3] = -1.0;"
" offset[4] = 0.0;"
" offset[5] = 1.0;"
" offset[6] = 2.0;"
" offset[7] = 3.0;"
" offset[8] = 4.0;"
" vec2 texturecoord = gl_TexCoord[0].st;"
" int i;"
" vec4 sum = vec4 (0.0);"
" for (i = 0; i < 9; i++) { "
" if (kernel[i] != 0.0) {"
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); "
" sum += neighbor * kernel[i]/norm_const; "
" }"
" }"
" gl_FragColor = sum + norm_offset;"
"}";
" float offset[9];"
" offset[0] = -4.0;"
" offset[1] = -3.0;"
" offset[2] = -2.0;"
" offset[3] = -1.0;"
" offset[4] = 0.0;"
" offset[5] = 1.0;"
" offset[6] = 2.0;"
" offset[7] = 3.0;"
" offset[8] = 4.0;"
" vec2 texturecoord = gl_TexCoord[0].st;"
" int i;"
" vec4 sum = vec4 (0.0);"
" for (i = 0; i < 9; i++) { "
" if (kernel[i] != 0.0) {"
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); "
" sum += neighbor * kernel[i]/norm_const; "
" }"
" }"
" gl_FragColor = sum + norm_offset;"
"}";
/* TODO: support several blend modes */
const gchar *sum_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect base;"
"uniform sampler2DRect blend;"
"uniform float alpha;"
"uniform float beta;"
"void main () {"
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
" gl_FragColor = alpha * basecolor + beta * blendcolor;"
"}";
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect base;"
"uniform sampler2DRect blend;"
"uniform float alpha;"
"uniform float beta;"
"void main () {"
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
" gl_FragColor = alpha * basecolor + beta * blendcolor;"
"}";
/* lut operations, map luma to tex1d, see orange book (chapter 19) */
const gchar *luma_to_curve_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform sampler1D curve;"
"void main () {"
" vec2 texturecoord = gl_TexCoord[0].st;"
" vec4 color = texture2DRect (tex, texturecoord);"
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
" vec4 outcolor;"
" color = texture1D(curve, luma);"
" gl_FragColor = color;"
"}";
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform sampler1D curve;"
"void main () {"
" vec2 texturecoord = gl_TexCoord[0].st;"
" vec4 color = texture2DRect (tex, texturecoord);"
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
" color = texture1D(curve, luma);"
" gl_FragColor = color;"
"}";
/* lut operations, map rgb to tex1d, see orange book (chapter 19) */
const gchar *rgb_to_curve_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform sampler1D curve;"
"void main () {"
" vec2 texturecoord = gl_TexCoord[0].st;"
" vec4 color = texture2DRect (tex, texturecoord);"
" vec4 outcolor;"
" outcolor.r = texture1D(curve, color.r).r;"
" outcolor.g = texture1D(curve, color.g).g;"
" outcolor.b = texture1D(curve, color.b).b;"
" outcolor.a = color.a;"
" gl_FragColor = outcolor;"
"}";
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"uniform sampler1D curve;"
"void main () {"
" vec2 texturecoord = gl_TexCoord[0].st;"
" vec4 color = texture2DRect (tex, texturecoord);"
" vec4 outcolor;"
" outcolor.r = texture1D(curve, color.r).r;"
" outcolor.g = texture1D(curve, color.g).g;"
" outcolor.b = texture1D(curve, color.b).b;"
" outcolor.a = color.a;"
" gl_FragColor = outcolor;"
"}";
const gchar *sin_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"vec3 rgb2hsl (vec3 v) "
"{"
"#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect tex;"
"vec3 rgb2hsl (vec3 v) "
"{"
/* TODO: check this algorythm */
" float MIN, MAX;"
" float r, g, b;"
" float h, l, s;"
" float delta;"
" h = 0.0; l = 0.0; s = 0.0;"
" r = v.r; g = v.g; b = v.b;"
" MIN = min (r, min (g, b));"
" MAX = max (r, max (g, b));"
" delta = MAX - MIN;"
" l = (MAX + MIN) / 2.0;"
" if ((MAX - MIN) < 0.0001) { h = 0.0; s = 0.0; }"
" else {"
" if (l <= 0.5) s = (MAX - MIN) / (MAX + MIN);"
" else s = (MAX - MIN) / (2.0 - MAX - MIN);"
" if (r == MAX) h = (g - b) / delta;"
" else if (g == MAX) h = 2.0 + (b - r) / delta;"
" else h = 4.0 + (r - g) / delta;"
" h *= 60.0;"
" if (h < 0.0) h += 360.0;"
" }"
" return vec3 (h, l, s);"
"}"
"void main () {"
" vec3 HSL, RGB;"
" vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));"
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
" HSL = rgb2hsl (color.rgb);"
" float MIN, MAX;"
" float r, g, b;"
" float h, l, s;"
" float delta;"
" h = 0.0; l = 0.0; s = 0.0;"
" r = v.r; g = v.g; b = v.b;"
" MIN = min (r, min (g, b));"
" MAX = max (r, max (g, b));"
" delta = MAX - MIN;"
" l = (MAX + MIN) / 2.0;"
" if ((MAX - MIN) < 0.0001) { h = 0.0; s = 0.0; }"
" else {"
" if (l <= 0.5) s = (MAX - MIN) / (MAX + MIN);"
" else s = (MAX - MIN) / (2.0 - MAX - MIN);"
" if (r == MAX) h = (g - b) / delta;"
" else if (g == MAX) h = 2.0 + (b - r) / delta;"
" else h = 4.0 + (r - g) / delta;"
" h *= 60.0;"
" if (h < 0.0) h += 360.0;"
" }"
" return vec3 (h, l, s);"
"}"
"void main () {"
" vec3 HSL, RGB;"
" vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));"
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
" HSL = rgb2hsl (color.rgb);"
/* move hls discontinuity away from the desired red zone so we can use
* smoothstep.. to try: convert degrees in radiants, divide by 2 and
* smoothstep cosine */
" HSL.x += 180.0;"
" if ((HSL.x) > 360.0) HSL.x -= 360.0;"
" HSL.x += 180.0;"
" if ((HSL.x) > 360.0) HSL.x -= 360.0;"
/* damn, it is extremely hard to get rid of human face reds! */
/* picked hue is slightly shifted towards violet to prevent this but
* still fails.. maybe hsl is not well suited for this */
" float a = smoothstep (110.0, 150.0, HSL.x);"
" float b = smoothstep (170.0, 210.0, HSL.x);"
" float alpha = a - b;"
" gl_FragColor = color * alpha + luma * (1.0 - alpha);"
"}";
" float a = smoothstep (110.0, 150.0, HSL.x);"
" float b = smoothstep (170.0, 210.0, HSL.x);"
" float alpha = a - b;"
" gl_FragColor = color * alpha + luma * (1.0 - alpha);"
"}";
const gchar *interpolate_fragment_source =
"#extension GL_ARB_texture_rectangle : enable\n"

View file

@ -30,6 +30,7 @@ const gchar *twirl_fragment_source;
const gchar *bulge_fragment_source;
const gchar *square_fragment_source;
const gchar *luma_threshold_fragment_source;
const gchar *sobel_fragment_source;
const gchar *hconv9_fragment_source;
const gchar *vconv9_fragment_source;
const gchar *sum_fragment_source;

264
gst/gl/gstglfiltersobel.c Normal file
View file

@ -0,0 +1,264 @@
/*
* GStreamer
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gstglfilter.h>
#include <gstgleffectssources.h>
#define GST_TYPE_GL_FILTERSOBEL (gst_gl_filtersobel_get_type())
#define GST_GL_FILTERSOBEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FILTERSOBEL,GstGLFilterSobel))
#define GST_IS_GL_FILTERSOBEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FILTERSOBEL))
#define GST_GL_FILTERSOBEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_FILTERSOBEL,GstGLFilterSobelClass))
#define GST_IS_GL_FILTERSOBEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_FILTERSOBEL))
#define GST_GL_FILTERSOBEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_FILTERSOBEL,GstGLFilterSobelClass))
typedef struct _GstGLFilterSobel GstGLFilterSobel;
typedef struct _GstGLFilterSobelClass GstGLFilterSobelClass;
struct _GstGLFilterSobel
{
GstGLFilter filter;
GstGLShader *shader0;
GLuint midtexture;
};
struct _GstGLFilterSobelClass
{
GstGLFilterClass filter_class;
};
GType gst_gl_glfiltersobel_get_type (void);
#define GST_CAT_DEFAULT gst_gl_filtersobel_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static const GstElementDetails element_details =
GST_ELEMENT_DETAILS ("Gstreamer OpenGL Sobel",
"Filter/Effect",
"Sobel edge detection",
"Filippo Argiolas <filippo.argiolas@gmail.com>");
#define DEBUG_INIT(bla) \
GST_DEBUG_CATEGORY_INIT (gst_gl_filtersobel_debug, "glfiltersobel", 0, "glfiltersobel element");
GST_BOILERPLATE_FULL (GstGLFilterSobel, gst_gl_filtersobel, GstGLFilter,
GST_TYPE_GL_FILTER, DEBUG_INIT);
static void gst_gl_filtersobel_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gl_filtersobel_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_gl_filter_filtersobel_reset (GstGLFilter* filter);
static void gst_gl_filtersobel_draw_texture (GstGLFilterSobel * filtersobel, GLuint tex);
static void gst_gl_filtersobel_init_shader (GstGLFilter* filter);
static gboolean gst_gl_filtersobel_filter (GstGLFilter * filter,
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
static void gst_gl_filtersobel_callback (gint width, gint height, guint texture, gpointer stuff);
static void
gst_gl_filtersobel_init_resources (GstGLFilter *filter)
{
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
glGenTextures (1, &filtersobel->midtexture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, filtersobel->midtexture);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
filter->width, filter->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
static void
gst_gl_filtersobel_reset_resources (GstGLFilter *filter)
{
GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (filter);
glDeleteTextures (1, &filtersobel->midtexture);
}
static void
gst_gl_filtersobel_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_details (element_class, &element_details);
}
static void
gst_gl_filtersobel_class_init (GstGLFilterSobelClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_gl_filtersobel_set_property;
gobject_class->get_property = gst_gl_filtersobel_get_property;
GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filtersobel_filter;
GST_GL_FILTER_CLASS (klass)->display_init_cb = gst_gl_filtersobel_init_resources;
GST_GL_FILTER_CLASS (klass)->display_reset_cb = gst_gl_filtersobel_reset_resources;
GST_GL_FILTER_CLASS (klass)->onInitFBO = gst_gl_filtersobel_init_shader;
GST_GL_FILTER_CLASS (klass)->onReset = gst_gl_filter_filtersobel_reset;
}
static void
gst_gl_filtersobel_init (GstGLFilterSobel * filtersobel, GstGLFilterSobelClass * klass)
{
filtersobel->shader0 = NULL;
filtersobel->midtexture = 0;
}
static void
gst_gl_filter_filtersobel_reset (GstGLFilter* filter)
{
GstGLFilterSobel* filtersobel = GST_GL_FILTERSOBEL(filter);
//blocking call, wait the opengl thread has destroyed the shader
gst_gl_display_del_shader (filter->display, filtersobel->shader0);
}
static void
gst_gl_filtersobel_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
/* GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (object); */
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gl_filtersobel_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
/* GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (object); */
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_gl_filtersobel_init_shader (GstGLFilter* filter)
{
GstGLFilterSobel* filtersobel = GST_GL_FILTERSOBEL (filter);
//blocking call, wait the opengl thread has compiled the shader
gst_gl_display_gen_shader (filter->display, 0, sobel_fragment_source, &filtersobel->shader0);
}
static void
gst_gl_filtersobel_draw_texture (GstGLFilterSobel * filtersobel, GLuint tex)
{
GstGLFilter *filter = GST_GL_FILTER (filtersobel);
glActiveTexture (GL_TEXTURE0);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, tex);
glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex2f (-1.0, -1.0);
glTexCoord2f ((gfloat)filter->width, 0.0);
glVertex2f (1.0, -1.0);
glTexCoord2f ((gfloat)filter->width, (gfloat)filter->height);
glVertex2f (1.0, 1.0);
glTexCoord2f (0.0, (gfloat)filter->height);
glVertex2f (-1.0, 1.0);
glEnd ();
}
/*static void
change_view (GstGLDisplay *display, gpointer data)
{
// GstGLFilterSobel *filtersobel = GST_GL_FILTERSOBEL (data);
const double mirrormatrix[16] = {
-1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0
};
glMatrixMode (GL_MODELVIEW);
glLoadMatrixd (mirrormatrix);
}*/
static gboolean
gst_gl_filtersobel_filter (GstGLFilter* filter, GstGLBuffer* inbuf,
GstGLBuffer* outbuf)
{
GstGLFilterSobel* filtersobel = GST_GL_FILTERSOBEL(filter);
// gst_gl_display_thread_add (filter->display, change_view, filtersobel);
gst_gl_filter_render_to_target (filter, inbuf->texture, outbuf->texture,
gst_gl_filtersobel_callback, filtersobel);
return TRUE;
}
static void
gst_gl_filtersobel_callback (gint width, gint height, guint texture, gpointer stuff)
{
GstGLFilterSobel* filtersobel = GST_GL_FILTERSOBEL (stuff);
gfloat hkern[9] = {
1.0, 0.0, -1.0,
2.0, 0.0, -2.0,
1.0, 0.0, -1.0
};
gfloat vkern[9] = {
1.0, 2.0, 1.0,
0.0, 0.0, 0.0,
-1.0, -2.0, -1.0
};
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gst_gl_shader_use (filtersobel->shader0);
glActiveTexture (GL_TEXTURE1);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
gst_gl_shader_set_uniform_1i (filtersobel->shader0, "tex", 1);
gst_gl_shader_set_uniform_1fv (filtersobel->shader0, "hkern", 9, hkern);
gst_gl_shader_set_uniform_1fv (filtersobel->shader0, "vkern", 9, vkern);
gst_gl_filtersobel_draw_texture (filtersobel, texture);
}

View file

@ -43,6 +43,7 @@ GType gst_gl_effects_get_type (void);
GType gst_gl_filter_app_get_type (void);
GType gst_gl_filter_cube_get_type (void);
GType gst_gl_filterblur_get_type (void);
GType gst_gl_filtersobel_get_type (void);
GType gst_gl_filter_edge_get_type (void);
GType gst_gl_filter_laplacian_get_type (void);
GType gst_gl_filter_glass_get_type (void);
@ -100,6 +101,11 @@ plugin_init (GstPlugin * plugin)
return FALSE;
}
if (!gst_element_register (plugin, "glfiltersobel",
GST_RANK_NONE, gst_gl_filtersobel_get_type())) {
return FALSE;
}
if (!gst_element_register (plugin, "glfilterlaplacian",
GST_RANK_NONE, GST_TYPE_GL_FILTER_LAPLACIAN)) {
return FALSE;