user270700
user270700

Reputation: 759

How to handle multiple opencv version in a c++

I want to write a c++ code that can be build both in opencv version 3 and 4. But I found that CV_BGR2RGB in v3 is moved to COLOR_BGR2RGB in v4. I need that for an argument of cvtColor function.

In that case, how can I make it work in both version?

Upvotes: 0

Views: 769

Answers (1)

Nuzhny
Nuzhny

Reputation: 1927

Simple:

#include "opencv2/imgproc/imgproc_c.h"

Complex:

#if (CV_VERSION_MAJOR >= 4)

    cv::cvtColor(..., cv::COLOR_BGR2RGB);

#else

    cv::cvtColor(..., CV_BGR2RGB);

#endif

Upvotes: 2

Related Questions