I am trying to utilize some python scripts in an Android Application (Java). I have configured Chaquopy following the instructions on their website. https://chaquo.com/chaquopy/doc/current/android.html
I have found an example of how to execute python scripts in a Kotlin application but I am struggling to figure this out in Java.
If I understand correctly, the python script (.py) is stored in src/main/python and one can call this script from another activity and display the results in that same calling activity.
The example in Kotlin:
val python = Python.getInstance()
val pythonFile = python.getModule("helloworldscript")
val helloWorldString = pythonFile.callAttr("helloworld")
hello_textview.text = helloWorldString.toString()
I want to execute the following python script:
import os
import face_recognition
def cmd2():
os.system("face_recognition ./event_faces/ ./event_images/")
This commandline tool from face_recognition allows the user to run facial recognition on a directory of images and compares them to a directory of known faces. The result is a printout of the files processed with any known or unknown faces being appended to the filename.

My Goal is to execute this python script and display the output in the activity (i.e textView) Does anyone know if it is possible to use face_recognition in Android Studio with Chaquopy? It is not listed so I am having some doubts https://chaquo.com/pypi-7.0/ Is it possible to make os. type calls in android application?
ADDITIONALLY If anyone is aware of a way to perform facial recognition on a directory of images in Java without using python's face_recognition, please let me know. I have attempted find a library like face_recognition for java but have not been successful. The face_recognition library from Python has been working very well for me but now as I am trying to port my python scripts into a Android Studio project things are becoming a little tricky.
My code thus far: Android Manifest
<application
android:name="com.chaquo.python.android.PyApplication"
app Gradle
apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'
android {
compileSdkVersion 29
defaultConfig {
python{
staticProxy "bulk.py"
pip{
install "dlib"
install "opencv-python"
install "opencv-contrib-python"
install "face_recognition"
install "pillow"
install "numpy"
install "cv2"
install "os"
}
}
applicationId "com.projectdevelopment.faces"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
project gradle
buildscript {
repositories {
google()
jcenter()
maven { url "https://chaquo.com/maven" }
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
classpath 'com.google.gms:google-services:4.3.3'
classpath "com.chaquo.python:gradle:8.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Activity executing the Python script
python.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//call python script and return output to this activity
}
});