- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
基于 MSDN 为 Handwriting Recognition 提供的代码在 Windows 10 应用程序中,我尝试让它在用户完成笔划笔划后自动识别手写内容,而不是在单击按钮时自动识别。
当我的 Canvas 中触发 PointerReleased 事件时,通过调用我的手写识别方法,我已经能够在 Windows 8.1 Metro 应用程序中执行类似的操作。它运行良好,我尝试在 UWP 中模拟相同的行为。
PointerReleased 事件未在 UWP 应用程序中触发,因此我使用 InkCanvas.InkPresenter.StrokeInput.StrokeEnded 事件来调用此方法:
async void RecognizeAsync(InkStrokeInput input, PointerEventArgs e)
{
IReadOnlyList<InkStroke> currentStrokes =myInkCanvas.InkPresenter.StrokeContainer.GetStrokes();
if (currentStrokes.Count > 0)
{
var recognitionResults = await inkRecognizerContainer.RecognizeAsync(myInkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);
if (recognitionResults.Count > 0)
{
// Display recognition result
string str = "Recognition result:";
foreach (var r in recognitionResults)
{
str += " " + r.GetTextCandidates()[0];
}
Status.Text=str;
}
else
{
Status.Text = "No text recognized.";
}
}
else
{
Status.Text="Must first write something.";
}
}
它接近我想要实现的目标,只是没有考虑最后一笔。我猜想当 StrokeEnded 事件被触发时,InkStroke 尚未被“处理”,因此它不包含在 currentStrokes 中。
我试图通过将事件的 InkStrokeInput 对应的 Strokes 添加到我用作识别参数的 StrokeContainer 来规避这个问题:
InkStrokeContainer totalStrokes=new InkStrokeContainer();
if (currentStrokes.Count > 0) {
totalStrokes= myInkCanvas.InkPresenter.StrokeContainer;
}
totalStrokes.AddStrokes(input.InkPresenter.StrokeContainer.GetStrokes());
var recognitionResults = await inkRecognizerContainer.RecognizeAsync(totalStrokes, InkRecognitionTarget.All);
但是 input.InkPresenter.StrokeContainer.GetStrokes() 返回一个空列表。
有没有办法让我在事件触发时访问当前的 Stroke?或者在笔划被“处理”后,我可以使用另一个事件来调用手写识别吗?或者另一种自动识别所有当前 InkStrokes 的笔迹的方法?
最佳答案
我找到了一种方法,通过在触发 InkCanvas.InkPresenter.StrokesCollected 事件时调用我的 RecognizedAsync 方法来实现我期望的结果。
来自 MSDN 文档:
InkPresenter.StrokesCollected event
Occurs when one or more ink strokes are processed ("wet" to "dry") by the >application thread.
By default, an ink stroke is processed on a low-latency background thread and >rendered wet as it is drawn. When the stroke is completed (pen or finger >lifted, or mouse button released), the stroke is processed on the UI thread >and rendered dry to the InkCanvas layer (above the application content).
关于c# - 每次用户完成描笔后,如何进行手写识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33738500/
目录 1、背景 2、样本均值和样本方差矩阵 3、PCA 3.1 最大投影方差 3.2 最小重构距离 4、Py
android中获取屏幕的长于宽,参考了网上有很多代码,但结果与实际不符,如我的手机是i9000,屏幕大小是480*800px,得到的结果却为320*533 结果很不靠谱,于是自己写了几行代码,亲测
我写了一个 vector 类来学习 move 语义。 我使用 move 构造函数来 move T(注释行)。 我的问题是为什么不像在 C 中一样复制临时对象的所有字节并将临时对象的所有字节设置为零?
我需要解析一种类似于 Java 的最小化版本的语言。由于效率是最重要的因素,所以我选择手写解析器而不是像 GOLD、bison 和 yacc 这样的 LRAR 解析器生成器。 但是我找不到优秀的手写解
我正在尝试向 perlin 单纯形噪声函数添加 asm.js 注释: "use strict"; // Ported from Stefan Gustavson's java implementati
之前在bind和apply以及call函数使用中详解总结过bind和apply以及call函数的使用,下面手写一下三个函数。 一、首先call函数 Function.prototype.MyCall
我正在 asm.js 中编写优先级队列和八叉树Javascript 的子集,以便从它们中挤出最后可能的性能。 但是,您如何在 asm.js 函数的 heap 中存储对 Javascript 对象的引用
我是一名优秀的程序员,十分优秀!