Skip to content

Commit 528a459

Browse files
committed
Compatibility with OpenCV 3.2 .
1 parent 74efab3 commit 528a459

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/cv_codec.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include <cv_bridge/cv_bridge.h>
1717
#include <opencv2/core.hpp>
1818
#include <opencv2/imgcodecs/imgcodecs.hpp>
19+
#if CV_VERSION_MAJOR < 4
20+
#include <opencv2/imgcodecs/imgcodecs_c.h>
21+
#endif
1922
#include <sensor_msgs/CompressedImage.h>
2023
#include <sensor_msgs/Image.h>
2124
#include <sensor_msgs/image_encodings.h>
@@ -224,7 +227,11 @@ cras::expected<void, std::string> CVCodec::validateImageFormat(const CVTransport
224227
{
225228
const auto f = format.formatString.c_str();
226229

230+
#if CV_VERSION_MAJOR >= 4
227231
if (!cv::haveImageWriter("." + format.formatString))
232+
#else
233+
if (!cvHaveImageWriter((std::string(".") + format.formatString).c_str()))
234+
#endif
228235
return cras::make_unexpected(cras::format("OpenCV cannot encode images with format %s.", f));
229236

230237
char dataType = 'U';

0 commit comments

Comments
 (0)