Last active
January 8, 2020 09:37
-
-
Save BoHellgren/93f43d374526be4681e4fb200013ac9c to your computer and use it in GitHub Desktop.
_findDog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<Map> _findDog(CameraImage image) async { | |
List resultList = await Tflite.detectObjectOnFrame( | |
bytesList: image.planes.map((plane) { | |
return plane.bytes; | |
}).toList(), | |
model: "SSDMobileNet", | |
imageHeight: image.height, | |
imageWidth: image.width, | |
imageMean: 127.5, | |
imageStd: 127.5, | |
threshold: 0.2, | |
); | |
List<String> possibleDog = ['dog', 'cat', 'bear', 'teddy bear', 'sheep']; | |
Map biggestRect; | |
double rectSize, rectMax = 0.0; | |
for (int i = 0; i < resultList.length; i++) { | |
if (possibleDog.contains(resultList[i]["detectedClass"])) { | |
Map aRect = resultList[i]["rect"]; | |
rectSize = aRect["w"] * aRect["h"]; | |
if (rectSize > rectMax) { | |
rectMax = rectSize; | |
biggestRect = aRect; | |
} | |
} | |
} | |
return biggestRect; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment