Commit 7b8b6a42 authored by Clement Guedez's avatar Clement Guedez Committed by jeremad

OpenCV4 support

OpenCV4 support : change old C definition to standard c++ one in use
the old definition still exist in imgproc.c_types.h
parent b6014f1a
...@@ -82,7 +82,7 @@ Status AutoCrop::setupImage(const cv::Mat& inputImage) { ...@@ -82,7 +82,7 @@ Status AutoCrop::setupImage(const cv::Mat& inputImage) {
inputCvImage, blurredImage, inputCvImage, blurredImage,
cv::Size((int)autoCropConfig.getGaussianBlurKernelSize(), (int)autoCropConfig.getGaussianBlurKernelSize()), cv::Size((int)autoCropConfig.getGaussianBlurKernelSize(), (int)autoCropConfig.getGaussianBlurKernelSize()),
autoCropConfig.getGaussianBlurSigma(), 0); autoCropConfig.getGaussianBlurSigma(), 0);
cv::cvtColor(blurredImage, inputLabImage, CV_BGR2Lab); cv::cvtColor(blurredImage, inputLabImage, cv::COLOR_BGR2Lab);
cv::Size downSize = cv::Size(inputLabImage.cols, inputLabImage.rows); cv::Size downSize = cv::Size(inputLabImage.cols, inputLabImage.rows);
while (downSize.width > 512 && downSize.height > 512) { while (downSize.width > 512 && downSize.height > 512) {
......
...@@ -57,7 +57,7 @@ Potential<Ptv::Value> AutoCropAlgorithm::apply(Core::PanoDefinition* pano, Progr ...@@ -57,7 +57,7 @@ Potential<Ptv::Value> AutoCropAlgorithm::apply(Core::PanoDefinition* pano, Progr
std::memcpy(hostFrame.hostPtr(), frame.hostPtr(), frame.byteSize()); std::memcpy(hostFrame.hostPtr(), frame.hostPtr(), frame.byteSize());
cv::Mat cvImage; cv::Mat cvImage;
cv::Mat originalImage(cv::Size((int)width, (int)height), CV_8UC4, frame.hostPtr(), cv::Mat::AUTO_STEP); cv::Mat originalImage(cv::Size((int)width, (int)height), CV_8UC4, frame.hostPtr(), cv::Mat::AUTO_STEP);
cv::cvtColor(originalImage, cvImage, CV_RGBA2BGR); cv::cvtColor(originalImage, cvImage, cv::COLOR_RGBA2BGR);
cv::Point3i circle; cv::Point3i circle;
FAIL_RETURN(autoCrop.findCropCircle(cvImage, circle)); FAIL_RETURN(autoCrop.findCropCircle(cvImage, circle));
......
...@@ -12,7 +12,7 @@ KeypointExtractor::KeypointExtractor(unsigned int nb_octaves, unsigned int nb_su ...@@ -12,7 +12,7 @@ KeypointExtractor::KeypointExtractor(unsigned int nb_octaves, unsigned int nb_su
this->nOctaves = nb_octaves; this->nOctaves = nb_octaves;
this->nSubLevels = nb_sublevels; this->nSubLevels = nb_sublevels;
this->threshold = threshold; this->threshold = threshold;
extractor = cv::AKAZE::create(5, 0, 3, (float)threshold, nOctaves, nSubLevels, 1); extractor = cv::AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, (float)threshold, nOctaves, nSubLevels, KAZE::DIFF_PM_G2);
} }
Status KeypointExtractor::extract(const cv::Mat& image, KPList& keypoints, DescriptorList& descriptors, Status KeypointExtractor::extract(const cv::Mat& image, KPList& keypoints, DescriptorList& descriptors,
......
...@@ -274,7 +274,7 @@ static Status loadInputImages(std::map<frameid_t, std::vector<cv::Mat>>& inputIm ...@@ -274,7 +274,7 @@ static Status loadInputImages(std::map<frameid_t, std::vector<cv::Mat>>& inputIm
cv::Mat bgrImage; cv::Mat bgrImage;
cv::Mat rgbaImage(cv::Size(width, height), CV_8UC4, frame.hostPtr(), cv::Mat::AUTO_STEP); cv::Mat rgbaImage(cv::Size(width, height), CV_8UC4, frame.hostPtr(), cv::Mat::AUTO_STEP);
cv::cvtColor(rgbaImage, bgrImage, CV_RGBA2BGR); cv::cvtColor(rgbaImage, bgrImage, cv::COLOR_RGBA2BGR);
inputImages[frameNumber].push_back(bgrImage); inputImages[frameNumber].push_back(bgrImage);
......
...@@ -70,13 +70,13 @@ Status loadBoundaryCoords(const std::string& filename, int64_t& width, int64_t& ...@@ -70,13 +70,13 @@ Status loadBoundaryCoords(const std::string& filename, int64_t& width, int64_t&
const int thresh = 100; const int thresh = 100;
cv::Mat src_gray; cv::Mat src_gray;
cv::Mat canny_output; cv::Mat canny_output;
cv::cvtColor(image, src_gray, CV_RGBA2GRAY); cv::cvtColor(image, src_gray, cv::COLOR_RGBA2GRAY);
// Detect edges using canny // Detect edges using canny
cv::Canny(src_gray, canny_output, thresh, thresh * 2, 3); cv::Canny(src_gray, canny_output, thresh, thresh * 2, 3);
// Find contours // Find contours
std::vector<std::vector<cv::Point>> contours; std::vector<std::vector<cv::Point>> contours;
std::vector<cv::Vec4i> hierarchy; std::vector<cv::Vec4i> hierarchy;
cv::findContours(canny_output, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, cv::Point(0, 0)); cv::findContours(canny_output, contours, hierarchy, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_NONE, cv::Point(0, 0));
points.clear(); points.clear();
if (contours.size() > 0) { if (contours.size() > 0) {
for (size_t i = 0; i < contours[0].size(); i++) { for (size_t i = 0; i < contours[0].size(); i++) {
......
...@@ -30,7 +30,7 @@ Status Compression::polylineEncodeBinaryMask(const int width, const int height, ...@@ -30,7 +30,7 @@ Status Compression::polylineEncodeBinaryMask(const int width, const int height,
"Corrupted input mask in polylines encoding (width * height != data.size())"}; "Corrupted input mask in polylines encoding (width * height != data.size())"};
} }
FAIL_RETURN( FAIL_RETURN(
Util::GeometryProcessing::findImageContours<unsigned char>(size, data, 1, contours, CV_CHAIN_APPROX_TC89_KCOS)); Util::GeometryProcessing::findImageContours<unsigned char>(size, data, 1, contours, cv::CHAIN_APPROX_TC89_KCOS));
std::vector<int> encodedSizes; std::vector<int> encodedSizes;
for (size_t i = 0; i < contours.size(); i++) { for (size_t i = 0; i < contours.size(); i++) {
......
...@@ -395,7 +395,7 @@ Status GeometryProcessing::findImageContours(const cv::Size size, const std::vec ...@@ -395,7 +395,7 @@ Status GeometryProcessing::findImageContours(const cv::Size size, const std::vec
cv::Mat src_gray(size, CV_8UC1, &image[0]); cv::Mat src_gray(size, CV_8UC1, &image[0]);
/// Find contours /// Find contours
std::vector<cv::Vec4i> hierarchy; std::vector<cv::Vec4i> hierarchy;
cv::findContours(src_gray, contours, hierarchy, CV_RETR_EXTERNAL, method, cv::Point(0, 0)); cv::findContours(src_gray, contours, hierarchy, cv::RETR_EXTERNAL, method, cv::Point(0, 0));
return Status::OK(); return Status::OK();
} }
......
...@@ -66,7 +66,7 @@ class VS_EXPORT GeometryProcessing { ...@@ -66,7 +66,7 @@ class VS_EXPORT GeometryProcessing {
*/ */
template <typename T> template <typename T>
static Status findImageContours(const cv::Size size, const std::vector<T>& data, const T bitMask, static Status findImageContours(const cv::Size size, const std::vector<T>& data, const T bitMask,
std::vector<std::vector<cv::Point>>& points, const int method = CV_CHAIN_APPROX_NONE); std::vector<std::vector<cv::Point>>& points, const int method = cv::CHAIN_APPROX_NONE);
/** /**
* @brief Draw polygon to an output buffer * @brief Draw polygon to an output buffer
......
...@@ -23,7 +23,7 @@ Status ImageProcessing::findCropCircle(const int& width, const int& height, void ...@@ -23,7 +23,7 @@ Status ImageProcessing::findCropCircle(const int& width, const int& height, void
r = 0; r = 0;
cv::Mat originalImage(cv::Size(width, height), CV_8UC4, data); cv::Mat originalImage(cv::Size(width, height), CV_8UC4, data);
cv::Mat inputImage; cv::Mat inputImage;
cv::cvtColor(originalImage, inputImage, CV_RGBA2BGR); cv::cvtColor(originalImage, inputImage, cv::COLOR_RGBA2BGR);
std::unique_ptr<VideoStitch::Ptv::Value> fake(VideoStitch::Ptv::Value::stringObject("fake")); std::unique_ptr<VideoStitch::Ptv::Value> fake(VideoStitch::Ptv::Value::stringObject("fake"));
VideoStitch::AutoCrop::AutoCropConfig config(algoConfig ? algoConfig : fake.get()); VideoStitch::AutoCrop::AutoCropConfig config(algoConfig ? algoConfig : fake.get());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment