Coder Social home page Coder Social logo

zinnia-swift's Introduction

Zinnia-Swift

A Swift wrapper around zinnia, a library to recognize handwritten Japanese (or Chinese) characters.

For more information about zinnia, see https://taku910.github.io/zinnia/.

Recognition requires a model file that incorporates training data. Model files can be downloaded, for example from https://tegaki.github.io. A model file is included for unit testing.

Installation

Use the Swift Package Manager. Add the following to your dependencies in Package.swift

dependencies: [
        .package(url: "https://github.com/shinjukunian/zinnia-swift.git", from: "0.1.0"),
    ],

How to use

To get started, initialize the Recognizer

let url = ... //the url of your model file
let recognizer=try? Recognizer(modelURL:url)

Don't forget to specify the canvas size on which the characters are being drawn.

recognizer.canvasSize = Recognizer.Size(width:500, height:500)

Next, add strokes to the recognizer. These would typically come from a gesture recognizer on a UIView or the movements of a mouse. A stroke consists of all the points between touchesBegan(:) and touchesEnded(:).

let stroke = Stroke(points: [Point(x: 50, y: 250], Point(x:450, y: 250)])
//strokes for character 一

recognizer.add(stroke:stroke)

The stroke order is important. To classify strokes, use

let result = recognizer.classify()

let characters = result.map({$0.character})
//the recognized characters

The recognizer can be reset using

recognizer.clear()

to start a new character.

For a sample application, see https://github.com/shinjukunian/KanjiLookup-SwiftUI.

To Do

  • Implement training - [ ] Sample application

Licence

zinnia (Copyright (c) 2005-2007, Taku Kudo), is BSD-licenced.

zinnia-Swift is under the MIT licence

The various model files come with their own licence.

zinnia-swift's People

Contributors

shinjukunian avatar

Stargazers

Shannon Lane avatar Romain PELLEN avatar K。 avatar JP Whitaker avatar Alex Ehlke avatar beforeold avatar yibit avatar Kevin avatar  avatar Ryan avatar Chinsyo avatar Chris Vasselli avatar  avatar Uli Troyo avatar  avatar

Watchers

James Cloos avatar

zinnia-swift's Issues

Unable to add package because Xcode's git does not support git-lfs

When I try to add this package via Xcode, I get this mysterious error:
Screen Shot 2022-02-18 at 3 14 38 PM

After some digging, I found this error message:
Screen Shot 2022-02-18 at 3 14 59 PM

And sure enough, it looks like SwiftPM doesn't support git-lfs currently, at least without symlinking it in from another git installation, and remembering to update it every time you update Xcode.

I'd rather avoid going down that path if possible. It looks like the only git-lfs file is a model used in the tests. Maybe it would be OK in this case to simply include it in the repo, without using git-lfs? Or maybe require that it would be downloaded separately in order to run tests?

@shinjukunian If you have a preferred way, I'd be happy to put together a pull request. Thanks for making this package, it looks great!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.