visageSDK
Public Member Functions | Static Public Member Functions | List of all members
com.visagetechnologies.facedetectdemo.ImageDetectorView Class Reference

Derives from TrackerView. More...

Inheritance diagram for com.visagetechnologies.facedetectdemo.ImageDetectorView:
com.visagetechnologies.facedetectdemo.DetectorView

Public Member Functions

void surfaceCreated (SurfaceHolder holder)
 Implementation of surfaceCreated method provided by SurfaceHolder.Callback class. More...
 
void surfaceChanged (SurfaceHolder holder, int format, int width, int height)
 Implementation of surfaceChanged method provided by SurfaceHolder.Callback class. More...
 
void surfaceDestroyed (SurfaceHolder holder)
 Implementation of surfaceDestroyed method provided by SurfaceHolder.Callback class.
 
int getBitmapWidth ()
 Called to obtain width of bitmap used for tracking. More...
 
int getBitmapHeight ()
 Called to obtain height of bitmap used for tracking. More...
 
Bitmap SetOptimalBitmapSize (Bitmap bitmap)
 Utility method used to resize bitmap of image used for tracking. More...
 
byte [] ConvertToByte (Bitmap bitmap, boolean opacity)
 Utility method called to obtain raw pixel data from bitmap object in which image used for detection is loaded. More...
 
void CreateGallery () throws IOException
 Method used to create face recognition gallery from set of images. More...
 
void run ()
 Implementation of run method of Runnable interface. More...
 
- Public Member Functions inherited from com.visagetechnologies.facedetectdemo.DetectorView
void setGLView (DetectorGLSurfaceView tview)
 Called to set GLSurfaceView used for rendering with OpenGL. More...
 

Static Public Member Functions

static Bitmap LoadFromFile (Activity activity, Uri uri) throws IOException
 Utility method called for loading the image from file into a Bitmap object. More...
 
static native void DetectFeatures (byte[] frame, int width, int height)
 Interface to native method used for passing raw pixel data to detector. More...
 

Detailed Description

Derives from TrackerView.

Class ImageTrackerView is used for providing detector with necessary image data and controlling surface used to display results of detection. Implements Runnable interface provided by Android. Runnable interface is used for implementation of simple multi-threading.

Definition at line 28 of file ImageDetectorView.java.

Member Function Documentation

◆ ConvertToByte()

byte [] com.visagetechnologies.facedetectdemo.ImageDetectorView.ConvertToByte ( Bitmap  bitmap,
boolean  opacity 
)
inline

Utility method called to obtain raw pixel data from bitmap object in which image used for detection is loaded.

Pixel data is obtained as array of integers by calling getPixels method of Bitmap class. Each element of obtained array of integer represents one pixel of bitmap. In order to create pixel data usable by tracker it is necessary to extract red, green and blue color values from array of integers and store it as a byte array.

Parameters
bitmapbitmap image from which pixel data will be obtained
opacityopacity flag indicating if image is transparent
Returns
byte array of raw pixel data obtained from image used for detection.

Definition at line 267 of file ImageDetectorView.java.

Referenced by com.visagetechnologies.facedetectdemo.ImageDetectorView.CreateGallery(), and com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceCreated().

◆ CreateGallery()

void com.visagetechnologies.facedetectdemo.ImageDetectorView.CreateGallery ( ) throws IOException
inline

Method used to create face recognition gallery from set of images.

Path to directory where images are located is defined in pathToGallery. For each image that is loaded and converted to pixel data, JNI method AddToGallery is called.

Definition at line 305 of file ImageDetectorView.java.

References com.visagetechnologies.facedetectdemo.ImageDetectorView.ConvertToByte(), com.visagetechnologies.facedetectdemo.ImageDetectorView.LoadFromFile(), and com.visagetechnologies.facedetectdemo.ImageDetectorView.SetOptimalBitmapSize().

Referenced by com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceCreated().

◆ DetectFeatures()

static native void com.visagetechnologies.facedetectdemo.ImageDetectorView.DetectFeatures ( byte []  frame,
int  width,
int  height 
)
static

Interface to native method used for passing raw pixel data to detector.

Called from surfaceCreated.

Parameters
frameraw pixel data of image used for tracking.
widthwidth of image used for tracking.
heightheight of image used for tracking.

Referenced by com.visagetechnologies.facedetectdemo.ImageDetectorView.run(), and com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceCreated().

◆ getBitmapHeight()

int com.visagetechnologies.facedetectdemo.ImageDetectorView.getBitmapHeight ( )
inline

Called to obtain height of bitmap used for tracking.

Returns
height of bitmap in pixels.

Definition at line 123 of file ImageDetectorView.java.

◆ getBitmapWidth()

int com.visagetechnologies.facedetectdemo.ImageDetectorView.getBitmapWidth ( )
inline

Called to obtain width of bitmap used for tracking.

Returns
width of bitmap in pixels

Definition at line 114 of file ImageDetectorView.java.

◆ LoadFromFile()

static Bitmap com.visagetechnologies.facedetectdemo.ImageDetectorView.LoadFromFile ( Activity  activity,
Uri  uri 
) throws IOException
inlinestatic

Utility method called for loading the image from file into a Bitmap object.

Returns
loaded bitmap object

Definition at line 243 of file ImageDetectorView.java.

Referenced by com.visagetechnologies.facedetectdemo.ImageDetectorView.CreateGallery().

◆ run()

void com.visagetechnologies.facedetectdemo.ImageDetectorView.run ( )
inline

Implementation of run method of Runnable interface.

Android requires that all rendering to a surface is done from separate thread than the one which created the View object. Rendering thread is started from surfaceCreated method. Method calls rendering logic of application.

Definition at line 322 of file ImageDetectorView.java.

References com.visagetechnologies.facedetectdemo.ImageDetectorView.DetectFeatures().

◆ SetOptimalBitmapSize()

Bitmap com.visagetechnologies.facedetectdemo.ImageDetectorView.SetOptimalBitmapSize ( Bitmap  bitmap)
inline

Utility method used to resize bitmap of image used for tracking.

Images that are larger than the screen are resized to fit the screen while keeping the initial ratio between height and width. In order to interpret images in a correct way OpenCV requires image size to be power of two. Images that have either width or height value that does not satisfy this condition are additionally resized until they do. This slightly changes ratio between width and height.

Definition at line 133 of file ImageDetectorView.java.

Referenced by com.visagetechnologies.facedetectdemo.ImageDetectorView.CreateGallery(), and com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceCreated().

◆ surfaceChanged()

void com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceChanged ( SurfaceHolder  holder,
int  format,
int  width,
int  height 
)
inline

Implementation of surfaceChanged method provided by SurfaceHolder.Callback class.

Sets new width and height values of view.

Definition at line 95 of file ImageDetectorView.java.

◆ surfaceCreated()

void com.visagetechnologies.facedetectdemo.ImageDetectorView.surfaceCreated ( SurfaceHolder  holder)
inline

Implementation of surfaceCreated method provided by SurfaceHolder.Callback class.

Creates and starts rendering thread. Calls DetectFeatures method to pass image data to detector.

Definition at line 74 of file ImageDetectorView.java.

References com.visagetechnologies.facedetectdemo.ImageDetectorView.ConvertToByte(), com.visagetechnologies.facedetectdemo.ImageDetectorView.CreateGallery(), com.visagetechnologies.facedetectdemo.ImageDetectorView.DetectFeatures(), and com.visagetechnologies.facedetectdemo.ImageDetectorView.SetOptimalBitmapSize().


The documentation for this class was generated from the following file: