mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.3k stars 1.07k forks source link

💭 #3165

Closed moloudayat closed 2 weeks ago

moloudayat commented 2 weeks ago

Question

my camera doesn't cover the entier screen.

What I tried

I want to have a screen that can scan the barcode. Unfortunately, my camera only shows in a square box and the other part of the screen is black. this is my code:

const BarcodeScanner: React.FC<Navigation> = props => {

   const device = useCameraDevice('back')
   const codeScanner = useCodeScanner({
        codeTypes: [
            'code-128'
            , 'code-39'
            , 'code-93'
            , 'codabar'
            , 'ean-13'
            , 'ean-8'
            , 'itf'
            , 'upc-e'
            , 'upc-a'
            , 'qr'
            , 'pdf-417'
            , 'aztec'
            , 'data-matrix'

        ],
        onCodeScanned: (codes: Code[], frame: CodeScannerFrame) => {
            if (codes.length > 0) {
                onSelect(codes[0].value)
                navigation.goBack()
            }
        }
    });

    return device !== null ? (
        <StandalonePage
            title={t("common.barcodeScanner")}
            onBack={handleBackPress}
            navigation={props.navigation}>
            <Camera
                style={StyleSheet.absoluteFill}
                device={device}
                isActive={true}
                codeScanner={codeScanner}
                torch={isFlashOn ? "on" : "off"}/>
            <View style={styles.topRight} />
            <View style={styles.topLeft} />
            <View style={styles.bottomRight} />
            <View style={styles.bottomLeft} />
            <TouchableOpacity
                style={styles.imgContainer}
                onPress={toggleFlash}>
                <Image
                    style={styles.img}
                    source={isFlashOn ? FlashOff : FlashOn} />
            </TouchableOpacity>
        </StandalonePage>
    )
        : null
}

and this is what happened I used resizeMode="cover" but the result didn't change.

Screenshot_1725098994

VisionCamera Version

4.5.2

Additional information

maintenance-hans[bot] commented 2 weeks ago

Guten Tag, Hans here! 🍻

It looks like you are experiencing an issue with ze camera not covering ze entirety of ze screen. However, I noticed that ze issue might be more related to your implementation rather than a bug in ze library.

Have you tried adjusting ze dimensions directly in your Camera component or checking ze aspect ratio? Also, please remember to provide relevant logs if you encounter any runtime errors. To gather logs on Android, you can use adb logcat from your terminal, and for iOS, you can check ze Xcode logs.

If you continue to have issues, please let us know with clear details and logs! And if you want mrousavy to take a closer look, consider sponsoring ze project for more immediate support: Sponsor mrousavy.

Note: If you think I made a mistake, please ping @mrousavy to take a look.

moloudayat commented 2 weeks ago

How can I adjust the dimensions in my Camera component and check for aspect ratio?

mrousavy commented 2 weeks ago

No title.