I am trying to compile the Tesseract OCR code and have run into many problems. One is that the tessembeded.cpp function calls the "edges_and_textord" function and that other .cpp files call the "find_components" function. The "edges_and_textord" function is in the textord.cpp file that I downloaded from google, but the "find_components" function is not. However when I searched google for "textord.cpp" I found a completely different version of "textord.cpp" (here) with the "find_components" function in it. They both have identical commented header information at the very begining of the file (down to the date and time they were created).
So my question is, which one do I use? The tesseract code calls both of these functions so should I add the second "textord.cpp" file in under a different name?
I have run into the same problem with the "start_recog" function. The definition I have in my tface.cpp file is
"int Wordrec::start_recog(const char *textbase)"
but I have found another version of the file on Tesseract's website with the definition
"int start_recog(const char *configfile, const char *textbase)"
And tessembedded.cpp seems to call it using the second definition not found in the code I downloaded. Should I just replace what I downloaded with the second file?
Why are there these double files in the Tesseract code?
Related
I have question about replacing <THC/THC.h> method.
Recently, I'm working on installing different loss functions compiled with cpp and cuda.
However, what I faced was a fatal error of
'THC/THC.h': No such file or directory
I found out that TH(C) methods were currently deprecated in recent version of pytorch, and was replaced by ATen API (https://discuss.pytorch.org/t/question-about-thc-thc-h/147145/8).
For sure, downgrading my pytorch version will solve the problem. However, due to my GPU compatibility issue, I have no choice but to modify the script by myself. Therefore, my question can be summarized into follows.
First, how can I replace codes that have dependency of TH(C) method using ATen API?. Below are codes that I have to modify, replacing those three lines looked enough for my case.
#include <THC/THC.h>
extern THCState *state;
cudaStream_t stream = THCState_getCurrentStream(state);
Second, will single modification on cpp file be enough to clear the issue that I'm facing right now? (This is just a minor question, answer on first question will suffice me).
For reference, I attach the github link of the file I'm trying to build (https://github.com/sshaoshuai/Pointnet2.PyTorch).
After struggling for a while, I found the answer for my own.
In case of THCState_getCurrentStream, it could directly be replaced by at::cuda::getCurrentCUDAStream(). Therefore, modified code block was formulated as below.
//Comment Out
//#include <THE/THC.h>
//extern THCState *state;
//cudaStream_t stream = THCState_getCurrentStream(state);
//Replace with
#include <ATen/cuda/CUDAContext.h>
#include <ATen/cuda/CUDAEvent.h>
cudaStream_t stream = at::cuda::getCurrentCUDAStream();
After replacing the whole source code, I was able to successfully build the module.
Hope this helps.
I'm searching for a tool to get the used header (if there is one/more) for every line/statment in my c++ code.
Example:
#include<iostream>
std::cout << "hallo";
The output i'd like to see:
line 2: std::cout uses "iostream"
I found this question, the tools there do most of the part, they show dependency per file.
Does anyone know such a tool or how to acomplish this with the tools given in the answers in the question above?
Goal: I'm checking code for the conformity to a standard which i have a list of allowed headers for. With the desired output I can create a metric saying something like: 60% of the code is using allowed headers, 15% is using other headers or something like that.
This is not completely what you want but you can use Eclipse CDT to know where std::cout is declared.
If you press F3 when cout is selected in Eclipse, you will jump to this line of code inside iostream header file on the system with gcc 7:
extern ostream cout; /// Linked to standard output
You can try CppDepend to get all the methods called by a specific one with the location of each method called.
I have implemented a complex mexFunction using visual studio 2012 and successfully integrated it with Matlab. (lets call it mexFunctionA.mexw32 )
When I run this command in matlab command window, I get the expected results:
mexFunctionA("My1Argument", "My2Argument");
Now , I need to develop a mexFunctionB that calls mexFunctionA; mexFunctionB is a simple as it can be.
The C code I´m trying (inside mexFunctionB.c) is:
#include "mexFunctionA.mexw32"
(...)
static void mdlOutputs(SimStruct *S, int_T tid)
{
mexFunctionA("My1Argument", "My2Argument");
}
(...)
This line of code is not compiling.
The command line I am using is:
mex -v mexFunctionB.c -I'C:\patchToMexFunctionA' -L'C:\patchToMexFunctionA' 'mexFunctionA.mexw32'
So, here are the possible errors:
The #include method is wrong.
The command line for compiling the code is wrong.
It is not possible to do what I am planning to do.
Something else.
Anyone knows how to fix it?
The code you give is non-sensical. .mexw32 files are dynamically linked libraries (i.e. dll's), and in C code #include statements aren't used to include dll's.
Firstly note that as far as your S-Function is concerned mexFunctionA is no different from any other MATLAB function. So the question you should be asking is "how do I call a MATLAB function from within a mex file?".
The answer to that is to use the function mexCallMATLAB.
In short, you need to remove the #include and reformat the call to mexFunctionA to the form required by mexCallMATLAB.
I've been modifying an example C++ program from the Caffe deep learning library and I noticed this code on line 234 that doesn't appear to be referenced again.
::google::InitGoogleLogging(argv[0]);
The argument provided is a prototxt file which defines the parameters of the deep learning model I'm calling. The thing that is confusing me is where the results from this line go? I know they end up being used in the program because if I make a mistake in the prototxt file then the program will crash. However I'm struggling to see how the data is passed to the class performing the classification tasks.
First of all, argv[0] is not the first argument you pass to your executable, but rather the executable name. So you are passing to ::google::InitGoogleLogging the executable name and not the prototxt file.
'glog' module (google logging) is using this name to decorate the log entries it outputs.
Second, caffe is using google logging (aka 'glog') as its logging module, and hence this module must be initialized once when running caffe. This is why you have this
::google::InitGoogleLogging(argv[0]);
in your code.
I am working with Visual Studio on C++ code, and I send some variables to MATLAB engine. So far there is no problem. Imagine I have the MATLAB command window opened and these variables:
» whos
Name Size Bytes Class Attributes
QWe 1x365 2920 double
QWp 1x364 2912 double
QWu 1x364 2912 double
I can use the standard MATLAB functions, but I have dowloaded a new function.m (which works in MATLAB normally after setting the path) that this command window from MATLAB's engine is not recognizing or finding.
» isnormq(Q)
??? Undefined function or method 'isnormq'
I thought they (command window and MATLAB) were synchronized but now I see they aren't.
How can I solve this so I can use my function.m from the command window? Any help will be welcomed.
As it has been a long time and nobody answered I will post what I did:
In Matlab everytime you need a newtoolbox you link the path once and there stays "forever". You can use functions from the toolbox as if they were by default in Matlab.
Using matlab engine this doesn't work that way so it is necessary to write the command line:
% Here we load the toolbox for converting quaternion to Euler Angles
addpath(genpath('C:\Program Files (x86)\MATLAB\R2010a\toolbox\SpinCalc')); //for example
It's been a long time but I face the same problem and find some interesting information about it.
First of all at the newer version of MATLAB (2016a) MATLAB Engine search path is C:\Program Files\MATLAB\R2016a (Or the same path where you install MATLAB). So if you don't change it C++ can use all the build-in functions. Furthermore, you can using functions from Toolboxes!
But there is another one problem: what about user defined functions? So I need to put .m file directly to C:\Program Files\MATLAB\R2016a to make it visible for MATLAB Engine.
Here we can go another way - just add the path of your .m file to MATLAB through C++:
char CommandChangePath[MAX_PATH];
strcpy(CommandChangePath, "addpath('C:\\Users\\SuperUser\\Documents\\Visual Studio 2017\\Projects\\MyCppProject')");
engEvalString(ep, CommandChangePath);
For me its very useful to put necessary MATLAB function in current C++ project, add the path and use then! Now you don't need to change the path at every step - it's remembered and useful always for current application.