感谢GitHub用户,您可以测试一个示例: https : //gist.github.com/Koze/e59fa3098388265e578dee6b3ce89dd8
- (void)detectWithImageURL:(NSURL *)URL
{
VNImageRequestHandler *handler = [[VNImageRequestHandler alloc] initWithURL:URL options:@{}];
VNDetectTextRectanglesRequest *request = [[VNDetectTextRectanglesRequest alloc] initWithCompletionHandler:^(VNRequest * _Nonnull request, NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error);
}
else {
for (VNTextObservation *textObservation in request.results) {
// NSLog(@"%@", textObservation);
// NSLog(@"%@", textObservation.characterBoxes);
NSLog(@"%@", NSStringFromCGRect(textObservation.boundingBox));
for (VNRectangleObservation *rectangleObservation in textObservation.characterBoxes) {
NSLog(@" |-%@", NSStringFromCGRect(rectangleObservation.boundingBox));
}
}
}
}];
request.reportCharacterBoxes = YES;
NSError *error;
[handler performRequests:@[request] error:&error];
if (error) {
NSLog(@"%@", error);
}
}
事实是,结果是每个检测到的字符的包围盒阵列。从我在Vision的会议上收集到的信息来看,我认为您应该使用CoreML来检测实际的字符。
推荐的WWDC 2017演讲: 视觉框架:基于Core ML构建 (也没有看完),看看25:50的类似示例MNISTVision
这是另一个漂亮的应用程序, 演示了如何使用Keras(Tensorflow)训练使用CoreML进行笔迹识别的MNIST模型 : Github
0
我正在查看Apple的Vision API文档,并且看到了一些与
UIImages
文本检测有关的类:1)
class VNDetectTextRectanglesRequest
2)
class VNTextObservation
看起来他们可以检测到字符,但是我看不到对字符执行任何操作的方法。一旦检测到字符,您将如何将其转换为
NSLinguisticTagger
可以解释的NSLinguisticTagger
?这是对
Vision
的简要概述。感谢您的阅读。