This is the same issue as #1492
To be able to pass cv::Mat in cv_image constructor
Compilation error with OpenCV version 4.0.0 and above.
/dlib/opencv/cv_image.h:37:22: **error**: conversion from ‘const cv::Mat’ to non-scalar type ‘IplImage’ {aka ‘_IplImage’} requested
IplImage temp = img;
try to construct cv_image from cv::Mat
the same as in #1492
You need to post more detailed instructions because I am not able to reproduce this. See also this recent thread: https://github.com/davisking/dlib/pull/1494#issuecomment-565770272 where someone asked the same question, only later to report that this isn't an issue.
Thank you very much for the reply.
I will try to explain it a bit detailed.
This is code snippet from my C++ project:
dlib::array2d<unsigned char> dlib_img;
dlib::assign_image(dlib_img, dlib::cv_image<unsigned char>(_mat));
within the dlib::cv_image constructor there is a statement
IplImage temp = img;
The above statement causes compilation error with OpenCV 4.x.y.
To fix the problem I have changed the above line from cv_image constructor to this:
temp = cvIplImage(img);
I have just cloned the master branch from the OpenCV github.
I have installed dlib 19.19.
Thanks for the report. I just pushed a change to github that should fix this for all versions of OpenCV.
Thank you very much for the fix. Everything is OK now.
For resolve compilation error, the following code could be used:
IplImage ipl_img = cvIplImage(image);
dlib::cv_image<dlib::bgr_pixel> cimg(&ipl_img);
@amir-saniyan
or simply:
`
dlib::assign_image(dlib_img, dlib::cv_image<unsigned char>(cvIplImage(ocv_mat)));
Most helpful comment
For resolve compilation error, the following code could be used: