-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use cv model 2.13, requires newer plugin * Bump version and build * Use cv model 2.13, requires newer plugin * Bump version and build * Use vision-plugin with speedup by taxonomy cutoff * Bump build * Bundle update * Redo bundle with deleted Gemfile.lock * Update plugin. Add option to set cutoff from JS * Cycle through different taxonomy cutoffs * Bump build * Update vision plugin * Change cycle back to one cutoff value only * Bump build * Show correct about text, and not missing translation Closes #713 * Use history for going back in navigation Closes #715 Closes #675 * Bump build * Update vision-plugin * Add a bit of padding to bottom of challenges screen * Bump build * Update with stable cv plugin * Log timeElapsed for cv on native side * Bump build * Comment * Update README.md * Use stable vc plugin main Technically this means we now support geomodel on iOS. We would need to add it to the app an connect to the frame processor though. * Bump build * Update vision-plugin * Bump build * Remove taxonomy cutoff override Now it uses the plugin's inbuilt taxonomy cutoff of 0.001 the top cv score. * Remove timesRun state * Bump build * Card that announces the new cv model on the home screen (#717) * Fix vision plugin to version commit on main there * Update Podfile.lock * Basic version of the updates card * Count how many species are in cv 2.13 * Looks nicer * Bump build * Revert back to storing only five results at a time * Bump build * Update vision-plugin to use new names for options No change in Seek required * Hardcode to never show a specific taxon * Bump build * Update package.json * Remove deprecated model files; Use model on iOS directly from bundle * Bump build * Update fastlane * modelFileNames TS * Update config.example.js * Geomodel into XCode project * dirStorage TS, plus geomodel * Refactor camera files helpers into own file * Update import * Update vision-plugin * Prop geomodel path into camera * Use location from species nearby provider for the geomodel
- Loading branch information
Showing
12 changed files
with
184 additions
and
113 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { Alert, Platform } from "react-native"; | ||
import RNFS from "react-native-fs"; | ||
|
||
import i18n from "../i18n"; | ||
import { dirModel, dirGeomodel, dirTaxonomy } from "./dirStorage"; | ||
import modelFiles from "../constants/modelFileNames"; | ||
|
||
const addCameraFilesAndroid = () => { | ||
const copyFilesAndroid = ( source: string, destination: string ) => { | ||
RNFS.copyFileAssets( source, destination ).then( ( _result ) => { | ||
console.log( `moved file from ${source} to ${destination}` ); | ||
} ).catch( ( error ) => { | ||
console.log( error, `error moving file from ${source} to ${destination}` ); | ||
} ); | ||
}; | ||
|
||
RNFS.readDirAssets( "camera" ).then( ( results ) => { | ||
const model = modelFiles.ANDROIDMODEL; | ||
const geomodel = modelFiles.ANDROIDGEOMODEL; | ||
const taxonomy = modelFiles.ANDROIDTAXONOMY; | ||
|
||
const hasModel = results.find( ( r ) => r.name === model ); | ||
const hasGeoModel = results.find( ( r ) => r.name === geomodel ); | ||
|
||
// Android writes over existing files | ||
if ( hasModel !== undefined ) { | ||
console.log( "Found model asset with filename", model ); | ||
copyFilesAndroid( `camera/${model}`, dirModel ); | ||
copyFilesAndroid( `camera/${taxonomy}`, dirTaxonomy ); | ||
} else { | ||
console.log( "No model asset found to copy into document directory." ); | ||
Alert.alert( | ||
i18n.t( "model.not_found_error" ), | ||
i18n.t( "model.not_found_error_description" ) | ||
); | ||
} | ||
if ( hasGeoModel !== undefined ) { | ||
console.log( "Found geomodel asset with filename", geomodel ); | ||
copyFilesAndroid( `camera/${geomodel}`, dirGeomodel ); | ||
} else { | ||
console.log( "No geomodel asset found to copy into document directory." ); | ||
} | ||
} ); | ||
}; | ||
|
||
const checkForModelFileIOS = () => { | ||
RNFS.readDir( RNFS.MainBundlePath ).then( ( results ) => { | ||
const model = modelFiles.IOSMODEL; | ||
const hasModel = results.find( ( r ) => r.name === model ); | ||
if ( hasModel !== undefined ) { | ||
console.log( "Found model asset with filename", model ); | ||
} else { | ||
console.log( "No model asset found to copy into document directory." ); | ||
Alert.alert( | ||
i18n.t( "model.not_found_error" ), | ||
i18n.t( "model.not_found_error_description" ) | ||
); | ||
} | ||
} ); | ||
}; | ||
|
||
const removeDeprecatedModelFilesIOS = () => { | ||
// On releasing cv model 2.13 (the second one ever), we changed the app to use the model | ||
// from the main bundle directly instead of the document directory. This function removes all | ||
// existing model files from the document directory. | ||
RNFS.readDir( RNFS.DocumentDirectoryPath ).then( ( results ) => { | ||
results.forEach( ( result ) => { | ||
if ( result.name.includes( ".mlmodelc" ) || result.name.includes( "taxonomy" ) ) { | ||
RNFS.unlink( `${RNFS.DocumentDirectoryPath}/${result.name}` ).then( () => { | ||
console.log( "Removed deprecated model file: ", result.name ); | ||
} ).catch( ( error ) => { | ||
console.log( error, "error removing deprecated model file" ); | ||
} ); | ||
} | ||
} ); | ||
} ); | ||
}; | ||
|
||
const removeDeprecatedModelFilesAndroid = () => { | ||
RNFS.readDir( RNFS.DocumentDirectoryPath ).then( ( results ) => { | ||
results.forEach( ( result ) => { | ||
if ( result.name === modelFiles.ANDROIDMODEL || result.name === modelFiles.ANDROIDTAXONOMY ) { | ||
console.log( "Not removing model asset with filename", result.name ); | ||
return; | ||
} | ||
if ( result.name.includes( ".tflite" ) || result.name.includes( ".csv" ) ) { | ||
RNFS.unlink( `${RNFS.DocumentDirectoryPath}/${result.name}` ).then( () => { | ||
console.log( "Removed deprecated model file: ", result.name ); | ||
} ).catch( ( error ) => { | ||
console.log( error, "error removing deprecated model file" ); | ||
} ); | ||
} | ||
} ); | ||
} ); | ||
}; | ||
|
||
const addARCameraFiles = async () => { | ||
if ( Platform.OS === "android" ) { | ||
removeDeprecatedModelFilesAndroid(); | ||
addCameraFilesAndroid(); | ||
} else if ( Platform.OS === "ios" ) { | ||
removeDeprecatedModelFilesIOS(); | ||
checkForModelFileIOS(); | ||
} | ||
}; | ||
|
||
export { | ||
addARCameraFiles | ||
}; |
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
Oops, something went wrong.