Reputation: 329
I need to look at the source code of the following opencv C functions but I have not yet found the right directories in the opencv source code.
cvSmooth()
cvResize()
cvSaveImage()
I am using OpenCV 2.3.1, does anyone know where can I find the source code for these three functions in C?
Upvotes: 0
Views: 397
Reputation: 1906
It's easy with grep, given that they use at least part of the GNU code style which puts a function's return type on the line above the implementation and that grep can search for patterns that include a start of a line token, as the grep manual says:
Grep manual: The caret ^ and the dollar sign $ are metacharacters that respectively match the empty string at the beginning and end of a line. The symbols \< and > respectively match the empty string at the beginning and end of a word. The symbol \b matches the empty string at the edge of a word, and \B matches the empty string provided it's not at the edge of a word.
grep "^cvSmooth" -rn .
The -r
options tells grep to search recursively so that it'll search through all sub folders of the path you ask it to search.
The -n
option tells grep to include the line number of any matches it finds which can help us further narrow down what we're looking for.
The .
path designator on the end tells grep to search the current directory.
This gives me the following output:
./modules/imgproc/src/smooth.cpp:3514:cvSmooth( const void* srcarr, void* dstarr, int smooth_type,
which tells you exactly where to find the implementation of cvSmooth in the source code. You can do the same for the rest of the functions you want to find.
Learn to use grep because it's invaluable when trying to navigate source code, especially large projects. Plus, thank the authors of openCV for using that code style policy because that REALLY helps when grepping!
Upvotes: 1