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
import React, { Component } from 'react'; | |
import { | |
Platform, | |
StyleSheet, | |
Text, | |
View | |
} from 'react-native'; | |
const BEST_MATCH_THRESHOLD = 0.5; |
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
const BEST_MATCH_THRESHOLD = 0.5; |
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
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: 'transparent', | |
}, | |
info: { | |
fontSize: 20, | |
color: "#ffffff", |
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
constructor(props) { | |
super(props); | |
this.state = { | |
bestMatch: null | |
}; | |
} |
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
[ | |
{identifier: "hotdog", confidence: 0.6}, | |
{identifier: "not-hotdog", confidence: 0.002} | |
] |
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
onClassification(classifications) { | |
var bestMatch = null; | |
if (classifications && classifications.length > 0) { | |
// Loop through all of the classifications and find the best match | |
classifications.forEach((classification) => { | |
if (!bestMatch || classification.confidence > bestMatch.confidence) { | |
bestMatch = classification; | |
} | |
}); |
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
render() { | |
var classification = null; | |
if (this.state.bestMatch) { | |
if (this.state.bestMatch && this.state.bestMatch.identifier && this.state.bestMatch.identifier == "hotdog") { | |
classification = "🌭 Hot Dog 🌭"; | |
} else { | |
classification = "Not hot dog"; | |
} |
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
import CoreMLImage from "react-native-core-ml-image" |
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
npm install react-native-core-ml-image --save | |
react-native link react-native-core-ml-image |
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
renderRow: function(foodItem) { | |
return ( | |
<Text>{foodItem.name}</Text> | |
) | |
}, | |
renderSectionHeader: function(sectionData, category) { | |
return ( | |
<Text style={{fontWeight: "700"}}>{category}</Text> | |
) |
NewerOlder