Open kHanHnq4901 opened 1 month ago
Guten Tag, Hans here! 🍻
It looks like you are experiencing a runtime issue with your application closing due to a JNI error. Thank you for providing the logs, they're quite helpful. A maximum of 51200 global references indicates a possible memory leak in your frame processing.
However, I notice that you didn't try to reproduce the issue in the VisionCamera Example app. This step is essential to help mrousavy pinpoint whether the problem lies within your code or the library itself.
Please try to replicate the issue there, and if it persists, feel free to provide additional details about your implementation and we will investigate further.
And remember, if you want to ensure swift attention to such issues, consider supporting the project by becoming a sponsor! Check out sponsorship options here.
Looking forward to your update!
Note: If you think I made a mistake, please ping
@mrousavy
to take a look.
source
// Bộ xử lý khung
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet';
// Hàm xử lý OpenCV
const openCvWorklet = (frame: FrameInternal) => {
'worklet'; // Đánh dấu hàm này là worklet
try {
frame.incrementRefCount();
const map = openCv(frame); // Giả định openCv là hàm xử lý OpenCV
return map;
} finally {
frame.decrementRefCount();
}
};
// Hàm vẽ trên khung hình
const drawOnFrame = (map: object) => {
'worklet'; // Đánh dấu hàm này là worklet
if (!map) return;
frame.render(); // Render the frame before drawing
const paint = Skia.Paint();
paint.setColor(Skia.Color('red'));
frame.drawLine(map.center_x - 10, map.center_y, map.center_x + 10, map.center_y, paint);
frame.drawLine(map.center_x, map.center_y - 10, map.center_x, map.center_y + 10, paint);
if (map.ptAx) {
const paintRed = Skia.Paint();
paintRed.setColor(Skia.Color('red'));
const paintYellow = Skia.Paint();
paintYellow.setColor(Skia.Color('yellow'));
const paintBlue = Skia.Paint();
paintBlue.setColor(Skia.Color('blue'));
const paintBlack = Skia.Paint();
paintBlack.setColor(Skia.Color('black'));
frame.drawLine(map.ptAx, map.ptAy, map.ptBx, map.ptBy, paintRed);
frame.drawLine(map.ptAx, map.ptAy, map.ptCx, map.ptCy, paintYellow);
frame.drawLine(map.ptBx, map.ptBy, map.ptCx, map.ptCy, paintBlue);
frame.drawLine(map.ptIx, map.ptIy, map.ptCx, map.ptCy, paintBlack);
}
};
// Gọi hàm xử lý OpenCV và vẽ trên khung hình
const nativeBuffer = frame.getNativeBuffer(); // Lưu trữ nativeBuffer
const map = openCvWorklet(frame); // Gọi hàm xử lý OpenCV
// Vẽ trên khung hình
drawOnFrame(map);
const image = Skia.Image.MakeImageFromNativeBuffer(nativeBuffer.pointer);
image.dispose();
// Xóa buffer sau khi hoàn tất
nativeBuffer.delete();
}, []); <Camera key={cameraKey} style={StyleSheet.absoluteFill} device={device} isActive={isActive} zoom={zoom ? 7 : 1} frameProcessor={frameProcessor} enableFpsGraph={true} format={format} fps={[minFps, maxFps]} enableBufferCompression = {true}/>
@mrousavy
What's happening?
Reproduceable Code
Relevant log output
Camera Device
Device
Samsung Galaxy A03s
VisionCamera Version
4.5.3
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (⚠️ your issue might get ignored & closed if you don't try this)
Additional information