react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

perspective (processTransform3d) not work

Open i7soft opened this issue 1 year ago • 0 comments

Description

I use skia with react-native-vision-camera, and want to Transform the video frame, rotateY is work, but perspective not work

Version

1.4.2

Steps to reproduce

1.use with react-native-vision-camera

2.on the camera frameProcessor event, try to Transform the video frame

Snack, code example, screenshot, or link to a repository

` import { Matrix4, PaintStyle, perspective, processTransform3d, processTransformProps, rotateX, scale, Skia,SkImage, TileMode } from '@shopify/react-native-skia'; import { useEffect } from 'react'; import { StyleSheet, Text } from 'react-native';

import {
    Camera,
    useCameraDevice,
    useCameraPermission,
    useSkiaFrameProcessor,
    useFrameProcessor
} from 'react-native-vision-camera';




export function CameraRealtimeDetection() {
    const device = useCameraDevice('back');
    const { hasPermission, requestPermission } = useCameraPermission();



    useEffect(() => {
        requestPermission();
    }, [requestPermission]);



    const frameProcessor2 = useSkiaFrameProcessor((frame) => {
        'worklet';

        var matrix = processTransform3d([
            { rotateY: 45 },       // work √
            { perspective: 100 },   // no work ×
        ])

    
        frame.concat(matrix)

        frame.render()
        
        
    }, []);

    if (!hasPermission) {
        return <Text>No permission</Text>;
    }

    if (device == null) {
        return <Text>No device</Text>;
    }

    return (
        <Camera
            style={[{height:300,width:200}]}
            device={device}
            isActive={true}
            frameProcessor={frameProcessor2}
        />
    );
}

`

i7soft avatar Oct 06 '24 12:10 i7soft