adamgf / react-native-opencv3-tests

Sample react native apps that expose OpenCV functionality on both iOS and Android
Other
19 stars 14 forks source link

Pausing Recognition and Displaying Alert Mesage #119

Open iuri opened 2 years ago

iuri commented 2 years ago

Hello there, How would we pause openCV engine on real time, show an Alert message within a button whether to "Exit" or "scan" to keep scanning faces? As the screenshot attached shows

Best wishes, I

IMG_1462 WhatsApp Image 2021-12-29 at 12 29 49

iuri commented 2 years ago

Hi there, Searching for ideas within node-modules/react-native-opencv3, I found within the IOS library file /ios/CvCamera.mm, a chunk of code, which calls [videoCamera stop].

file /ios/CvCamera.mm ''''

That, made me wonder if and how I could use the same directives to stop/start Camera, while displaying Alert message, and: i. if the user chooses Exit, it would leave the Screen and the whole process stops ii. else if the user selects "Scan", then another command is executed (i.e. [videoCamera start]) and the mechanism continues to scan Faces again. Then, Alert.alert() would not show in the screen repeated infinetly .

Some sort of code as in the example below: '''' +++ (void)CameraStop:(NSNotification )notification { [videoCamera stop]; } +++ (void)CameraStart:(NSNotification )notification { [videoCamera start]; } ''''

... CvCamera.CameraStop(); Alert.alert( 'Check!', 'Face successfully scanned!', [{ text: 'Exit', onPress: () => { this.props.navigation.navigate('Home'); }, style: 'cancel' }, { text: 'Scan', onPress: () => { CvCamera.CameraStop(); } },],{cancelable: false } );

...