6 #include "VisageRendering.h" 7 #include "VisageFeaturesDetector.h" 9 #include "VisageFaceRecognition.h" 10 #include "LicenseString.h" 13 #include <android/log.h> 14 #define LOG_TAG "DetectorWrapper" 15 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) 16 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) 49 static bool endsWith(
const std::string& str,
const std::string& suffix)
51 return str.size() >= suffix.size() && 0 == str.compare(str.size()-suffix.size(), suffix.size(), suffix);
68 className =
"com/visagetechnologies/facedetectdemo/DetectorActivity";
70 _appPath = env->GetStringUTFChars(appPath, 0);
73 std::string pathToLicense(_appPath + std::string(
"/") + licenseKey);
74 if (endsWith(licenseKey,
".vlc"))
75 initializeLicenseManager(env, obj, pathToLicense.c_str(),
AlertCallback);
77 initializeLicenseManager(env, obj, licenseKey.c_str(),
AlertCallback);
79 if(visageFeaturesDetector == 0)
81 const char *_modelName = env->GetStringUTFChars(modelName, 0);
82 std::string pathToCfgFile(_appPath + std::string(
"/") +
"Face Detector.cfg");
84 bool ret = visageFeaturesDetector->
Initialize();
85 env->ReleaseStringUTFChars(modelName, _modelName);
86 env->ReleaseStringUTFChars(appPath, _appPath);
100 if(visageFeaturesDetector == 0)
105 jbyte *f = env->GetByteArrayElements(frame, 0);
106 input = vsCreateImage(vsSize(width, height), VS_DEPTH_8U, 3);
117 env->ReleaseByteArrayElements(frame, f, 0);
127 VisageRendering::Reset();
150 glHeight = glHeight*tmp/
glWidth;
157 LOGE(
"Could not load font");
163 LOGE(
"Could not load logo");
165 for (
int i = 0; i<faces; i++)
177 vsReleaseImage(&input);
178 vsReleaseImage(&logo);
179 vsReleaseImage(&font);
int height
Image height in pixels.
static void DisplayResults(FaceData *trackingData, int trackStat, int width, int height, VsImage *frame, int drawingOptions=DISPLAY_DEFAULT)
Method calls other methods for drawing the frame and tracking results.
void Java_com_visagetechnologies_facedetectdemo_ImageDetectorView_DetectFeatures(JNIEnv *env, jobject obj, jbyteArray frame, jint width, jint height)
Method for passing raw image data to detector and initiating detection of features in it...
int glHeight
Size of the OpenGL view.
Faces and facial features detector implementation.
float videoAspect
Aspect of the video.
char * imageData
Pointer to aligned image data.
void AlertCallback(const char *warningMessage)
Callback method for license notification.
int width
Image width in pixels.
void Java_com_visagetechnologies_facedetectdemo_DetectorActivity_DetectorInit(JNIEnv *env, jobject obj, jstring appPath, jstring modelName)
Method for initializing the detector.
static void SetFontTexture(const VsImage *font_tex)
Method sets font texture.
int imageSize
Image data size in bytes (==image->height*image->widthStep in case of interleaved data) ...
int detectFacialFeatures(VsImage *frame, FaceData *output, int maxFaces=1, float minFaceScale=0.1f, float maxFaceScale=1.0f, bool outputOnly2DFeatures=false)
Performs faces and facial features detection in a still image.
bool Initialize()
Initializes the features detector.
int glWidth
Size of the OpenGL view.
Face data structure, used as container for all face tracking and detection results.
void Java_com_visagetechnologies_facedetectdemo_DetectorActivity_CleanUp(JNIEnv *env, jobject obj)
Method for cleaning up resources used by application.
void Java_com_visagetechnologies_facedetectdemo_DetectorRenderer_displayResults(JNIEnv *env, jobject obj, jint width, jint height)
Method for displaying detection results.
Feature points of a face.
static void DisplayLogo(const VsImage *logo, int width, int height)
Method draws a logo in the upper right corner.