I new in flutter and I want to count the frequency of blinks in the user's eyes. I use startImageStream to get the image and mlkit. this is my code:
await cameraController.startImageStream((CameraImage img) =>
_proccessImageToBlinking(img));
void _proccessImageToBlinking(CameraImage img) async {
int numOfEyesBlink = 0;
VisionFaceDetectorOptions options = new VisionFaceDetectorOptions(
modeType: VisionFaceDetectorMode.Accurate,
landmarkType: VisionFaceDetectorLandmark.None,
classificationType: VisionFaceDetectorClassification.All,
minFaceSize: 0.1,
isTrackingEnabled: true);
FirebaseVisionFaceDetector faceDetector = FirebaseVisionFaceDetector
.instance;
var imgByte = img.planes.map((plane) {return plane.bytes;}).toList().first;
List<VisionFace> face = await faceDetector.detectFromBinary(imgByte, options);
if (!face[0].hasLeftEyeOpenProbability &&
!face[0].hasRightEyeOpenProbability) {
numOfEyesBlink++;
print("blinking");
}
}
The code is broken in this line:
List<VisionFace> face = await faceDetector.detectFromBinary(imgByte, options);
in services\binding in line ByteData? response; I think it has to do with the way the imgByte comes, but I could not understand why. I also get this line all the time in consola -
Background concurrent copying GC freed 2456(184KB) AllocSpace objects, 69(4676KB) LOS objects, 49% free, 5132KB/10MB, paused 4.580ms total 185.865ms
How can I fix this?