public abstract class VideoRenderProcessing<T extends boofcv.struct.image.ImageBase<T>> extends java.lang.Thread implements VideoProcessing
Processing class for displaying more complex visualizations data. Children of this class must properly lock
down the GUI when processing data that can be read/written to when updating GUI. This is done by synchronizing
around the class variable lockGui.
The canvas is resized and centered for display purposes. The scale and translation factors applied to the
canvas prior to it being passed in to the child of this class can be access through the class parameters or
getter functions. The size of the output image can be accessed in a similar manor, see outputWidth and
outputHeight. The just mentioned output size is used to compute the scale and translation and can be
overridden inside init(android.view.View, android.hardware.Camera, android.hardware.Camera.CameraInfo, int) or declareImages(int, int).
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
lockConvert
Lock used when converting the video stream.
|
protected java.lang.Object |
lockGui
Lock used ever reading or writing to display related data.
|
protected int |
outputHeight |
protected int |
outputWidth |
protected double |
scale |
protected double |
tranX |
protected double |
tranY |
protected android.view.View |
view |
| Modifier | Constructor and Description |
|---|---|
protected |
VideoRenderProcessing(boofcv.struct.image.ImageType<T> imageType) |
| Modifier and Type | Method and Description |
|---|---|
void |
convertPreview(byte[] bytes,
android.hardware.Camera camera)
Called inside the camera preview thread after new data has arrived.
|
protected void |
declareImages(int width,
int height) |
double |
getScale()
Scaling applied to the drawing canvas
|
double |
getTranX()
Translation x applied to the drawing canvas
|
double |
getTranY()
Translation y applied to the drawing canvas
|
protected void |
imageToOutput(double x,
double y,
georegression.struct.point.Point2D_F64 pt)
Converts a coordinate from pixel to the output image coordinates
|
void |
init(android.view.View view,
android.hardware.Camera camera,
android.hardware.Camera.CameraInfo info,
int previewRotation) |
void |
onDraw(android.graphics.Canvas canvas)
Invoked by Android GUI thread.
|
protected void |
outputToImage(double x,
double y,
georegression.struct.point.Point2D_F64 pt)
Converts a coordinate from output image coordinates to input image
|
protected abstract void |
process(T gray)
Image processing is done here and is invoked in its own thread, removing any hard time constraints.
|
protected abstract void |
render(android.graphics.Canvas canvas,
double imageToOutput)
Results computed by
process(T) are visualized here. |
void |
run() |
void |
stopProcessing()
Blocks until all processing has stopped
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprotected int outputWidth
protected int outputHeight
protected android.view.View view
protected final java.lang.Object lockGui
protected final java.lang.Object lockConvert
protected double scale
protected double tranX
protected double tranY
protected VideoRenderProcessing(boofcv.struct.image.ImageType<T> imageType)
public void init(android.view.View view,
android.hardware.Camera camera,
android.hardware.Camera.CameraInfo info,
int previewRotation)
init in interface VideoProcessingpublic void onDraw(android.graphics.Canvas canvas)
VideoProcessingonDraw in interface VideoProcessingcanvas - Use this canvas to draw results onto. Already be adjusted for the display and camera
preview size. .protected void imageToOutput(double x,
double y,
georegression.struct.point.Point2D_F64 pt)
protected void outputToImage(double x,
double y,
georegression.struct.point.Point2D_F64 pt)
public void convertPreview(byte[] bytes,
android.hardware.Camera camera)
VideoProcessingconvertPreview in interface VideoProcessingbytes - Data from preview image in NV21 format.camera - Reference to camerapublic void stopProcessing()
VideoProcessingstopProcessing in interface VideoProcessingpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic double getScale()
public double getTranX()
public double getTranY()
protected abstract void process(T gray)
Image processing is done here and is invoked in its own thread, removing any hard time constraints.
When modifying data structures that are read inside of render(android.graphics.Canvas, double) be sure to use synchronize with
lockGui to avoid crashes or weird visual artifacts. Use of lockGui should be minimized to
ensure a fast and responsive GUI
protected abstract void render(android.graphics.Canvas canvas,
double imageToOutput)
process(T) are visualized here. This function is called inside a
synchronize(lockGui) block. The provided canvas has been adjusted to be centered in the view and to account
for the resolution difference of the preview image and the display.canvas - Canvas which is to be displayed.imageToOutput - Scale factor from input image to output display. Can also be accessed via getScale()protected void declareImages(int width,
int height)