Add preview processing capability and crop preview
Closed this issue ยท 2 comments
Hey,
I am working on a KMP compose app where I need a barcode scanner.
For camera preview, I could use this lib. But I need to be able to:
- process each frame
- be able to have a barcode frame for processing (still not sure if this cropping has to be processed before outputting a
ByteArray
, or it can be calculated after)
I guess a simpler way would be to expose another callback onFrame
, similar to onCapture
. Just not sure about a performance. Or some sort of stream of ByteArray (coroutines Flow '<ByteArray'> ?).
2 questions:
- would you accept such contribution?
- any suggestions/pointers on the topic?
Thanks in advance ๐
Hello @deividasstr thanks for good suggestion! ๐๐ป
I think it should be needed @onseok's opinion, but I'll answer in terms of mine. Also since I'm Android developer, I can't give you advices of implementation in iOS env.
In this case, Rect(struct that represents area you want to crop) parameter should be passed and onFrame(type that I think is (ImageIntermediateResult(wrapping ImageProxy of camerax)) -> Unit
is proper) also should be passed i think.
But this way is too android-istic way so I want to suggest get feedbacks to you or @onseok.
Thanks for suggest good feature one more time ๐
would you accept such contribution?
Hi @deividasstr, your contribution to this library regarding barcode scanning feature would be highly welcome!
any suggestions/pointers on the topic?
In addition to the onFrame
callback approach suggested by @l2hyunwoo for enhancing the Android module, I think for Android, leveraging the CameraX
is a robust way to implement real-time frame processing for barcode scanning. The use of ImageAnalysis with a custom analyzer allows for processing each frame from the camera feed. This analyzer can be designed to crop the frame if necessary before or during the detection process, depending on the requirements of the barcode scanning algorithm. Implementing this feature within our library, it would be highly beneficial to explore the use of Kotlin's coroutines and Flow for streaming ByteArray data from each frame.
On the iOS side, using AVFoundation
to implement a similar feature involves setting up a camera capture session with a AVCaptureVideoDataOutput to process frames in real time. Similar to the Android approach, you would analyze each frame for barcodes. The AVCaptureMetadataOutput class can be particularly useful for barcode detection, as it's designed to process video frames and detect various types of metadata, including QR codes and barcodes.