Desert Ant Labs

Shapes.

図形認識提供中

オンデバイスの図形認識。手描きの一筆を長方形、楕円、三角形、星、直線に変換します。10 ms 未満。

デモ

ラフなスケッチを、完璧な図形に。

ラフな円を描くと、Shapes がきれいな円にスナップします。Shapes は正確なベクター図形をあてはめ、軸、円、正方形、15 度単位の回転にスナップし、図形でない走り書きは棄却します。

Apple では、1 回の呼び出しで PencilKit のキャンバスに「メモ」アプリ風のスマート図形スナップを追加でき、ライブプレビューもそのまま残ります。Apple 自身の「Snap to Shape」はサードパーティアプリが呼び出せないプライベート API なので、Shapes が同じ仕事を 1 行で引き受けます。

モデルはアプリに同梱できる大きさで、ダウンロードは不要です。ブラウザでは、Shapes は LiteRT.js を通して動きます。

1 ストロークあたり 10 ms 未満。

Apple では 0.2MB、Android と Web では 1.3MB のモデルによる、1 ストロークあたり 10 ms 未満。

0.2MB
オンデバイス
<10ms
認識 1 回あたり
オンデバイス
5
図形クラス
長方形、楕円、三角形、星、直線
1.3MB
ブラウザでは
一度だけ取得してキャッシュ

社内測定値。Apple は Core ML、ブラウザは LiteRT.js、Node はビルド済みのネイティブライブラリです。

「メモ」アプリ風のスマート図形

canvasView.enableShapeSnapping() で PencilKit のキャンバスに図形スナップを追加します。ライブプレビュー、取り消し・やり直しはそのまま保たれ、Apple のプライベートな Snap to Shape API が残した隙間を埋めます。

手描きの図をきれいに整える

図解やホワイトボードのツールで、ラフなストロークを正確な図形に変えます。tldraw や Excalidraw のストロークデータにも対応します。

クロスプラットフォームの描画

1 つの認識エンジンが iOS、Android、Web をカバーするので、スナップの処理は一度書けば済みます。

ダウンロードではなく、アプリに同梱

Apple では認識エンジンは 0.2MB でバイナリに同梱され、Android パッケージも既定で同梱します。ブラウザでは、SDK が 1.3MB を一度だけ取得してキャッシュします。

インスピレーション

Shapes で作るためのアイデア。プロンプトをコーディングエージェントにコピーして始めましょう。

Shapes

Build a whiteboard that snaps rough sketches into clean shapes.

Shapes

Clean up a freehand diagram into crisp shapes.

Shapes

Add shape recognition to a web canvas with no download.

Shapes

Snap flowchart boxes and connector lines as you sketch them.

Shapes

Add smart-shape drawing to a kids' learning app.

Shapes

Recognize gesture shapes to trigger app actions.

モデルができること

  • 一度にひと筆ずつ、その [x, y] 座標として渡します。PencilKit、tldraw、Excalidraw、あるいは自作のキャンバスから。
  • 長方形、楕円、三角形、星、直線を認識し、図形でないものは棄却します。
  • 軸、円、正方形、15 度単位の回転にスナップします。
  • 1 回の呼び出しで PencilKit のライブスナップ:canvasView.enableShapeSnapping()
  • ブラウザでは LiteRT.js を通して動作します。Node はビルド済みのネイティブライブラリを使います。

はじめに

図形認識 を、数行のコードで iOS or macOS, Android or web アプリに追加。 Shapes のドキュメント.

iOS, macOS
インストール
// Swift Package Manager
.package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core", from: "3.1.0")
// target dependency
.product(name: "Shapes", package: "desert-ant-core")
使用例 - Swift
import Shapes

let shapes = Shapes()
let shape = try await shapes.recognize(points: stroke)
// Shape? -> rectangle, ellipse, triangle, star, line
使用例 - PencilKit
import PencilKit
import Shapes

// Live smart-shape snapping on a PencilKit canvas, in one line.
// Pause after a stroke to preview the fit, lift to snap. Undo-safe,
// and it uses the same recognizer, bundled by default.
canvasView.enableShapeSnapping()
プロンプトで作る
Add Shapes from Desert Ant Labs to this Swift project (iOS, macOS).

What it does: Shapes:オンデバイスの単一ストローク図形認識.

SDK:

Swift (iOS, macOS)
Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme
// Swift Package Manager
.package(url: "https://github.com/Desert-Ant-Labs/desert-ant-core", from: "3.1.0")
// target dependency
.product(name: "Shapes", package: "desert-ant-core")

Reference:
- Model page: https://desertant.com/models/shapes/
- Full catalog and other models: https://desertant.com/llms.txt

Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.
Android
インストール
// build.gradle.kts (Maven Central)
implementation("ai.desertant:shapes:3.1.0")
使用例 - Kotlin
import ai.desertant.shapes.Shapes

val shapes = Shapes(context)
val shape = shapes.recognize(points)
// Shape? -> rectangle, ellipse, triangle, star, line
プロンプトで作る
Add Shapes from Desert Ant Labs to this Kotlin project (Android).

What it does: Shapes:オンデバイスの単一ストローク図形認識.

SDK:

Kotlin (Android)
Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme
// build.gradle.kts (Maven Central)
implementation("ai.desertant:shapes:3.1.0")

Reference:
- Model page: https://desertant.com/models/shapes/
- Full catalog and other models: https://desertant.com/llms.txt

Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.
Web, Node.js
インストール
npm i @desert-ant-labs/shapes @litertjs/core
使用例 - TypeScript
import { Shapes } from "@desert-ant-labs/shapes";       // browser
// import { Shapes } from "@desert-ant-labs/shapes/native"; // server-side Node

const shapes = await Shapes.load();
const shape = await shapes.recognize(points);
// { kind: "ellipse", center: {...}, ... } or null
プロンプトで作る
Add Shapes from Desert Ant Labs to this JavaScript / TypeScript project (Web, Node.js).

What it does: Shapes:オンデバイスの単一ストローク図形認識.

SDK:

JavaScript / TypeScript (Web, Node.js)
Repo: https://github.com/Desert-Ant-Labs/desert-ant-core#readme
npm i @desert-ant-labs/shapes @litertjs/core

Reference:
- Model page: https://desertant.com/models/shapes/
- Full catalog and other models: https://desertant.com/llms.txt

Add the SDK, then follow its README for the exact API and current version. Do not invent API names or method signatures; confirm them against the README.

仕様

図形クラス
長方形、楕円、三角形、星、直線
オンデバイスサイズ
0.2MB Core ML(Apple)、1.3MB LiteRT(Android、Web)
速度
10 ms 未満
Web ランタイム
ブラウザは LiteRT.js、Node はネイティブライブラリ

Shapes が読み取るのは一度にひと筆だけなので、2 画で描いた図形は認識しません。あまりに雑な、あるいはどちらとも取れるストロークはあえて棄却するため、走り書きが三角形にスナップすることはありません。複数画の図解を扱うには、まず自前でストロークをまとめる処理が必要です。

FAQ

Shapes とは?

オンデバイスの図形認識。手描きの一筆を長方形、楕円、三角形、星、直線に変換します。10 ms 未満。

Shapes はオンデバイスで動作しますか?

はい。Shapes はデバイス上で動作し、サーバーへの通信は発生しません。データはユーザーの手元に残ります。

Shapes はどのプラットフォームに対応していますか?

Shapes は Swift, Kotlin, JavaScript / TypeScript 向けのネイティブなオンデバイス SDK として提供されます。

Shapes の料金はいくらですか?

すべてのモデルは、SDK ごとに月間アクティブデバイス 100k 台まで無料です。各ユーザーがモデルを実行する回数に制限はありません。 カスタムライセンスについては、お問い合わせください

Shapes の精度や速度はどれくらいですか?

Apple では 0.2MB、Android と Web では 1.3MB のモデルによる、1 ストロークあたり 10 ms 未満。

リソース