0

我想将位图转换为 Leptonica.Pix .. 所以在我进行搜索后,我发现有人在这里遇到同样的问题: Tesseract .NET Process image from memory object

所以这个问题的解决方案是使用 PixConverter.ToPix() 方法。

我的问题是我在最新安装的 Leptonica 包中找不到这个方法。我试图删除并重新安装最新版本的 Nuget,但该方法仍然不存在。

我应该怎么做才能使用 PixConverter.ToPix()?提前致谢。

编辑:我忘了提到我也在使用最新的 Tessercat pacakge。

4

3 回答 3

1

您需要为此 (PixConverter.ToPix()) 使用版本“3.0.2”才能工作。

所以你的 .csproj 文件应该在版本中有这个完全匹配:

<PackageReference Include="Tesseract" Version="3.0.2" />

希望能帮助到你。

于 2019-04-02T19:01:44.837 回答
1

在 Tesseract 4 中有一种新方法可以使用以下语法进行转换:

var pixFromByteArray = Pix.LoadFromMemory(byteArray);
var pixFromFile = Pix.LoadFromFile(fileName);
于 2021-02-10T16:28:59.270 回答
0

它位于Tesseract命名空间中,更多信息可以在这里找到https://github.com/charlesw/tesseract

namespace Tesseract
{
    /// <summary>
    /// Handles converting between different image formats supported by DotNet.
    /// </summary>
    public static class PixConverter
    {
        private static readonly BitmapToPixConverter bitmapConverter = new BitmapToPixConverter();
        private static readonly PixToBitmapConverter pixConverter = new PixToBitmapConverter();

        /// <summary>
        /// Converts the specified <paramref name="pix"/> to a Bitmap.
        /// </summary>
        /// <param name="pix">The source image to be converted.</param>
        /// <returns>The converted pix as a <see cref="Bitmap"/>.</returns>
        public static Bitmap ToBitmap(Pix pix)
        {
            return pixConverter.Convert(pix);
        }

        /// <summary>
        /// Converts the specified <paramref name="img"/> to a Pix.
        /// </summary>
        /// <param name="img">The source image to be converted.</param>
        /// <returns>The converted bitmap image as a <see cref="Pix"/>.</returns>
        public static Pix ToPix(Bitmap img)
        {
            return bitmapConverter.Convert(img);
        }
    }
}

根据网站登陆页面

通过从包管理器控制台运行 Install-Package Tesseract 添加 Tesseract NuGet 包。

此外,它值得彻底阅读该网站。

免责声明,我以前从未使用过这个库,只是查找了信息

更新

只是为了确保我没有给你坏信息,我创建了一个新项目,下载了最新的 Tesseract nuget。并且能够做到以下几点。

using Tesseract;

...

PixConverter.ToPix()

更新2

您注意到的问题是因为您正在使用

https://www.nuget.org/packages/tesseract.net/

相对于

https://www.nuget.org/packages/Tesseract/

现在我不确定你真正想要的是什么。但是,该方法在前者中不存在

于 2018-05-24T00:44:23.030 回答