gpt4 book ai didi

c++ - 如何将 tesseract-ocr 库集成到 CMakeLists.txt 中?

转载 作者:太空狗 更新时间:2023-10-29 21:20:16 30 4
gpt4 key购买 nike

我不知道如何将 tesseract-ocr 库集成到我的 ros 项目中,我使用 qt creator 进行编码并且库已正确安装,因为 Qtcreator 会自动完成我使用该库的行,但此代码无法编译

#include "text_detector.h"
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <tesseract/baseapi.h>

image_transport::Subscriber sub;
image_transport::Publisher imPub;
ros::Publisher textPub;
tesseract::TessBaseAPI tess;

void onImageReceived(const sensor_msgs::ImageConstPtr& msg){

}

int main (int argc, char* argv[]){
ros::init(argc,argv,"text_detector");
ros::NodeHandle nh;
ROS_INFO_STREAM("Starting text detection");
image_transport::ImageTransport it(nh);
imPub = it.advertise("camera_hsv",1);
tess.Init(NULL,"eng",tesseract::OEM_DEFAULT);
sub = it.subscribe("camera_raw",1,&onImageReceived);
// textPub=nh.advertise<>("text",1000);
ros::spin();
}

编译错误

text_detector.cpp:-1: error: undefined reference to tesseract::TessBaseAPI::TessBaseAPI()'
text_detector.cpp:-1: error: undefined reference to
tesseract::TessBaseAPI::~TessBaseAPI()'

如何将库添加到 CMakeLists.txt 中的项目?谢谢!

最佳答案

看起来您没有链接库。你的 CMakeLists.txt 应该包含

target_link_libraries (<YOUR-EXECUTABLE-NAME>  tesseract)

根据您的 CMake 文件,可能只是 ${PROJECT_NAME}

关于c++ - 如何将 tesseract-ocr 库集成到 CMakeLists.txt 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25022183/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com