Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
const BEST_MATCH_THRESHOLD = 0.5;
@darylrowland
darylrowland / App.js
Created December 21, 2017 13:48
BEST_MATCH_THRESHOLD
const BEST_MATCH_THRESHOLD = 0.5;
@darylrowland
darylrowland / App.js
Created December 21, 2017 13:46
Styles
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'transparent',
},
info: {
fontSize: 20,
color: "#ffffff",
constructor(props) {
super(props);
this.state = {
bestMatch: null
};
}
[
{identifier: "hotdog", confidence: 0.6},
{identifier: "not-hotdog", confidence: 0.002}
]
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;
}
});
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";
}
@darylrowland
darylrowland / App.js
Last active December 21, 2017 13:51
import react-native-coreml-image
import CoreMLImage from "react-native-core-ml-image"
@darylrowland
darylrowland / install-component
Last active December 21, 2017 13:51
react-native-coreml-image article gists
npm install react-native-core-ml-image --save
react-native link react-native-core-ml-image
@darylrowland
darylrowland / rowAndSectionHeaderRender.js
Created January 11, 2016 12:27
Row and Section Header render
renderRow: function(foodItem) {
return (
<Text>{foodItem.name}</Text>
)
},
renderSectionHeader: function(sectionData, category) {
return (
<Text style={{fontWeight: "700"}}>{category}</Text>
)