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

Star-Dust

Expert
Licensed User
Longtime User
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....):
View attachment 65894

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

Thanks, it's very beautiful.
It seems that it uses google augmented reality APIs, so it has features like face detection and its landmarks.
Does this enclosure contain all the functions of the original library?
And the most important question, who is that unknown in photos?
 

Johan Schoeman

Expert
Licensed User
Longtime User

LucaMs

Expert
Licensed User
Longtime User
...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.


...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
 

Johan Schoeman

Expert
Licensed User
Longtime User
...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.


...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
Sure you have both these folders in your B4A project where the resources are loaded from...
B4X:
#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\resource
 

Johan Schoeman

Expert
Licensed User
Longtime User
...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.


...\FaceSpotter\b4aFaceSpotter\Objects\bin\extra\res1\res\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
It is also working on a KitKat device....
 

Johan Schoeman

Expert
Licensed User
Longtime User
Tried copying AppCompat also to the internal libraries folder... same error.
Try with the attached lib files (just make sure you "clean" your B4A project before compiling it - Tools ---> Clean project).
 

Attachments

  • FaceSpotter.jar
    28.9 KB · Views: 213
  • FaceSpotter.xml
    1.8 KB · Views: 207

Johan Schoeman

Expert
Licensed User
Longtime User
1/2. It can be installed, starts but does nothing, except allowing you to switch camera.
Do you have an Internet connection enabled on your device? It needs an initial internet connection for the dependencies to be downloaded and installed. Once downloaded you don't need an Internet connection any longer. The graphics should automatically start to display once the dependencies have been downloaded and installed.
 
Top