Ask Your Question
3

How to integrate tesseract-ocr library in a catkin project?

asked 2014-07-29 11:53:07 -0500

sirasistant gravatar image

updated 2014-07-29 13:23:42 -0500

Hi, I have no idea of how to integrate the tesseract-ocr library to my project, i use qt creator to code and the library is correctly installed since Qtcreator autocompletes the lines where i use the library but this code fails to compile

#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();
}

with this compilation error

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

How can i add the library to the project in the cmakelists.txt? Thanks!

edit retag flag offensive close merge delete

Comments

I want to execute this node for my project but i am facing some errors, can you please post me the complete node (.cpp file) and CMakeLists.text.

Kishore Kumar gravatar imageKishore Kumar ( 2015-07-20 05:56:27 -0500 )edit

Hi @sirasistant! As @Kishore Kumar, I'm also interested in your findings. Are you able to share what you have right now? Thanks in advance!

TSC gravatar imageTSC ( 2015-08-28 13:48:57 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
5

answered 2014-07-29 15:04:48 -0500

ahendrix gravatar image

The project's API Samples page gives the proper command-line arguments for building and linking against the tesseract_ocr library: "g++ -o myprogram myprogram.cpp -llept -ltesseract"

In cmake, you can link against libraries using target_link_libraries(); cmake will automatically add the -l flag for you, so all you have to do is:

target_link_libraries(my_tesseract_node lept tesseract)

edit flag offensive delete link more

Comments

That was it! thank you very much :D

sirasistant gravatar imagesirasistant ( 2014-07-30 10:11:47 -0500 )edit

appreciate, saves me a lot of time.

mikelilin gravatar imagemikelilin ( 2015-11-19 06:37:12 -0500 )edit
0

answered 2015-12-17 21:35:08 -0500

I find another free online ocr to convert image to text, it's using google tesseract ocr 3.02.

edit flag offensive delete link more

Comments

This forum is for questions and answers about ROS (Robot Operating System). How is your answer related to ROS?

ahendrix gravatar imageahendrix ( 2015-12-17 23:06:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-07-29 11:53:07 -0500

Seen: 1,441 times

Last updated: Nov 19 '15