求教:Tomoe识别字符速率问题

z373522886 z373522886 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
整个tomoe手写识别流程都实现了,就是到下面这个识别函数的时候,速度不够快!
求高手指教!

(PS:linux PC 平台的,没问题! 就是移植到mips 开发板,就有问题!)


static GPtrArray *
get_candidates (GList *points, GPtrArray *cands) //用points对应cands查找数据
{
GPtrArray *rtn_cands;
guint cand_index = 0;
guint strk_index = 0;
gint i_nop = 0; /* input stroke number of points */
tomoe_metric *i_met = NULL; /* input stroke metrics */
gint d_nop = 0; /* dict stroke number of points */
TomoePoint *pi0, *pil;

rtn_cands = g_ptr_array_new ();

i_nop = g_list_length (points);
stroke_calculate_metrics (points, &i_met);
pi0 = (TomoePoint *) g_list_nth_data (points, 0); //每笔首坐标(x,y)
pil = (TomoePoint *) g_list_nth_data (points, i_nop - 1); //每笔末坐标(x,y)

for (cand_index = 0; cand_index < cands->len; cand_index++) { //笔画循环查找
gboolean match_flag = FALSE;
cand_priv *cand_p;
GArray *tmp = NULL;
TomoeChar *lttr;
TomoeWriting *writing;
TomoeCandidate *cand;
GList *writing_strokes, *list;
guint stroke_num;

cand_p = g_ptr_array_index (cands, cand_index);
tmp = _g_array_copy_int_value (cand_p->adapted_strokes);
cand = TOMOE_CANDIDATE (cand_p->cand);
lttr = tomoe_candidate_get_char (cand);
writing = tomoe_char_get_writing (lttr);
writing_strokes = (GList *) tomoe_writing_get_strokes (writing);
stroke_num = g_list_length (writing_strokes);

for (list = writing_strokes, strk_index = 0;
list;
list = g_list_next (list), strk_index++) {//用每一个笔画对应xml文件
GList *writing_points;
TomoePoint *pw0, *pw1, *pwl;
gint d1 = 0, d2 = 0;
gint d3 = 0, d4 = 0;
gint score1 = 0, score2 = 0;
gint score3 = 0;
gdouble d_angle = 0;

/* if the stroke index is already appended to, the value is ignored */
if (_g_array_has_this_int_value (tmp, strk_index))
continue;

writing_points = (GList *) list->data;
d_nop = g_list_length (writing_points);
/*
* Distance between the point and begining point.
* Distance between the point and ending point.
* Number of characteristic points.
*/
pw0 = (TomoePoint *) g_list_nth_data (writing_points, 0);
d1 = dist_tomoe_points (pi0, pw0);

pwl = (TomoePoint *) g_list_nth_data (writing_points, d_nop - 1);
d2 = dist_tomoe_points (pil, pwl);

score3 = (d1 + d2);
tomoe_candidate_set_score (
cand,
tomoe_candidate_get_score (cand) + score3);
if (d1 > LIMIT_LENGTH ||
d2 > LIMIT_LENGTH ||
abs (d_nop - i_nop) > 3) {
continue;
}

d3 = i_met[0].d;

pw1 = (TomoePoint *) g_list_nth_data (writing_points, 1);
d_angle = atan2 (pw1->y - pw0->y, pw1->x - pw0->x);
d4 = dist_tomoe_points (pw0, pw1);

/* threshold is (angle of bigining line) % 45[degree] (PI/4)*/
if (d3 > LIMIT_LENGTH &&
d4 > LIMIT_LENGTH &&
abs (d_angle - i_met[0].angle) > M_PI_4) {
continue;
}

/*
* Distance and angle of each characteristic points:
* (Compare handwriting data with dictionary data)
*/
score1 = match_input_to_dict (points, writing_points);
if (score1 < 0) {
tomoe_candidate_set_score (
cand,
tomoe_candidate_get_score (cand) * 2);
continue;
}
tomoe_candidate_set_score (
cand,
tomoe_candidate_get_score (cand) + score1);

/*
* Distance and angle of each characteristic points:
* (Compare dictionary data with handwriting data)
*/
score2 = match_dict_to_input (writing_points, points);
/* score2 = match_input_to_dict (writing_points, points); */
if (score2 < 0) {
tomoe_candidate_set_score (
cand,
tomoe_candidate_get_score (cand) * 2);
continue;
}

tomoe_candidate_set_score (
cand_p->cand,
tomoe_candidate_get_score (cand) + score2);

g_array_append_val (cand_p->adapted_strokes, strk_index);
match_flag = TRUE;

list = NULL;
}

if (match_flag) {
g_ptr_array_add (rtn_cands, cand_p);
}
g_array_free (tmp, TRUE);
//if (rtn_cands->len >= 220) break;
}

free (i_met);

return rtn_cands;
}
...全文

相关推荐

JEP30-PX100A PartModel Product Guidelines for Electronic-Device Substrates and Assemblies – XML Requ

JEP30-PX100A PartModel Product Guidelines for Electronic-Device Substrates and Assemblies – XML Requirements

cdming

基于Matlab的自动睡眠粒状结构检测算法,从脑电信号中进行。.zip

1.版本:matlab2014a/2019b/2024b 2.附赠案例数据可直接运行。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。

海神之光

JEP375 2.5D_3D Silicon thinned wafers with Through Silicon Vias (TSV’s) and Backside Redistribution

JEP375 2.5D_3D Silicon thinned wafers with Through Silicon Vias (TSV’s) and Backside Redistribution Layer (RDL).pdf

Red Car

考虑供电可靠性与算力柔性的数据中心园区源‑储‑荷一体化规划研究(Matlab代码实现)

考虑供电可靠性与算力柔性的数据中心园区源‑储‑荷一体化规划研究(Matlab代码实现)内容概要:本文围绕“考虑供电可靠性与算力柔性的数据中心园区源-储-荷一体化规划”展开研究,提出了一种综合能源系统优化规划方法。该方法充分考虑数据中心对供电可靠性的高要求以及算力负载的灵活性特征,将电力供应、储能配置与计算负荷进行协同优化。通过建立数学模型,整合光伏发电、储能系统与数据中心负荷调度,利用Matlab代码实现优化求解,旨在提升能源利用效率、降低运营成本并增强系统韧性。研究涵盖了对新能源出力不确定性、负荷波动以及储能动态行为的建模与仿真分析,最终验证了所提一体化规划方案在提高供电可靠性和实现算力资源柔性调度方面的有效性。; 适合人群:具备一定电气工程、能源系统或计算机科学背景,从事数据中心、智能电网、综合能源系统等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 为数据中心园区的绿色低碳与高可靠运行提供规划设计方案;② 实现可再生能源的高效消纳与储能系统的优化配置;③ 探索算力作为柔性负荷参与电力系统互动的潜力,支撑新型电力系统建设。; 阅读建议:此资源以Matlab代码为核心,辅以理论模型,建议读者在理解基本原理的基础上,动手运行和调试所提供的代码,通过修改参数和场景设置来深入掌握一体化规划的优化逻辑与关键技术细节。

@橘柑橙柠桔柚

歌曲爆款传播预测数据集10000首曲目Spotify音频特征机器学习

本数据集为合成音乐数据,包含2010至2025年间10000首曲目的Spotify风格音频特征与明确的爆款(viral)目标标签。现有音乐数据集常缺少可用建模目标或存在授权限制,本数据集提供了干净、字段完整、可直接用于监督学习的基准语料。字段涵盖节奏、能量、可舞性、声学度、效价等音频属性,以及曲目元数据与年份信息,目标列viral基于传播表现定义,可直接用于二分类建模。适合开展爆款歌曲预测、音频特征与传播关系分析、年代音乐风格演变可视化、特征重要性排序等分析任务,也可作为分类、回归与特征工程教学的演示数据。数据结构清晰、无缺失值,适合数据科学课程、音乐媒体分析与推荐算法原型验证使用。

licy__
评论 5
收藏 已收藏
分享
返回顶部
z373522886
其他硬件开发 2,432 成员 4,281 内容