File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed
apps/computer-vision/app/vision_camera
packages/react-native-executorch/src/modules/computer_vision Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ module.exports = {
3232 customWordListFile : path . resolve ( __dirname , '.cspell-wordlist.txt' ) ,
3333 } ,
3434 ] ,
35- 'camelcase' : 'error' ,
35+ 'camelcase' : [ 'error' , { properties : 'never' } ] ,
3636 } ,
3737 plugins : [ 'prettier' , 'markdown' ] ,
3838 overrides : [
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 View ,
1616} from 'react-native' ;
1717import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
18+ import { useIsFocused } from '@react-navigation/native' ;
1819import {
1920 Camera ,
2021 Frame ,
@@ -235,6 +236,7 @@ export default function VisionCameraScreen() {
235236 const [ fps , setFps ] = useState ( 0 ) ;
236237 const [ frameMs , setFrameMs ] = useState ( 0 ) ;
237238 const lastFrameTimeRef = useRef ( Date . now ( ) ) ;
239+ const isFocused = useIsFocused ( ) ;
238240 const cameraPermission = useCameraPermission ( ) ;
239241 const devices = useCameraDevices ( ) ;
240242 const device =
@@ -461,7 +463,7 @@ export default function VisionCameraScreen() {
461463 style = { StyleSheet . absoluteFill }
462464 device = { device }
463465 outputs = { [ frameOutput ] }
464- isActive = { true }
466+ isActive = { isFocused }
465467 format = { format }
466468 orientationSource = "interface"
467469 />
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { VisionModule } from './VisionModule';
1010 *
1111 * @category Typescript API
1212 */
13- export class StyleTransferModule extends VisionModule < PixelData > {
13+ export class StyleTransferModule extends VisionModule < PixelData | string > {
1414 /**
1515 * Loads the model, where `modelSource` is a string that specifies the location of the model binary.
1616 * To track the download progress, supply a callback function `onDownloadProgressCallback`.
@@ -41,4 +41,13 @@ export class StyleTransferModule extends VisionModule<PixelData> {
4141 throw parseUnknownError ( error ) ;
4242 }
4343 }
44+
45+ async forward < O extends 'pixelData' | 'url' = 'pixelData' > (
46+ input : string | PixelData ,
47+ output ?: O
48+ ) : Promise < O extends 'url' ? string : PixelData > {
49+ return super . forward ( input , output === 'url' ) as Promise <
50+ O extends 'url' ? string : PixelData
51+ > ;
52+ }
4453}
Original file line number Diff line number Diff line change @@ -127,7 +127,6 @@ export abstract class VisionModule<TOutput> extends BaseModule {
127127 RnExecutorchErrorCode . ModuleNotLoaded ,
128128 'The model is currently not loaded. Please load the model before calling forward().'
129129 ) ;
130-
131130 // Type detection and routing
132131 if ( typeof input === 'string' ) {
133132 return await this . nativeModule . generateFromString ( input , ...args ) ;
You can’t perform that action at this time.
0 commit comments