Step 1: Download all the required tools
- OpenCv - https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.1.0/opencv-3.1.0.exe/download
- Tesseract - https://github.com/tesseract-ocr/tesseract/wiki/Downloads
- Visual Studio 2013
- Extract the downloaded OpenCv installer to C drive or any preferred drives.
Copy all the downloaded files to C drive where you have already extracted OpenCv.
Step 4: Setting up VS 2013
Run Visual Studio 2013 set to get it installed.
By this step I hope all the required tools are downloaded and got it installed/copied to respective drives.
Step 4: Setting up environment variables
- Right click on My Computer>> properties
- Then click on Advanced System Settings
- Click on Environment Variables under Advanced tab.
- Then click on new under System variables
- Add variable name as OPENCV_DIR and variable value as C:\opencv\build\x64\vc12\bin (this is the path of openCv bin folder check where you have copied your openCv files)
- Create one more new System variable and fill the details as variable name as TESSDATA_PREFIX variable value as C:\Tesseract-Build\tesseract-vs2013\ (this is the path of tesseract bin folder check where you have copied your tesseract files)
- Now search for Path variable under System variables and add the following followed by a ;C:\opencv\build\x64\vc12\bin;C:\Tesseract-Build\tesseract-vs2013\build\lib\x64
Step 6: Configuring OpenCv and Tesseract for VS 2013
- Launch VS 2013.
- File >> New >> Project(Ctrl+Shift+N)
- Choose Visual C++ >> Win32 Console Application
- Give a name for your new project and click OK to continue
- Click Next to continue
- Click Finish to complete
- Right over the project under Solution Explorer and select the option Properties(Alt + Enter)
- Under C/C++ .. select the Additional Include Directories and add the path of Tesseract and OpenCv include folders something as below
C:\Tesseract-Build\tesseract-vs2013
C:\opencv\build\include
opencv_world310.lib
- Then select General under Linker and add all the library paths for tesseract and OpenCv, something as below. You can check the tesseract and OpenCv folders which you have already copied to your C drive to get the exact path
C:\Tesseract-Build\tesseract-vs2013\lib
C:\opencv\build\x64\vc12\lib\
$(OPENCV_DIR)\lib
- Then Move on to Input under Linker and add the following, which can be found under C:\opencv\build\x64\vc12\lib and C:\Tesseract-Build\tesseract-vs2013\build\lib\x64
opencv_world310.lib
opencv_world310d.lib
liblept168.lib
libtesseract302.lib
- That's it now OPenCv & Tesseract is successfully configured for Visual Studio 2013.
- Note - You need to configure similarly whenever you create a new project.
- So Let us test it now
- Save the below hello world image and copy it to your project folder something similar as below path: Visual Studio 2013\Projects\openCvtest\openCvtest
-
- Now create a new C++ file by right clicking on source files
- Now open the newly created C++ file and paste the below code
#include "opencv2/core/core.hpp"
#include"opencv2/highgui/highgui.hpp"
using namespace cv;
using namespace std;
#include <iostream>
int main(int argc, const char** argv)
{
Mat img = imread("helloworld.jpg", CV_LOAD_IMAGE_UNCHANGED);
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
return 0;
}
- Then press Ctrl+F5 to compile the code
- This window opens up an image window with Hello World Text as shown below.
- That's it you have successfully configured openCv and tesseract for VS2013
From the Tesseract download link,I got only vs2010 only not vs2013 and inside the lib folder there is no \lib\x64?????
ReplyDelete