After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 710810 - geometrictransform: Add a plugin for a 2D perspective transform
geometrictransform: Add a plugin for a 2D perspective transform
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.2.0
Other All
: Normal enhancement
: 1.3.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-24 14:06 UTC by Antonio Ospite
Modified: 2013-12-02 09:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
add a matrix plugin for a 2D perspective transform (13.71 KB, patch)
2013-10-24 14:06 UTC, Antonio Ospite
needs-work Details | Review
geometrictransform: add a 2D perspective transform plugin (14.17 KB, patch)
2013-11-02 13:56 UTC, Antonio Ospite
committed Details | Review

Description Antonio Ospite 2013-10-24 14:06:53 UTC
Created attachment 258024 [details] [review]
add a matrix plugin for a 2D perspective transform

Hi,

in the attached patch I am proposing a "matrix" plugin which applies a 2D perspective (also called projective) transform to the frame buffer.

A perspective transform can be used for instance to perform keystone correction when playing the content with a video projector.

It is a little and nice generic plugin, but it is my first one, so I could use some review, in particular I am concerned about the gst_matrix_get_property() implementation, I am using a new allocated GValueArray (allocated in get_array_from_matrix()), is that OK?

A test program for the plugin can be found here:
http://git.ao2.it/experiments/gstreamer.git/tree/HEAD:/c/gst-matrix-example

The plugin is based on the "rotate" one, the "semantic diff" can be seen with this script:

#!/bin/bash

set -e

filter()
{
  cat $1 | sed -e 's/ROTATE/MATRIX/g' -e 's/Rotate/Matrix/g' -e 's/rotate/matrix/g'
}

diff -pu <(filter gstrotate.h) gstmatrix.h | cat
diff -pu <(filter gstrotate.c) gstmatrix.c
Comment 1 Sebastian Dröge (slomo) 2013-10-31 21:24:35 UTC
Review of attachment 258024 [details] [review]:

Looks good in general, but the name seems wrong

::: gst/geometrictransform/gstmatrix.c
@@ +187,3 @@
+  /* Perspective division */
+  xi = xp / w;
+  yi = yp / w;

As this is not a normal matrix multiplication but perspective transformation, maybe the element should be called perspectivetransform instead?
Comment 2 Antonio Ospite 2013-11-02 13:56:39 UTC
Created attachment 258799 [details] [review]
geometrictransform: add a 2D perspective transform plugin

Hi Sebastian,

an affine transform can be seen as a particular case of perspective
transform that's why I was calling the plugin just "matrix", but I agree
with you that "perspective" is a better name; I am leaving out the
"transform" suffix from the plugin name as the plugin is
a geometrictransform already.

Version 2  attached.

Changes since v1:
  - Rename the element from "matrix" to "perspective"
  - Rename the "m" property to "matrix"
  - Don't include math.h and geometricmath.h in gstperspective.c


I still have a doubt about gst_perspective_get_property() where I am
returning an array allocated in get_array_from_matrix(): whose
responsibility is to free that memory?

The example program has been updated too:
http://git.ao2.it/experiments/gstreamer.git/tree/HEAD:/c/gst-perspective-example

Thanks,
   Antonio

P.S. here's the updated "semantic diff" script:
#!/bin/bash

set -e

filter()
{
  cat $1 | sed -e 's/ROTATE/PERSPECTIVE/g' \
               -e 's/Rotate/Perspective/g' \
               -e 's/rotate/perspective/g'
}

diff -pu <(filter gstrotate.h) gstperspective.h | cat
diff -pu <(filter gstrotate.c) gstperspective.c
Comment 3 Antonio Ospite 2013-11-26 23:08:58 UTC
ping
Comment 4 Sebastian Dröge (slomo) 2013-12-02 09:29:07 UTC
commit 8de96a2fbbb1e56dae298887a3a71e6c4572f148
Author: Antonio Ospite <ospite@studenti.unina.it>
Date:   Sun Oct 20 22:04:38 2013 +0200

    geometrictransform: Add a 2D perspective transform plugin
    
    The perspective plugin applies a 2D perspective (also called projective)
    transform to the frame buffer.
    
    A perspective transform can be used for instance to perform keystone
    correction when playing the content with a video projector.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710810