vision-camera-code-scanner icon indicating copy to clipboard operation
vision-camera-code-scanner copied to clipboard

stop continuous scanning qrcode and display the frame image

Open jochenshi opened this issue 2 years ago • 6 comments

Hi, is there any way to stop the camera and set the captured image fixed on screen after the qrcode is scanned and stop scanning qrcode again only when manually reactivated it?

jochenshi avatar May 05 '22 02:05 jochenshi

I guess if you use the active on the <Camera active={isActive}> property you can achieve this? You would then in the frameprocessor do setActive(false) and the camera will stop (and the frame will lock)

frankbolviken avatar May 25 '22 07:05 frankbolviken

The solution is to use useSharedValue hook from react-native-reanimated to sync frame processors.

infastin avatar Oct 19 '22 23:10 infastin

@infastin can you please describe how to do it with this hook?

fdelavra avatar Nov 04 '22 21:11 fdelavra

@fdelavra Something like this:

const barcodeScanned = useSharedValue(false);

const frameProcessor = useFrameProcessor((frame) => {
	"worklet"
	...
	if (barcodeScanned.value) {
		return;
	}
	
	barcodeScanned.value = true;
	...
});

infastin avatar Nov 06 '22 06:11 infastin

@infastin Thanks ;)

fdelavra avatar Nov 06 '22 10:11 fdelavra