Error: ‘cvLoadImage’ was not declared in this scope

Good day.

Recently, I’ve been trying to update the Player repository to work with the latest stable version of OpenCV (I’m running 4.9.0).
I made an issue report on GitHub about it for more detailed information:

I managed to make almost all of the base code work with the current available libraries and headers, but there’s two specific C files that use cvLoadImage in them (SimpleShape and ImageSeq), and it seems like OpenCV 4 completely removed any declaration for it in its headers.

I tried declaring it manually with:
IplImage* cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR));
But that throws an “undefined reference” error near the end of compilation.

So my question is, how can I properly declare back cvLoadImage so I can make the final two C files compile?

Thanks in advance.

PS: I’m aware this is using old OpenCV1 C API code, the reason why I want to make this compile while still using the old C API code is so I can have a base code to work with and compare before I begin the proper upgrade of the functions and code to OpenCV 4 functions.

you’ve been told on the github issue that those APIs were removed. you can’t bring them back.

use the current APIs.

I did attempt to change the cvLoadImage function to imread instead in the imageseq file, but I got issues when converting it. Maybe I missed something.

I tried with the following:

This excerpt of code is the one I tried to convert from cvLoadImage:

  IplImage *image;

  // Load image; currently forces the image to mono
  image = cvLoadImage(filename, -1);
  if(image == NULL)
  {
  		PLAYER_ERROR1("Could not load image file: %s", filename);
		return -1;
  }
...
  cvReleaseImage(&image);

To imread:

  IplImage image;
  cv::Mat  image2;

  image2 = cv::imread( filename, cv::IMREAD_UNCHANGED );
  image = image2;

  if( image2.empty() )
  {
  		PLAYER_ERROR1("Could not load image file: %s", filename);
		return -1;
  }
...
  //cvReleaseImage(&image);

(I also changed all the instances of image->XXXX to image.XXXX within the code)
However, when compiling after making those changes I get the following error:

error: no match for ‘operator=’ (operand types are ‘IplImage’ and ‘cv::Mat’)
  212 |   image = image2;
      |           ^~~~~~

Seems like that’s the only error popping up after making the change.
Did I miss something about a pointer or something related to it?

PS: I made these changes based on the commit history for the highgui.hpp file, specifically this commit with the changes made inside modules/video/test/test_optflowpyrlk.cpp: