|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Facemorph.aam.FBOwarp
public class FBOwarp
Frame buffer object warping
Constructor Summary | |
---|---|
FBOwarp(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)
Constructor for FBOwarp |
|
FBOwarp(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 FBOwarp |
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 affine border points |
static void |
addBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> points,
int width,
int height)
Adds a set of points round the border |
void |
checkError(javax.media.opengl.GL gl)
Check for an OpenGL error |
DelaunayTriangle[] |
computeTriangulation(java.util.Vector<java.awt.geom.Point2D.Float> points)
Compute the delaunay triangulation of the given points |
void |
destroy()
Deletes this (currently empty method) |
void |
display()
Force a redraw? (currently empty) |
void |
display(javax.media.opengl.GLAutoDrawable drawable)
|
void |
displayChanged(javax.media.opengl.GLAutoDrawable drawable,
boolean modeChanged,
boolean deviceChanged)
|
void |
dispose()
Disposes this FBOwarp |
static FloatImage |
getAlpha(java.awt.image.BufferedImage bimg)
Gets the alpha channel from the image |
int |
getHeight()
Get the height of this FBOwarp |
FloatImage[] |
getResult()
Get the warped image as an array of 3 FloatImage |
FloatImage[] |
getResult(boolean alpha)
Get the warped image as an array of 3 or 4 FloatImage |
int |
getWidth()
Get the width of this FBOwarp |
void |
grab(javax.media.opengl.GL gl,
FloatImage[] result)
Grab the result to the supplied array of float images |
void |
init(javax.media.opengl.GLAutoDrawable drawable)
|
void |
initFBO(javax.media.opengl.GL gl,
javax.media.opengl.glu.GLU glu)
Initialise the FBO |
double |
jacobianError()
Calculate the jacobean error (difference from 1) |
static void |
main(java.lang.String[] args)
Main method for testing |
double |
overlap(double minArea,
boolean adjust)
Scales the warp so that it doesn't fold |
void |
postRenderFBO(javax.media.opengl.GL gl,
javax.media.opengl.glu.GLU glu)
Unbinds the FBO |
void |
preRenderFBO(javax.media.opengl.GL gl,
javax.media.opengl.glu.GLU glu)
Sets up the global rendering state, binds the FBO |
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)
Non-integer bilinear sampling from a BufferedImage |
static java.awt.image.BufferedImage |
setAlpha(java.awt.image.BufferedImage bimg,
FloatImage alpha)
sets the alpha channel of the image |
void |
setDrawTriangulation(boolean drawTriangulation)
Should the warp triangulation be drawn |
void |
setDrawWarp(boolean drawWarp)
Should the warped image be drawn |
void |
setGLAutoDrawable(javax.media.opengl.GLAutoDrawable drawable)
Sets the OpenGL canvas |
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)
Sets the start and end warp points |
void |
setSize(int w,
int h)
Sets the size |
void |
setTriangulation(DelaunayTriangle[] dtTess)
Set the triangulation for this warp |
static java.nio.FloatBuffer |
toFloatBuffer(java.awt.image.BufferedImage bimg)
Converts 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 FBOwarp(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 FBOwarp(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
- use an existing OpenGL canvasMethod Detail |
---|
public void setSize(int w, int h)
w
- the new widthh
- the new heightpublic void dispose()
public void setGLAutoDrawable(javax.media.opengl.GLAutoDrawable drawable)
drawable
- the new OpenGL canvaspublic int getWidth()
public int getHeight()
public FloatImage[] getResult()
public FloatImage[] getResult(boolean alpha)
alpha
- indicates if the alpha should be grabbed
public void checkError(javax.media.opengl.GL gl)
gl
- the OpenGL object to checkpublic 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
- the new value for drawWarppublic void setDrawTriangulation(boolean drawTriangulation)
drawTriangulation
- the new value for drawTriangulationpublic static java.awt.Color sample(java.awt.image.BufferedImage img, float x, float y)
img
- the image to sample fromx
- the x-coord to sample fromy
- the y-coord to sample from
public static java.nio.FloatBuffer toFloatBuffer(java.awt.image.BufferedImage bimg)
bimg
- the 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 new triangulationpublic 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 objectresult
- for storing the resultspublic 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 void preRenderFBO(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
gl
- the opengl contextglu
- the opengl utility objectpublic void postRenderFBO(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
gl
- glu
- public void initFBO(javax.media.opengl.GL gl, javax.media.opengl.glu.GLU glu)
gl
- the opengl contextglu
- the opengl utility objectpublic 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 source points arraydstPoints
- the target point arraywidth
- the output widthheight
- the output heightaddBorder
- indicates that the border points should be addedpublic static void addBorderPoints(java.util.Vector<java.awt.geom.Point2D.Float> points, int width, int height)
points
- the point set to add towidth
- the image widthheight
- the image heightpublic double jacobianError()
public double overlap(double minArea, boolean adjust)
minArea
- the minimum allowed area of each triangle as a fraction of its current areaadjust
- if true and any triangles are smaller that the allowed minimum the warp is scaled to ensure it doesn't fold or come close to folding
public static java.awt.image.BufferedImage setAlpha(java.awt.image.BufferedImage bimg, FloatImage alpha)
bimg
- the original 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
- args[0] = name of input image, args[1] and args[2] start and end templates, args[3] output image name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |