Skip to content

Commit f4e8bc1

Browse files
committed
Add missing Vision API
Fixes #755.
1 parent 6c0101a commit f4e8bc1

File tree

4 files changed

+52
-12
lines changed

4 files changed

+52
-12
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[features]
2+
VNObservation = [
3+
"objc2-foundation/NSArray",
4+
"objc2-foundation/NSData",
5+
"objc2-foundation/NSDictionary",
6+
"objc2-foundation/NSError",
7+
"objc2-foundation/NSIndexPath",
8+
"objc2-foundation/NSIndexSet",
9+
"objc2-foundation/NSObject",
10+
"objc2-foundation/NSRange", # Added
11+
"objc2-foundation/NSString",
12+
"objc2-foundation/NSUUID",
13+
"objc2-foundation/NSValue",
14+
]

framework-crates/objc2-vision/Cargo.toml

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework-crates/objc2-vision/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ extern crate std;
1818
mod generated;
1919
#[allow(unused_imports, unreachable_pub)]
2020
pub use self::generated::*;
21+
#[cfg(feature = "VNObservation")]
22+
mod observation;
2123

2224
#[allow(unused)]
2325
pub(crate) type OSType = u32;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![allow(non_snake_case)]
2+
use objc2::extern_methods;
3+
use objc2::rc::Retained;
4+
use objc2_foundation::{NSError, NSRange};
5+
6+
use crate::{VNRecognizedText, VNRectangleObservation};
7+
8+
impl VNRecognizedText {
9+
extern_methods!(
10+
/// Calculate the bounding box around the characters in the range of
11+
/// the string.
12+
///
13+
/// The bounding boxes are not guaranteed to be an exact fit around
14+
/// the characters and are purely meant for UI purposes and not for
15+
/// image processing.
16+
#[unsafe(method(boundingBoxForRange:error:_))]
17+
#[unsafe(method_family = none)]
18+
pub unsafe fn boundingBoxForRange_error(
19+
&self,
20+
range: NSRange,
21+
) -> Result<Retained<VNRectangleObservation>, Retained<NSError>>;
22+
);
23+
}

0 commit comments

Comments
 (0)