checkForCavity method
Implementation
@override
Future<bool> checkForCavity(File image) async {
const cavityUrl =
'https://dentalprediction-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/b874109f-ffeb-428f-a30b-a9db47b75f26/classify/iterations/Iteration1/image';
final cavityHeaders = {
'Prediction-Key': '6c41e9fb16f64bf39c334fb6ae1761bc',
'Content-Type': 'application/octet-stream',
};
var cavityBytes = await image.readAsBytes();
var cavityResponse = await http.post(
Uri.parse(cavityUrl),
headers: cavityHeaders,
body: cavityBytes,
);
if (cavityResponse.statusCode == 200) {
var cavityData = jsonDecode(cavityResponse.body);
bool hasCavity = cavityData['hasCavity'] ?? false;
return hasCavity;
} else {
throw Exception('Failed to check for cavity');
}
}