B4A Library FaceSpotter

A shortcut wrap for this project that I found on the web. Download FaceSpotterOtherLibFiles.zip from the link below and then copy the extracted jars to your additional library folder.

https://drive.google.com/open?id=1gbO9xKOv1Y8zaDcs8ogbGxf2g4pWhk--

Attached the following:
1. zipped B4A project
2. resource.zip - extract it and the copy folder "resource" including its contents to be on the same efolder level as that of the /Files and /Objects folder of the B4A project
3. DemoRes.zip - extract it and the copy folder "DemoRes" including its contents to be on the same efolder level as that of the /Files and /Objects folder of the B4A project
4. b4aFaceSpotterLibFiles.zip - extract the jar and the xml and copy them to your additional library folder.

Take note of the B4A manifest file:

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aFaceSpotter
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\resource

#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 fc As FaceSpotter

    Private Button1 As Button
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")
    fc.Initialize("")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    
    fc.BeginScan
    
End Sub

B4A Manifest File contents:
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
AddApplicationText(<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="barcode" />
        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="ocr" />       
        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="face" />                   
        <activity android:name="com.raywenderlich.facespotter.FaceActivity"
            android:screenOrientation="portrait" android:configChanges="orientation|keyboardHidden">
        </activity>)   
AddPermission(android.permission.CAMERA) ' Required to be able to access the camera device.       
AddPermission(android.permission.GET_TASKS)
AddPermission("android.hardware.camera")
AddPermission("android.permission.FLASHLIGHT")

You should see something like this (obviously with your own face....):
1.png


It was done with B4A V7.80 on an Android 7.0 device.
 

Attachments

  • resource.zip
    423 bytes · Views: 321
  • b4aFaceSpotter.zip
    8.3 KB · Views: 316
  • b4aFaceSpotterLibFiles.zip
    26.6 KB · Views: 304
  • DemoRes.zip
    253.9 KB · Views: 311

Johan Schoeman

Expert
Licensed User
Longtime User
No, I did not have it; now it (your apk, of course) works perfectly (and eyes, nose, moustache adapt to the size of the (my) face at runtime. Just the hat is ever too small for my big head :p)
So, the problem with not being able to compile the B4A code must have something to do with your vs my installation of the Android SDK. Not sure what the answer is....
 

Johan Schoeman

Expert
Licensed User
Longtime User
... and just for fun!

But now... I'm thinking to an app that... who knows.

[Of course, if I will develop it, I will make the right donation to the great Johan ;)]
Have you noticed that if you do a big smile while the "scanner" is active that the graphics over the eyes turn into "stars"....
 

LucaMs

Expert
Licensed User
Longtime User
Have you noticed that if you do a big smile while the "scanner" is active that the graphics over the eyes turn into "stars"
No, I had not noticed (I do not have many reasons to smile :p:(). Now I saw.

But I noticed closed virtual eyes that are not due to real eyes really closed.

Something like:
upload_2018-3-26_18-26-17.png




[I noticed also that a my old b4a client does not work, now :D:(:(:(]
 

Johan Schoeman

Expert
Licensed User
Longtime User
No, I had not noticed (I do not have many reasons to smile :p:(). Now I saw.

But I noticed closed virtual eyes that are not due to real eyes really closed.

Something like:
View attachment 65930



[I noticed also that a my old b4a client does not work, now :D:(:(:(]
It reacts to what extent your eye(s) are opened or closed. Test it by closing your eyes until you can just see. The graphic will change. Put a big smile (show some serious white teeth) on your face and the stars will appear in your eyes.
 

Johan Schoeman

Expert
Licensed User
Longtime User
OK - you can take a picture and it will be stored with the graphic overlays. It will be stored in your device's File.DirRootExternal folder. Click on the bottom right button to take a picture.

Extract the B4A lib files from attached b4aFaceSpotterLibFiles.zip and copy them to your additional library folder.
Read post #1 to see what to do with attached resource.zip and DemoRes.zip - sure you will figure it out.

Use the attached B4A project - it is in b4aFaceSpotter.zip

You will still need to download and extract "the other lib files" as per post #1 of this thread and then copy them to your additional libs folder.


See button to take picture at bottom right....(the pic below is a picture of my other twin brother :cool:)
3.png
 

Attachments

  • b4aFaceSpotterLibFiles.zip
    31.6 KB · Views: 242
  • b4aFaceSpotter.zip
    8.4 KB · Views: 205
  • DemoRes.zip
    460.1 KB · Views: 210
  • resource.zip
    423 bytes · Views: 195
Last edited:

Johan Schoeman

Expert
Licensed User
Longtime User
With android 13 device and with targetSDK set to 34 - this is working:

Code for Android 13 and targetSDK 34:
#Region  Project Attributes
    #ApplicationLabel: b4aFaceSpotter
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #MultiDex: True
#End Region

#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\resource

#AdditionalJar: com.google.android.gms:play-services-code-scanner
#AdditionalJar: kotlin-stdlib-1.6.10
#AdditionalJar: androidx.arch.core:core-runtime
#AdditionalJar: androidx.resourceinspection:resourceinspection-annotation
#AdditionalJar: androidx.transition:transition-ktx
#AdditionalJar: androidx.emoji2:emoji2

'#AdditionalJar: com.android.support:appcompat-v7

#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 fc As FaceSpotter

    Private Button1 As Button
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")
    fc.Initialize("")
    Log(File.DirRootExternal)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
    
    fc.BeginScan
    
End Sub
 
Top