手写识别开发包 Zinnia

BSD
C/C++
Windows
2010-02-01
小编辑

Zinnia 是一个简单、可定制和可移植的手写识别系统,基于 Support Vector Machines (SVM) 算法。SVM算法简介

实例代码:

#include <stdio.h>
#include "zinnia.h"

int main(int argc, char **argv) {
size_t i;
zinnia_recognizer_t *recognizer;
zinnia_character_t *character;
zinnia_result_t *result;

recognizer = zinnia_recognizer_new();

if (!zinnia_recognizer_open(recognizer, "/usr/local/lib/zinnia/model/tomoe/handwriting-ja.model")) {
fprintf(stderr, "ERROR: %s\n", zinnia_recognizer_strerror(recognizer));
return -1;
}

zinnia_character_t *character = zinnia_character_new();
zinnia_character_clear(character);
zinnia_character_set_width(character, 300);
zinnia_character_set_height(character, 300);
zinnia_character_add(character, 0, 51, 29);
zinnia_character_add(character, 0, 117, 41);
zinnia_character_add(character, 1, 99, 65);
zinnia_character_add(character, 1, 219, 77);
zinnia_character_add(character, 2, 27, 131);
zinnia_character_add(character, 2, 261, 131);
zinnia_character_add(character, 3, 129, 17);
zinnia_character_add(character, 3, 57, 203);
zinnia_character_add(character, 4, 111, 71);
zinnia_character_add(character, 4, 219, 173);
zinnia_character_add(character, 5, 81, 161);
zinnia_character_add(character, 5, 93, 281);
zinnia_character_add(character, 6, 99, 167);
zinnia_character_add(character, 6, 207, 167);
zinnia_character_add(character, 6, 189, 245);
zinnia_character_add(character, 7, 99, 227);
zinnia_character_add(character, 7, 189, 227);
zinnia_character_add(character, 8, 111, 257);
zinnia_character_add(character, 8, 189, 245);

result = zinnia_recognizer_classify(recognizer, character, 10);
if (result == NULL) {
fprintf(stderr, "%s\n", zinnia_recognizer_strerror(recognizer));
return -1;
}


for (i = 0; i < zinnia_result_size(result); ++i) {
fprintf(stdout, "%s\t%f\n",
zinnia_result_value(result, i),
zinnia_result_score(result, i));
}

zinnia_result_destroy(result);
zinnia_character_destroy(character);
zinnia_recognizer_destroy(recognizer);

return 0;
}
加载中

评论(0)

暂无评论

暂无资讯

暂无问答

使用 django-blog-zinnia 搭建个人博客

目前网上搭建个人博客的方案很多,虽然使用诸如 Wordpress ( PHP )、Hexo ( Node.js ) 等可以方便快速地搭建一款功能齐全的高性能个人博客,但是本文将尝试一种更为小众化的方案 —— 一款基...

2012/08/21 19:43
284
0

没有更多内容

加载失败,请刷新页面

没有更多内容

返回顶部
顶部