Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Red channel is ALWAYS 255 #108

Open
Open
@Jashtezakonshem

Description

Hello, I'm trying to extract RGB channels from each frame and I need to get mean and stdDev for each channel. my processFrame function is pretty straightforward but I can't figure out why is not working and what I'm doing wrong.

I'm using expo@53 with react-native@0.79.6

`
const processFrame = useFrameProcessor(async (frame) => {
"worklet";
const enough = measurements.value.length >= 450; // 15 seconds at 30 fps
if (enough) {
await stopMeasurements();
return;
}

const height = frame.height / 2;
const width = frame.width / 2;
const resized = resize(frame, {
 scale: {
 width: width,
 height: height,
 },
 pixelFormat: "rgb",
 dataType: "uint8",
});
// Convert buffer to Mat
const source = OpenCV.bufferToMat("uint8", height, width, 3, resized);
// Split into RGB channels
const red = OpenCV.createObject(ObjectType.Mat, height, width, DataTypes.CV_8U);
const green = OpenCV.createObject(ObjectType.Mat, height, width, DataTypes.CV_8U);
const blue = OpenCV.createObject(ObjectType.Mat, height, width, DataTypes.CV_8U);
OpenCV.invoke("extractChannel", source, red, 0);
OpenCV.invoke("extractChannel", source, green, 1);
OpenCV.invoke("extractChannel", source, blue, 2);
const redMeanScalar = OpenCV.invoke("mean", red);
const greenMeanScalar = OpenCV.invoke("mean", green);
const blueMeanScalar = OpenCV.invoke("mean", blue);
const redMean = OpenCV.toJSValue(redMeanScalar);
const greenMean = OpenCV.toJSValue(greenMeanScalar).a;
const blueMean = OpenCV.toJSValue(blueMeanScalar).a;
console.log({ redMean, greenMean, blueMean });
OpenCV.clearBuffers();

}, []);
`

and this is my Camera component:

<Camera device={device} format={format} fps={30} isActive={active} style={styles.camera} torch={torch} frameProcessor={processFrame} pixelFormat={"rgb"} />
tried to inspect FOCV_Function.cpp but the invocation of open cv is pretty linear cv::meanStdDev(*src, *mean, *stddev, *mask);

any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /