|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Facemorph.aam.OpenGLwarp
public class OpenGLwarp
Opengl BASED WARPING
Constructor Summary | |
---|---|
OpenGLwarp(int width,
int height,
java.awt.image.BufferedImage bimg,
java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints,
java.util.Vector<java.awt.geom.Point2D.Float> targetPoints)
Creates a new OpenGL warp |
|
OpenGLwarp(int width,
int height,
java.awt.image.BufferedImage bimg,
java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints,
java.util.Vector<java.awt.geom.Point2D.Float> targetPoints,
javax.media.opengl.GLAutoDrawable canvas)
Constructor for OpenGLWarp |
Method Summary | |
---|---|
static void |
addAffineBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> srcPoints,
java.util.Vector<java.awt.geom.Point2D.Float> dstPoints,
int width,
int height,
boolean addBorder)
Adds points to pin down the border |
static void |
addBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> points,
int width,
int height)
Add border points to the point set given |
void |
checkError(javax.media.opengl.GL gl)
Check for opengl errors |
DelaunayTriangle[] |
computeTriangulation(java.util.Vector<java.awt.geom.Point2D.Float> points)
Compute the Delaunay Triangulation of a set of points |
void |
destroy()
Destroy the offscreen context |
void |
display()
Force a redraw of the offscreen context |
void |
display(javax.media.opengl.GLAutoDrawable drawable)
|
void |
displayChanged(javax.media.opengl.GLAutoDrawable drawable,
boolean modeChanged,
boolean deviceChanged)
|
void |
dispose()
Dispose of this |
static FloatImage |
getAlpha(java.awt.image.BufferedImage bimg)
Get the alpha channel as a FloatImage |
int |
getHeight()
Get the height |
FloatImage[] |
getResult()
Get the warped image |
FloatImage[] |
getResult(boolean alpha)
Get the warped image |
int |
getWidth()
Get the width |
void |
grab(javax.media.opengl.GL gl,
FloatImage[] result)
Grab the frame buffer into the FloatImage |
void |
init(javax.media.opengl.GLAutoDrawable drawable)
|
double |
jacobianError()
Calculate the jacobean error, i.e. |
static void |
main(java.lang.String[] args)
Main method used for testing |
double |
overlap(double minArea,
boolean adjust)
Calculate and optionally apply scaling to prevent warp folding |
void |
reshape(javax.media.opengl.GLAutoDrawable drawable,
int x,
int y,
int width,
int height)
|
static java.awt.Color |
sample(java.awt.image.BufferedImage img,
float x,
float y)
Sample from a BufferedImage |
static java.awt.image.BufferedImage |
setAlpha(java.awt.image.BufferedImage bimg,
FloatImage alpha)
Set the alpha channel |
void |
setDrawTriangulation(boolean drawTriangulation)
Indicate that the triangulation should be drawn |
void |
setDrawWarp(boolean drawWarp)
Indicate that the warped image should be drawn (??) |
void |
setGLAutoDrawable(javax.media.opengl.GLAutoDrawable drawable)
Set the opengl context |
void |
setImage(java.awt.image.BufferedImage img)
Set the image to warp |
void |
setPoints(java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints,
java.util.Vector<java.awt.geom.Point2D.Float> targetPoints)
Set the warping points |
void |
setSize(int w,
int h)
Sets the size |
void |
setTriangulation(DelaunayTriangle[] dtTess)
Set teh triangulation to use |
static java.nio.FloatBuffer |
toFloatBuffer(java.awt.image.BufferedImage bimg)
Convert the image to a FloatBuffer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OpenGLwarp(int width, int height, java.awt.image.BufferedImage bimg, java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints, java.util.Vector<java.awt.geom.Point2D.Float> targetPoints)
width
- the widthheight
- the heightbimg
- the image to warpsourcePoints
- the start pointstargetPoints
- the end pointspublic OpenGLwarp(int width, int height, java.awt.image.BufferedImage bimg, java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints, java.util.Vector<java.awt.geom.Point2D.Float> targetPoints, javax.media.opengl.GLAutoDrawable canvas)
width
- the widthheight
- the heightbimg
- the image to warpsourcePoints
- the start pointstargetPoints
- the end pointscanvas
- the opengl canvas to useMethod Detail |
---|
public void setSize(int w, int h)
w
- the widthh
- the heightpublic void dispose()
public void setGLAutoDrawable(javax.media.opengl.GLAutoDrawable drawable)
drawable
- the new opengl contextpublic int getWidth()
public int getHeight()
public FloatImage[] getResult()
public FloatImage[] getResult(boolean alpha)
alpha
- indicates that the alpha channel should be included
public void checkError(javax.media.opengl.GL gl)
gl
- the opengl contextpublic void destroy()
public void setImage(java.awt.image.BufferedImage img)
img
- the image to warppublic void setPoints(java.util.Vector<java.awt.geom.Point2D.Float> sourcePoints, java.util.Vector<java.awt.geom.Point2D.Float> targetPoints)
sourcePoints
- the start pointstargetPoints
- the end pointspublic void display()
public void setDrawWarp(boolean drawWarp)
drawWarp
- if treu draw the warped imagepublic void setDrawTriangulation(boolean drawTriangulation)
drawTriangulation
- if true draw the triangulationpublic static java.awt.Color sample(java.awt.image.BufferedImage img, float x, float y)
img
- the image to sample fromx
- the x coordy
- the y coord
public static java.nio.FloatBuffer toFloatBuffer(java.awt.image.BufferedImage bimg)
bimg
- the buffered image to convert
public DelaunayTriangle[] computeTriangulation(java.util.Vector<java.awt.geom.Point2D.Float> points)
points
- the points to triangulate
public void setTriangulation(DelaunayTriangle[] dtTess)
dtTess
- the triangulation to usepublic void init(javax.media.opengl.GLAutoDrawable drawable)
init
in interface javax.media.opengl.GLEventListener
public void display(javax.media.opengl.GLAutoDrawable drawable)
display
in interface javax.media.opengl.GLEventListener
public void grab(javax.media.opengl.GL gl, FloatImage[] result)
gl
- the opengl contextresult
- the array of FloatImage to store the grabbed imagepublic void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
reshape
in interface javax.media.opengl.GLEventListener
public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
displayChanged
in interface javax.media.opengl.GLEventListener
public static void addAffineBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> srcPoints, java.util.Vector<java.awt.geom.Point2D.Float> dstPoints, int width, int height, boolean addBorder)
srcPoints
- the start point arraydstPoints
- the end point arraywidth
- the widthheight
- the heightaddBorder
- indicates that points need to be added to both arrays, not just the output arraypublic static void addBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> points, int width, int height)
points
- the point set to add the border points toowidth
- the widthheight
- the heightpublic double jacobianError()
public double overlap(double minArea, boolean adjust)
minArea
- The minimum permited areaadjust
- if true and the scaling is less than 1 rescale the warp
public static java.awt.image.BufferedImage setAlpha(java.awt.image.BufferedImage bimg, FloatImage alpha)
bimg
- the imagealpha
- the new alpha channel
public static FloatImage getAlpha(java.awt.image.BufferedImage bimg)
bimg
- the image to get the alpha channel from
public static void main(java.lang.String[] args)
args
- the arguments
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |