-
Notifications
You must be signed in to change notification settings - Fork 70
QR Code Detection Implementation and Add Tests #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
//! It uses the `rqrr` crate for actual QR decoding and integrates with | ||
//! kornia's tensor operations for image processing. | ||
|
||
use anyhow::Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use thiserror only
/// | ||
/// Returns an error if conversion, detection, or decoding fails. | ||
pub fn detect_and_decode( | ||
image: &Tensor<u8, 3, CpuAllocator>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use directly Image<u8, 3> to avoid the conversion
let grayscale = Self::tensor_to_grayscale(image)?; | ||
|
||
// Prepare the image for QR detection | ||
let mut prepared = PreparedImage::prepare(grayscale.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no clone
//! kornia's tensor operations for image processing. | ||
|
||
use anyhow::Result; | ||
use image::{GrayImage, ImageBuffer}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no image crate
|
||
// Include the tests module | ||
#[cfg(test)] | ||
mod tests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this tests here to be more compact
|
||
impl QrDetectionExt<u8, 1> for Image<u8, 1> { | ||
fn detect_qr_codes(&self) -> Result<Vec<QrDetection>, QrError> { | ||
// First convert grayscale image to a 3-channel tensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use rgb_from_gray from here https://github.com/kornia/kornia-rs/blob/main/crates/kornia-imgproc/src/color/gray.rs#L134
fixes #231
Summary
This PR implements proper QR code detection functionality in the
kornia-qr
crate using therqrr
library. It fixes build issues, adds proper tests, and ensures seamless integration with the main Kornia crate.Changes
1. Fixed API usage and version handling
rqrr
library API by simplifying the QR code version handling2. Added comprehensive testing
tests/data/qr/
3. Fixed build dependencies
kornia
dependency fromkornia-qr
Cargo.toml
to0.1.9-rc.2
to match the workspace4. Created example application
qr_detector
example inexamples/qr_detector/
Testing
These changes make the QR code detection functionality in Kornia more robust and user-friendly while ensuring proper integration with the rest of the Kornia ecosystem.