LoginSignup
0
4

More than 1 year has passed since last update.

概要

画像から文字認識をする方法です。

伝えたいこと

機械学習を使って文字を認識するのは、Visionのフレームワークで簡単にできます。

解決したい課題

画像のテキストが難しい手続きなしで、パッと読み取れれば、たとえばOCRアプリなど、いろんなサービスに応用できます。

解決手法

Visionを使います。
アップルのフレームワークで、機械学習ベースの文字認識が簡単に使えます。

留意点

ただし、現在のところ日本語はサポートされていません。

2021年 12月 現在のサポート言語
英語
フランス語
イタリア語
ドイツ語
スペイン語
ポルトガル語
中国語 簡体
中国語 繁体

let request = VNRecognizeTextRequest()
let handler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .right, options: requestOptions)
do {
    try handler.perform([request])
} catch let error {
    print(error)
}
guard let observations = request.results as? [VNTextObservation] else { return }
for observation in observations {
    let box = observation.boundingBox
    let topCandidate = observation.topCandidates(1)
    if let recognizedText = topCandidate.first {
        print(recognizedText.string)
    }
}

business
&
We have
people
A VISION
Principle
Education
UNDIVIDED
? ?
We start
1
Z
We hate
WE DONT WORK
WITH
from WHY
digital
Government
Open
knowledge
Not-only-money!
1
POWER
We Love
Open
digital
processi
Teamf
Community
Power
Digital
Honesty with
of
STOMO
idea
transforma-
ourselves
Design
†ion
Skills
2
Creative ir
Digital
2
AS
Passion
Diversity
PRODUCT
development
RESTRICT
-f
opinions
Customer
deseloptrert
Invisible
digital
Punk
WE DON'T
make
and research
useless
2
PRODUCT
Symbies
Concept

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
簡単な開発内容をお書き添えの上、お気軽にご連絡ください。
rockyshikoku@gmail.com

Core MLやARKitを使ったアプリを作っています。
機械学習/AR関連の情報を発信しています。

Twitter
Medium

0
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
4