[gst-devel] have written new "effect" for geometrictransform
thiagossantos at gmail.com
thiagossantos at gmail.com
Thu Sep 2 15:35:12 CEST 2010
On Thu, Sep 2, 2010 at 9:45 AM, Bert Douglas <bertd at tplogic.com> wrote:
> Hi All,
>
> I have written a new "effect" for geometrictransform. It does image
> rotation.
> The code is appended below.
> If there is any interest, I will do the work to push it upstream.
> But I need a mentor to help guide the way.
>
> On the code itself.
> I modified the "circle" element, to do rotation.
> The changes were confined to the "map" function.
> I used the same parameters, but with different meaning.
>
Great! I can help you getting this in. Can you provide this as a git patch
in bugzilla?
In case you've never done this before, I could guide you through the details
so you'd learn how to do it. I'm available on #gstreamer on freenode as
'thiagoss'. You can talk to me there or send me a private mail.
>
> Thanks,
> Bert Douglas
>
> ------------------------------------------------------------------------
>
> static gboolean
> circle_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
> gdouble * in_y)
> {
> //GstCircleGeometricTransform *cgt = GST_CIRCLE_GEOMETRIC_TRANSFORM_CAST
> (gt);
> GstCircle *circle = GST_CIRCLE_CAST (gt);
>
> gint w, h;
> gdouble pad, sa;
> gdouble cix, ciy, cox, coy; // centers, in/out x/y
> gdouble ai, ao, ar; // angles, in/out/rotate (radians)
> gdouble r; // radius
> gdouble xi, yi, xo, yo; // positions in/out x/y
>
> // input and output image height and width
> w = gt->width;
> h = gt->height;
>
> // our parameters
> pad = circle->height; // padding on bottom and right of input
> image
> ar = circle->angle * M_PI / 180.0; // angle of rotation, degrees to
> radians
> sa = circle->spread_angle; // not used
>
> // get in and out centers
> cox = 0.5 * w;
> coy = 0.5 * h;
> cix = 0.5 * (w - pad);
> ciy = 0.5 * (h - pad);
>
> // convert output image position to polar form
> xo = x - cox;
> yo = y - coy;
> ao = atan2 (yo, xo);
> r = sqrt (xo * xo + yo * yo);
>
> // perform rotation backward to get input image rotation
> // this seems wrong, but rotation from in-->out is counterclockwise
> ai = ao + ar;
>
> // back to rectangular for input image position
> xi = r * cos (ai);
> yi = r * sin (ai);
>
> // restore center offset, return values to caller
> *in_x = xi + cix;
> *in_y = yi + ciy;
>
> GST_DEBUG_OBJECT (circle, "Inversely mapped %d %d into %lf %lf",
> x, y, *in_x, *in_y);
>
> return TRUE;
> }
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
--
Thiago Sousa Santos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20100902/ec8f2e28/attachment-0001.htm>
More information about the gstreamer-devel
mailing list