Hello,

I am having a few problems with my image class using OpenCV.
I am getting the errors:

src/image.cpp: In constructor ‘Image<T>::Image(const char*, bool)’:
src/image.cpp:21: error: there are no arguments to ‘cvLoadImage’ that depend on a template parameter, so a declaration of ‘cvLoadImage’ must be available
src/image.cpp:21: error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
src/image.cpp:23: error: there are no arguments to ‘cvLoadImage’ that depend on a template parameter, so a declaration of ‘cvLoadImage’ must be available
src/image.cpp: In member function ‘void Image<T>::save(const char*)’:
src/image.cpp:44: error: there are no arguments to ‘cvSaveImage’ that depend on a template parameter, so a declaration of ‘cvSaveImage’ must be available

The header file is pretty standard, including cv.h for the required functions.

Code snippets below, with full files attached (image.hpp renamed to image.h otherwise it would not allow upload):

image.cpp Lines 18-25:

template<class T>
   Image<T>::Image(const char* filename, bool color = true) {

       if(color) {

         imgp = cvLoadImage(filename);         

       } else {

         imgp = cvLoadImage(filename,0);     

       } 

   }

image.cpp Lines 42-45:

template<class T>
   
void Image<T>::save(const char* filename) {

       cvSaveImage(filename, imgp); 

   }

Thanks alot for any help :)
Adam

Have you put

template <class T>
class Image {

};

And where is Image.hpp?

Hello,

I have read through that link. I am still at a loss as to exactly what i have done wrong, and how i would go about fixing it.

Any advice is much appreciated
Adam

That link deals entirely with your exact problem and why it occurs, and tells you how to fix or avoid it. Please read it through carefully, again. this->imgp = cvLoadImage( filename ); cvSaveImage( filename, this->imgp ); Good luck.

Hello,

The compiler has no errors now, thank you :)

The linker on the other hand.... I am getting:

g++ main.o image.o -o tpp1 `pkg-config --cflags opencv` `pkg-config --libs opencv`
main.o: In function `main':
main.cpp:(.text+0x8a): undefined reference to `Image<RgbPixel>::Image()'
main.cpp:(.text+0x93): undefined reference to `Image<RgbPixel>::Image()'
main.cpp:(.text+0x13b): undefined reference to `Image<RgbPixel>::Image(char const*, bool)'
main.cpp:(.text+0x14c): undefined reference to `Image<RgbPixel>::~Image()'
main.cpp:(.text+0x1e7): undefined reference to `Image<RgbPixel>::~Image()'
main.cpp:(.text+0x200): undefined reference to `Image<RgbPixel>::~Image()'
main.cpp:(.text+0x212): undefined reference to `Image<RgbPixel>::~Image()'
main.cpp:(.text+0x237): undefined reference to `Image<RgbPixel>::~Image()'
collect2: ld returned 1 exit status

My files are attached. Code is mostly the same as first post bar a few fixes to make it compile.

Thanks
Adam