首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用PixConverter.ToPix Leptonica C#

无法使用PixConverter.ToPix Leptonica C#
EN

Stack Overflow用户
提问于 2018-05-24 00:38:41
回答 3查看 3.7K关注 0票数 0

我想把位图转换成Leptonica.Pix。所以,在我做了一个搜索之后,我在这里发现了一个同样的问题:Tesseract .NET处理内存对象的图像

因此,解决这个问题的方法是使用PixConverter.ToPix()方法。

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

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

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

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-05-24 00:44:23

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

代码语言:javascript
复制
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);
        }
    }
}

根据登陆页面的地点

通过从Package控制台运行添加Tesseract NuGet包。

同时,它的价值,同时阅读网站彻底。

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

更新

为了确保我没有给你坏消息,我创建了一个新项目,下载了最新的Tesseract nuget。做了以下几件事。

代码语言:javascript
复制
using Tesseract;

...

PixConverter.ToPix()

Update2

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

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

赋与

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

现在我不知道你真正想要的是什么。然而,这种方法在前者中并不存在。

票数 0
EN

Stack Overflow用户

发布于 2019-04-02 19:01:44

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

因此,您的.csproj文件应该在版本中具有与完全匹配的

代码语言:javascript
复制
<PackageReference Include="Tesseract" Version="3.0.2" />

希望能帮上忙。

票数 1
EN

Stack Overflow用户

发布于 2021-02-10 16:28:59

在Tesseract 4中,有一种使用以下语法将其转换的新方法:

代码语言:javascript
复制
var pixFromByteArray = Pix.LoadFromMemory(byteArray);
var pixFromFile = Pix.LoadFromFile(fileName);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50499300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档