Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCVBridge Compile error ITK 5.1RC1 #1651

Closed
AzHicham opened this issue Feb 24, 2020 · 4 comments
Closed

OpenCVBridge Compile error ITK 5.1RC1 #1651

AzHicham opened this issue Feb 24, 2020 · 4 comments
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Milestone

Comments

@AzHicham
Copy link

AzHicham commented Feb 24, 2020

Description

I managed to compile ITK 5.1RC1 with OpenCV Bridge, after some corrections (already fixed on master or ongoing).
Everything works pretty well, except when I use OpenCVImageBridge function.

I have the folowing error :
C:\Program Files\ITK\Release\include\ITK-5.1\itkOpenCVImageBridge.hxx(98): error C2440: 'initializing': cannot convert from 'const cv::Mat' to 'const IplImage'

I fixed this error using

const IplImage converted = cvIplImage(in);
instead of 
const IplImage converted = in;

on line 98 (itkOpenCVImageBridge.hxx)

Versions

OpenCV 4.2
ITK 5.1RC1

Environment

Windows 10 x64
MSVC 2019 16.4

Additional Information

@AzHicham AzHicham added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Feb 24, 2020
@dzenanz
Copy link
Member

dzenanz commented Apr 9, 2020

Is this issue still open? #1650 might have touched it.

@Giaco90
Copy link

Giaco90 commented Apr 21, 2020

@Hicham-Damae solution worked for ITK 5.0.1 and OpenCV 4.2.0 too.

@dzenanz
Copy link
Member

dzenanz commented Apr 21, 2020

Can either of you turn it into a PR?

@thewtex thewtex added this to the ITK 5.1.1 milestone Apr 24, 2020
@PierreWargnier
Copy link
Contributor

Hi, I was having the same error with ITK 5.2.0 and OpenCV 4.3.0 (latest stable version of both). The solution proposed by @Hicham-Damae works for me too. This is due to the fact that IplImage has been deprecated in OpenCV for quite a long time now. It was eventually removed in version 4.0.0 and only remains in the C API. The fix works because it is explicitely invoking the C API. This however, is only a temporary fix because the OpenCV C API is likely to be completely removed in future versions (it is already absent from the documentation as of version 4.3.0 - see https://docs.opencv.org/4.3.0/ - although it appears to be still accessible).

dzenanz pushed a commit that referenced this issue Jul 10, 2020
This fixes issue #1651 in a lasting manner by introducing specific implementations for functions CVMatToITKImage and ITKImageToCVMat
that no longer depend on the legacy C API while avoiding unnescessary memory copies.

This also fixes issue #1906 by adding support for int pixel type (IPL_DEPTH_32S in the
legacy C API, CV_32S in the C++ API) for both OpenCV legacy C and C++ APIs.

In addition, exceptions for pixel/component type mismatches and impossible conversions
were added to both IplImageToITKImage and CVMatToITKImage functions. Some extra functions
had to be introduced to ensure minimal code duplication/redundancy.
@thewtex thewtex modified the milestones: ITK 5.1.1, ITK v5.2.0 Aug 6, 2020
@thewtex thewtex closed this as completed Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Projects
None yet
Development

No branches or pull requests

5 participants