Hey everybody,
I am rather new to C++ and i just registered for this forum because i need help with an issue that at first sight seems to be very specific, but is rather a general thing, I guess:
I am using the OpenCV library (2.3.1-7) and Qt-Creator (2.4.1) and I have this simplified piece of code that reads in an image as cv::Mat and then applies the OpenCV function pyrDown to the cv::Mat.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
using namespace std;
using namespace cv;
int main()
{
Mat image1=imread("../image1.jpeg");
imshow("image1",image1);
cv::Mat pyrimag;
pyrDown(image1,pyrimag);
imshow("pyrimag",pyrimag);
while(true) {
char c = cvWaitKey(33);
if( c == 'c' ) break;
}
return 0;
}
|
This piece of code runs just fine and puts out the two different images as exected.
What I need to do now is to retrieve the source code of the "pyrDown"-function and then modify it according to the needs of the project that I am working on.
If I comment out the following line
//#include "opencv2/gpu/gpu.hpp"
then this results in the following error message:
'pyrDown' was not declared in this scope.
Apparently, pyrDown only works if
#include "opencv2/gpu/gpu.hpp"
is included in my code. Therefore the header of pyrDown should be included in this file, correct??
I am using Qt-Creator and the tooltip text for "pyrDown" is as follows:
"void pyrDown(InputArray src, OutputArray dst, const Size &dstsize=Size())"
Therefore, when i checked the file "/usr/include/opencv2/gpu/gpu.hpp" (which is the complete path to the file), looking for the headers of "pyrDown" I expected to find a matching header.
But instead, I only found this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
//! smoothes the source image and downsamples it
CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrDownBuf;
CV_EXPORTS void pyrDown(const GpuMat& src, GpuMat& dst, PyrDownBuf& buf, Stream& stream = Stream::Null());
struct CV_EXPORTS PyrDownBuf
{
PyrDownBuf() : image_type(-1) {}
PyrDownBuf(Size image_size, int image_type_) : image_type(-1) { create(image_size, image_type_); }
void create(Size image_size, int image_type_);
private:
friend void pyrDown(const GpuMat&, GpuMat&, PyrDownBuf&, Stream& stream);
static Mat ker;
GpuMat buf;
Ptr<FilterEngine_GPU> filter;
int image_type;
};
|
Those are all the lines of code where the character string "pyrDown" is included.
To me, being rather a newbie, it is kind of strange that there is no header that matches the call of the function as it was included in my simplified code example at the very top of this post.
What I would like to understand is the following:
1) Is the file gpu.hpp really the one that stores the header that is used for the call in my code example? If so, I would like to understand why this is the case, since the data types of the parameters seem not to match (eg "GpuMat&" vs. "InputArray"). In gpu.hpp there are other files included, using the "#include"-command, but a text search in those files did not find any strings like "pyrDown" in any of them.
2) If gpu.hpp is not the header file that I am looking for, which one is the correct one and where can I find it?
3) The most important part for me is: Where can I retrieve the corresponding .cpp file for pyrDown, since this is crucial to the progress in my project. I have googled a lot and I found lots of .cpp files that were named "pyrDown.cpp" (example:
https://github.com/cdemel/OpenCV/blob/master/modules/ocl/src/pyrdown.cpp), but none of them seems to be the one that I am looking for since either the data types in the header are not in accordance with what I expect or there are #include commands for files that I do not have available on my machine. And I assume that any .cpp-file that tries to use files that are not on my computer can not be the one that is used for the call in the code example at the top of this post.
I guess that it is sth. rather simple, but after many hours of searching the internet and trying to work with the gpu.hpp-files that I found, I am pretty much stuck and have no clue how to approach the whole problem.
If anybody could give me a hint? I would really appreciate it! Thanks in advance!
Regards, Ron