I'm trying to use Firebase's MLKit with unity, trying to use the face detection in my project. While sending a single image works, there is a high ping associated with the plugin call from unity and the time by which the callback actually returns the value. Is there any way to achieve a low latency solution for this, so that a reliable connection can be made?
Unity Code
public void AndroidRender() {
tex = new Texture2D(webcamTexture.width, webcamTexture.height);
textureHolder.GetComponent().texture = tex;
tex.SetPixels32(webcamTexture.GetPixels32());
tex.Apply();
byteObject.Call("passByteArray", colorBytes);
coordinates = byteObject.Call("getData");
}
Java code
public passByteArray(byte[] byteArray) {
if(gotData) {
return; //create new values only if previous one's have been consumed
}
//create bitmap
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inMutable = true;
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length, bitmapOptions);
bmp = rotateBitmap(bmp, 90);
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bmp);
//start detection
FirebaseVisionFaceDetector detector = FirebaseVision.getInstance()
.getVisionFaceDetector(options);
Task
- > result =
detector.detectInImage(image)
.addOnSuccessListener(
new OnSuccessListener
- >() {
@Override
public void onSuccess(List