It wraps this Github project. It extracts facial states and facial landmark information from a photo (bitmap) containing a human face. See the pic below...
Posting the following:
1. B4A project - b4aAndroidVisionPhotoFaceDetector.zip
2. The B4A library files (AndroidVisionFaceViewLibFiles.zip)
3. The java code as it stands at present (TheJavaCode.zip)
4. A link to all the other jars that will be required - download them from here and copy them to your additional library folder - https://www.dropbox.com/s/se5x5znl1tgpv6r/OtherLibFiles.zip?dl=0
5. resourceAdditionalLibFolder.zip - extract it and copy the resource folder to your additional library folder
6. resource.zip - extract it and copy the resource folder to the same folder level that of the /Files and /Objects folders of the B4A project.
You can download and test it but if you want to use it then you need to
Sample Code:
Library:
AndroidVisionFaceView
Author: Github: Clayton Wilkinson, Wrapped by: Johan Schoeman
Version: 1
AndroidVisionFaceView
Events:
Also important to note the B4A project's Manifest Files
And equally important to set your paths correctly (the below only applicable to my folder setup):
Posting the following:
1. B4A project - b4aAndroidVisionPhotoFaceDetector.zip
2. The B4A library files (AndroidVisionFaceViewLibFiles.zip)
3. The java code as it stands at present (TheJavaCode.zip)
4. A link to all the other jars that will be required - download them from here and copy them to your additional library folder - https://www.dropbox.com/s/se5x5znl1tgpv6r/OtherLibFiles.zip?dl=0
5. resourceAdditionalLibFolder.zip - extract it and copy the resource folder to your additional library folder
6. resource.zip - extract it and copy the resource folder to the same folder level that of the /Files and /Objects folders of the B4A project.
You can download and test it but if you want to use it then you need to
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: AndroidVisionPhotoFaceDetector
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\resource
#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama
#Extends: android.support.v7.app.AppCompatActivity
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bm As Bitmap
Private fv1 As AndroidVisionFaceView
Private lv1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
lv1.SingleLineLayout.Label.TextSize = 15
lv1.SingleLineLayout.Label.TextColor = Colors.White
lv1.TwoLinesLayout.Label.TextSize = 15
lv1.TwoLinesLayout.Label.TextColor = Colors.white
bm.Initialize(File.DirAssets,"charlize.jpg")
fv1.Photo = bm
fv1.CircleColor = Colors.Magenta
fv1.CircleWidth = 3
fv1.CircleDiameter = 5
fv1.build
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub fv1_face_found(LandMarks As Object, IsLeftEyeOpenProbability As Float, IsRightEyeOpenProbability As Float, _
IsSmilingProbability As Float, EulerY As Float, EulerZ As Float, iD As Int)
lv1.AddSingleLine("face ID = " & iD)
lv1.AddTwoLines("IsLeftEyeOpenProbability:", "" & IsLeftEyeOpenProbability)
lv1.AddTwoLines("IsRightEyeOpenProbability:", "" & IsRightEyeOpenProbability)
lv1.AddTwoLines("IsSmilingProbability:", "" & IsSmilingProbability)
lv1.AddTwoLines("Rotation of face around vertical(Y) axis:", "" & EulerY)
lv1.AddTwoLines("Rotation of face around Z axis:", "" & EulerZ)
Dim mylist As List
mylist = LandMarks
For i = 0 To mylist.Size - 1
If mylist.Get(i) = "0" Then lv1.AddSingleLine("Landmark found at BOTTOM_MOUTH")
If mylist.Get(i) = "1" Then lv1.AddSingleLine("Landmark found at LEFT_CHEEK")
If mylist.Get(i) = "2" Then lv1.AddSingleLine("Landmark found at LEFT_EAR_TIP")
If mylist.Get(i) = "3" Then lv1.AddSingleLine("Landmark found at LEFT_EAR")
If mylist.Get(i) = "4" Then lv1.AddSingleLine("Landmark found at LEFT_EYE")
If mylist.Get(i) = "5" Then lv1.AddSingleLine("Landmark found at LEFT_MOUTH")
If mylist.Get(i) = "6" Then lv1.AddSingleLine("Landmark found at NOSE_BASE")
If mylist.Get(i) = "7" Then lv1.AddSingleLine("Landmark found at RIGHT_CHEEK")
If mylist.Get(i) = "8" Then lv1.AddSingleLine("Landmark found at RIGHT_EAR_TIP")
If mylist.Get(i) = "9" Then lv1.AddSingleLine("Landmark found at RIGHT_EAR")
If mylist.Get(i) = "10" Then lv1.AddSingleLine("Landmark found at RIGHT_EYE")
If mylist.Get(i) = "11" Then lv1.AddSingleLine("Landmark found at RIGHT_MOUTH")
Next
lv1.AddSingleLine("*********************************")
' AN EXPLANATION FOR THE LANDMARK STRING VALUES THAT ARE RETURNED TO THE B4A LIST
' Public static final int BOTTOM_MOUTH = 0;
' Public static final int LEFT_CHEEK = 1;
' Public static final int LEFT_EAR_TIP = 2;
' Public static final int LEFT_EAR = 3;
' Public static final int LEFT_EYE = 4;
' Public static final int LEFT_MOUTH = 5;
' Public static final int NOSE_BASE = 6;
' Public static final int RIGHT_CHEEK = 7;
' Public static final int RIGHT_EAR_TIP = 8;
' Public static final int RIGHT_EAR = 9;
' Public static final int RIGHT_EYE = 10;
' Public static final int RIGHT_MOUTH = 11;
End Sub
Library:
AndroidVisionFaceView
Author: Github: Clayton Wilkinson, Wrapped by: Johan Schoeman
Version: 1
AndroidVisionFaceView
Events:
- face_found (LandMarks As Object, IsLeftEyeOpenProbability As Float, IsRightEyeOpenProbability As Float, IsSmilingProbability As Float, EulerY As Float, EulerZ As Float, iD As Int)
- ALL_LANDMARKS As Int
- NO_LANDMARKS As Int
- ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
- SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
- build
- android.hardware.camera
- android.hardware.camera.autofocus
- android.permission.CAMERA
- android.permission.FLASHLIGHT
- android.permission.VIBRATE
- android.permission.WRITE_EXTERNAL_STORAGE
- Background As Drawable
- CircleColor As Int [write only]
- CircleDiameter As Int [write only]
- CircleWidth As Int [write only]
- Color As Int [write only]
- Enabled As Boolean
- Height As Int
- LandmarkType As Int [write only]
- Left As Int
- MinFaceSize As Float [write only]
- Parent As Object [read only]
- Photo As Bitmap [write only]
- ProminentFaceOnly As Boolean [write only]
- Tag As Object
- Top As Int
- Visible As Boolean
- Width As Int
Also important to note the B4A project's Manifest Files
And equally important to set your paths correctly (the below only applicable to my folder setup):
B4X:
#AdditionalRes: ..\resource[/I][/B]
[B][I]#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
Attachments
Last edited: