Tesseract in QT - c++

This is the first time I am asking a question here.
I want to use Tesseract API in QT.
My idea was to design a programme using QT that would read aloud messages (QSpeech) from Telegram Desktop version (not that important).
Tesseract came across as a tool I needed so I tried to implement it. I wanted to use its API, but finally I ended up using QProcess to call Tesseract as a programme.
HERE'S THE PROBLEM.
After including tesseract and leptonica libraries to .pro file i get this:
(.qtversion[qt_version_tag]+0x0):-1: error: undefined reference to `qt_version_tag'
How to fix it?
I use QT 5_12_3
I included the libs.
INCLUDEPATH += "/usr/include"
LIBS += -L"/usr/local/lib" -ltesseract
INCLUDEPATH += "/usr/include"
LIBS += -L"/usr/lib/x86_64-linux-gnu" -llept
I downloaded QT from the official website. Tesseract API code is an example taken from the documentation. From the same documentation I followed instructions to download everything needed. As I mentioned before, if I compile a text file with the code sample, then it works fine. I just can't integrate it into QT.

Tesseract and Leptonica create pkg-config files, so you didn't have to manually add INCLUDEPATH or LIBS to your project, instead use
QT_CONFIG -= no-pkg-config
Config *= link_pkgconfig
PKGCONFIG *= tesseract
If it doesn't work for you, check whether the Tesseract is installed correctly (also check that you have tesseract.pc file in your system).

Related

Update translation file using Boost library Qt C++

I am using the Boost library in my C++ project.
I am including it in the PRO file like this:
win32: INCLUDEPATH += C:/boost_1_60_0
win32: LIBS += "-LC:/boost_1_60_0/stage/lib/"
But, when I run the following command on the terminal (cmd) to update my translation file:
lupdate MyProject.pro
It searchs for files in the Boost library path to update.
Is this normal? What can I do to not search in the Boost library path?
Now, I am commenting the Boost include lines when I need to run the lupdate command, but I don't want to do it every time I need to update my translation file.
Qt 5.3.2
Boost 1.6.0
There is a workaround in the bug report (QTBUG-27936), involving the TR_EXCLUDE option in the .pro project. It is used to tell lupdate to exclude certain files. I tested with Qt 5.6 and 5.8 and it worked as expected. Here there is the extract of my .pro file:
INCLUDEPATH += /Users/user/libs/boost
TR_EXCLUDE += /Users/user/libs/boost/*
PREVIOUS ANSWER
This is the previous answer, which I couldn't confirm and it happens to be wrong. I'm letting it here so it's kept documented. There is a workaround in the bug report (QTBUG-27936), which is to include all Boost libraries in the precompiled header, since lupdate doesn't look at it.

Bind Qt with QtGStreamer

I am trying to make a simple qt c++ VoIP application, when I searched I found the QtGStreamer Lib and wanted to make it work. I download the latest version 1.2 from here.When I went to the example folder and tried to compile the VoIP example I got this error:
Qt5GStreamer-1.0 development package not found
What I try is comment this line CONFIG += link_pkgconfig in .pro file and add the src folder that came with the folder of QtGstreamer to folder project. I also added this to .pro file INCLUDEPATH += $$PWD/src this the path of the Libs folder
Now I get an error that i need to add boost Lib so I add it by adding this to .pro file
INCLUDEPATH += C:/boost_1_61_0
LIBS += "-LC:/boost_1_61_0/stage/lib"
Now I get many errors that say (undefined reference to ..) 130 error. Not sure what to try.
the file comes with containing Readme file I download the dependency but the same error I think the problem that I don't link it correctly I'm still a beginner in 3rd party and link libs in c++,
my os is windows
Thanks in advance

Fail to link Pylon(Basler) SDK with Qt on Mac

I am trying to link Qt with the Pylon camera SDK in a Qt Creator project.
I install the pylon Camera Software Suite app from this pylon for OS X and the pylon framework is install at /Library/Frameworks/pylon.framework.
I first follow the pylon Programmer's Guide which is installed with the app to link the pylon with Xcode. It works perfectly.
Then I try to link with my Qt Project. I add this in the .pro file:
mac: LIBS += -F/Library/Frameworks/ -framework pylon
# add GenICam because pylon Programmer's Guide do so
INCLUDEPATH += /Library/Frameworks/pylon.framework/Headers/GenICam
DEPENDPATH += /Library/Frameworks
But this doesn't work. Qt cannot find the header files.
I also try:
QMAKE_LFLAGS += -F/Library/Frameworks/
LIBS += -framework pylon
as said in the document Using Frameworks. But still not working. Anyone help me to fix this? Thanks.
Update:
Weird is that Qt can detect auto-complete of the header files but when build it says no such file found.
I just answered this here:
A) If you are compiling this Pylon framework with source then In these cases you need source code installation, you need to go to your
Pylon source directory, e.g.:
<path-to-pylon>/src/include/
You can locate the directory where PylonIncludes.h is installed by
runing the following command:
find <path-to-Pylon> -name PylonIncludes.h
Once you locate the directory e.g. lets say
/Users/kevin/Pylon5.5 then you include add the following line in your
CMAkeLists.txt
INCLUDEPATH += /Users/kevin/Pylon5.5/src/include/
B) If you have binary framework itself then you can workaround by copying all headers to tmporary location under pylon/<all-headers>
cp -rf /Library/Frameworks/pylon.framework/Versions/A/Headers/* /tmp/pylonHeaders/pylon/ Then use following in .pro file
INCLUDEPATH += /tmp/pylonHeaders
LIBS += -framework pylon
There is an automatism in Xcode when you insert a framework it includes the header directory of the used frameworks automatically.
In your case, simple add this line and the compiler will find the pylon headers.
QMAKE_CXXFLAGS += -F/Library/Frameworks
I hope this will help you. With best regards

Installing libusb on windows for use with Qt

I'm trying to install libusb (not libusb-win32) on windows 7. I have to link it with Qt 5.0.1. Here are the problems I'm facing
In the INSTALL file in the extracted libusb folder, it tells me to cd to the current folder then run
./configure
make
makeinstall
But I got the error
'./configure' is not recognized as a valid command.
Googling this problem usually gives the solution as installing libusb-win32. However, I want to avoid that, as of now.
In the libusb library, there were a few MSVC projects, so I built them. That did generated some .lib files. So I proceeded to link them with my Qt project. It recognizes the libusb.h header file but does not link properly. Here is my .pro file
QT += core gui widgets
TARGET = Qt_libusb TEMPLATE = app
SOURCES += main.cpp\
qt_libusb.cpp
HEADERS += qt_libusb.h
FORMS += qt_libusb.ui
LIBS += -LC:\libusb-1.0.18\Win32\Debug\lib\libusb-1.0
INCLUDEPATH += C:/libusb-1.0.18/libusb DEPENDPATH += C:/libusb-1.0.18/libusb
My objective is to link the libusb library with Qt. Please tell me if I haven't 'installed' the library correctly or if I am linking it in a wrong way. thanks
Your project file does not reference the library. You only provide a path where libraries might be found, but there's no reference to the libusb library itself.
What you're missing is something like
LIBS += -llibusb
You also can't have multiple project file statements on the same line. The below is an error:
TARGET = Qt_libusb TEMPLATE = app
It should look like:
TARGET = Qt_libusb
TEMPLATE = app

How to link QT and OpenCV in Linux

I'm trying to link QT with the OpenCV library, but I can't.
OpenCV works, Qt works, but I can't work with both together.
I add a build step in the Qt creator, and this kind of work, I mean, I write cv:: and automatically a list has been show with all methods of OpenCV, but when I compile, I have around 20 errors, with OpenCV methods.
But, if i compile the same code in terminal, without Qt, all is fine.
Anyone knows how to link Correctly OpenCV and Qt?
Please help :(
Qt version: 5.2.1
Qt Creator version: 3.0.1
OpenCV version: 2.4.8
PD: remember, I'm using Linux, there are thousands of tutorials about this but in windows :/
PD2: Sorry for my English.
Edit: This is an example of my error, this happen with all OpenCV methods, like imread and waitKey
error: undefined reference to `cv::getRotationMatrix2D(cv::Point_, double, double)'
In your QtCreators Edit view you need to add a link to the library files, on my setup I have this within my .pro file:
CONFIG += use_webcam_opencv
...
use_webcam_opencv {
message("Using OpenCV Webcam")
LIBS += -lopencv_core247 -lopencv_highgui247
HEADERS += widgets/camerawidget.h \
widgets/camerawindow.h
SOURCES += widgets/camerawidget.cpp \
widgets/camerawindow.cpp
}
The HEADERS and SOURCES are of course my own, since I only compile them if I enable OpenCV.
Do you have pkg-config configured/installed with opencv?
You can check by simply typing 'pkg-config pkg-config opencv --libs. If you get any output, you're good.
Then, in QT, just edit .pro project setting file and add the following line(I had to put the image as I didn't know how to put those quotes in an answer) :-
http://imgur.com/DtQ0Zjr
Sample .pro file : http://pastebin.com/KDYqW5Wj
Should Work