我不知道如何将tesseract-ocr库集成到我的ros项目中,我使用qt creator进行编码并且库已正确安装,因为Qtcreator自动填充我使用库的行,但此代码无法编译< / p>
#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:错误:未定义引用
tesseract::TessBaseAPI::TessBaseAPI()' text_detector.cpp:-1: error: undefined reference to
tesseract :: TessBaseAPI :: ~TessBaseAPI()&#39;
如何在CMakeLists.txt中将库添加到项目中? 谢谢!
答案 0 :(得分:3)
看起来您没有链接库。您的CMakeLists.txt
应包含
target_link_libraries (<YOUR-EXECUTABLE-NAME> tesseract)
根据您的CMake文件,可能只有${PROJECT_NAME}