Leptonica --> tesseract --> OpenCV

本文详细记录了在Windows上配置和使用Leptonica、Tesseract和OpenCV的过程,包括遇到的问题、解决方案和最终成功运行的步骤。内容涵盖库版本匹配、依赖问题、静态编译与动态链接的冲突,以及不同系统(如OS X和Windows)上的安装差异。特别提到了静态库和DLL的版本兼容性问题,以及OpenALPR在不同平台上的应用和调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

=== 26/05/2017更 ===

  • The static drawing function static void DisplayBoxVector [tabfind.cpp] does draw different colours other than ScrollView::WHITE depending on blob types
  • TabFind::FindInitialTabVectors gets called TWICE, hence produces two sets of debugging windows:
    • ”VerticalLines”
    • “InitialTabs”
  • For 1st "InitialTabs" window, only white boxes are drawn via above DisplayBoxVector
  • For 2nd "InitialTabs" window, colour boxes will be drawn first, conforming to BLOBNBOX::TextlineColor colour scheme
  • For both cases, the box edges will be rendered based on Box Tab types

====================

  • The debugging window “Initial textline Blobs” is drawn through TextlineProjection::PlotGradedBlobs [textord/textlineprojection.cpp] ONLY
  • NOTE the difference between PlotGradedBlobs and TO_BLOCK::plot_graded_blobs
  • It ONLY has three colours:
    • ScrollView::YELLOW: UniquelyVertical
    • ScrollView::RED : bad_box after TextlineProjection::BoxOutOfHTextline
    • ScrollView::BLUE:
// Display the blobs in the window colored according to textline quality.
void TextlineProjection::PlotGradedBlobs(BLOBNBOX_LIST* blobs,
                                         ScrollView* win) {
#ifndef GRAPHICS_DISABLED
  BLOBNBOX_IT it(blobs);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    BLOBNBOX* blob = it.data();
    const TBOX& box = blob->bounding_box();
    bool bad_box = BoxOutOfHTextline(box, NULL, false);
    if (blob->UniquelyVertical())
      win->Pen(ScrollView::YELLOW);
    else
      win->Pen(bad_box ? ScrollView::RED : ScrollView::BLUE);
    win->Rectangle(box.left(), box.bottom(), box.right(), box.top());
  }
  win->Update();
#endif  // GRAPHICS_DISABLED
}

=== 25/05/2017更 ===

  • The following debugging windows from StrokeWidth::FindInitialPartitions are using mixed colour scheme for displaying blobs
    • ”Initial text chains”
    • “GoodTextline blobs”
    • “Diacritics”
    • “Smoothed blobs”
  • From template<class BBC, class BBC_CLIST, class BBC_C_IT>
    void BBGrid<BBC, BBC_CLIST, BBC_C_IT>::DisplayBoxes
  • Where BBC is initialised as ColPartition [textord/colpartition.cpp]
#ifndef GRAPHICS_DISABLED
// Provides a color for BBGrid to draw the rectangle.
// Must be kept in sync with PolyBlockType.
ScrollView::Color  ColPartition::BoxColor() const {
  if (type_ == PT_UNKNOWN)
    return BLOBNBOX::TextlineColor(blob_type_, flow_);
  return POLY_BLOCK::ColorForPolyBlockType(type_);
}
#endif  // GRAPHICS_DISABLED

=== 23/05/2017更 ===

#ifndef GRAPHICS_DISABLED
/// Returns a color to draw the given type.
ScrollView::Color POLY_BLOCK::ColorForPolyBlockType(PolyBlockType type) {
  // Keep kPBColors in sync with PolyBlockType.
  const ScrollView::Color kPBColors[PT_COUNT] = {
    ScrollView::WHITE,        // Type is not yet known. Keep as the 1st element.
    ScrollView::BLUE,         // Text that lives inside a column.
    ScrollView::CYAN,         // Text that spans more than one column.
    ScrollView::MEDIUM_BLUE,  // Text that is in a cross-column pull-out region.
    ScrollView::AQUAMARINE,   // Partition belonging to an equation region.
    ScrollView::SKY_BLUE,   // Partition belonging to an inline equation region.
    ScrollView::MAGENTA,      // Partition belonging to a table region.
    ScrollView::GREEN,        // Text-line runs vertically.
    ScrollView::LIGHT_BLUE,   // Text that belongs to an image.
    ScrollView::RED,          // Image that lives inside a column.
    ScrollView::YELLOW,       // Image that spans more t
<think>好的,用户的问题是关于在Visual Studio 2022中配置leptonica-1.78.0库的指南或解决方案。我需要根据提供的引用内容来组织答案,同时遵循系统级指令中的格式要求。 首先,用户提供的引用内容提到了使用CMake生成leptonica的解决方案,以及如何修改配置来适配不同的Visual Studio版本。例如,引用[1]和[4]详细描述了使用CMake生成项目文件、构建目录的设置,以及在VS中的编译步骤。引用[3]提到修改cppan.yml文件中的VS版本设置,这可能与用户的问题相关,但需要注意用户是否使用CPPAN,或者是否需要手动调整CMake配置。 接下来,我需要将这些步骤整理成一个清晰的指南。根据引用[1]和[4],步骤大致包括:解压源码、使用CMake生成VS项目、配置生成选项、编译生成库文件。同时,引用[4]还提到了在VS中配置解决方案为Release和x64平台,并勾选INSTALL选项,这样库文件会安装到指定目录。 需要注意用户可能遇到的问题,比如CMake配置时的路径选择是否正确,生成解决方案时是否选择了正确的平台(x64或x86),以及是否需要修改cppan.yml中的设置(如引用[3]所述)。此外,引用[5]提到了QT和OpenCV的配置,但用户当前的问题主要集中在leptonica,所以可能不需要涉及这部分,除非用户后续有其他需求。 另外,用户可能不熟悉CMake的使用,所以需要详细说明如何在CMake中设置源码路径和构建路径,如何配置生成器为VS2022,以及如何处理可能的错误,比如依赖项缺失或路径错误。例如,引用[4]中提到的活动解决方案配置和平台的选择,以及生成后的库文件位置,这些都是关键步骤。 同时,需要确保回答中的LaTeX格式正确,行内公式用$...$,独立公式用$$...$$,但在这个问题中可能涉及代码块和步骤说明,所以需要正确使用代码块的格式,如示例中的Python代码块。但用户的问题是关于C++库的配置,所以可能需要使用CMake和VS相关的代码或命令。 最后,生成相关问题时要考虑用户可能的后续步骤,比如如何将leptonica与其他库(如Tesseract)结合使用,如何处理编译错误,或者如何配置项目属性以链接库文件。这些问题可以帮助用户进一步解决实际开发中可能遇到的问题。</think>以下是根据引用内容整理的$Visual Studio 2022$配置$leptonica-1.78.0$库的详细步骤: ### 一、环境准备 1. 下载leptonica-1.78.0.zip并解压到指定目录(如$H:\leptonica-1.78.0$) 2. 安装CMake 3.20+和Visual Studio 2022(需包含C++开发组件)[^5] ### 二、CMake生成解决方案 ```bash # 在解压目录新建构建目录 mkdir build_x64 ``` 1. 打开CMake GUI工具 2. 设置源码路径为$H:\leptonica-1.78.0$ 3. 设置构建路径为$H:\leptonica-1.78.0\build_x64$ 4. 点击"Configure",选择生成器为$Visual Studio 17 2022$,平台选x64 5. 若需静态库,修改`BUILD_SHARED_LIBS`为OFF[^4] ### 三、VS2022编译安装 1. 打开生成的$leptonica.sln$解决方案 2. 在配置管理器: - 活动解决方案配置:Release - 活动解决方案平台:x64[^4] 3. 右键解决方案选择"生成解决方案" 4. 勾选`INSTALL`项目后重新生成,库文件将输出到$C:\Program Files (x86)\leptonica$[^4] ### 四、项目配置 1. 添加包含目录: ```makefile C:\Program Files (x86)\leptonica\include ``` 2. 添加库目录: ```makefile C:\Program Files (x86)\leptonica\lib ``` 3. 添加附加依赖项: ```makefile lept.lib ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值