From e28cc973bf5ad80988ea406468bd4f80386123ca Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 29 Mar 2018 14:17:23 +0300 Subject: [PATCH] samples: avoid using of legacy C-like API (part 2) --- samples/directx/d3d10_interop.cpp | 2 +- samples/directx/d3d11_interop.cpp | 6 +++--- samples/directx/d3d9_interop.cpp | 2 +- samples/directx/d3d9ex_interop.cpp | 2 +- samples/opengl/opengl_interop.cpp | 2 +- .../FaceDetection/FaceDetection/MainPage.xaml.cpp | 2 +- .../OcvImageProcessing/MainPage.xaml.cpp | 10 +++++----- .../winrt_universal/PhoneTutorial/MainPage.xaml.cpp | 4 ++-- .../PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp | 10 +++++----- .../PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp | 6 +++--- .../wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/samples/directx/d3d10_interop.cpp b/samples/directx/d3d10_interop.cpp index a6ca1335c6..48b18bd7b4 100644 --- a/samples/directx/d3d10_interop.cpp +++ b/samples/directx/d3d10_interop.cpp @@ -135,7 +135,7 @@ public: if (!m_cap.read(m_frame_bgr)) return -1; - cv::cvtColor(m_frame_bgr, m_frame_rgba, CV_BGR2RGBA); + cv::cvtColor(m_frame_bgr, m_frame_rgba, COLOR_BGR2RGBA); UINT subResource = ::D3D10CalcSubresource(0, 0, 1); diff --git a/samples/directx/d3d11_interop.cpp b/samples/directx/d3d11_interop.cpp index 95cf68b4af..4fc40e90f1 100644 --- a/samples/directx/d3d11_interop.cpp +++ b/samples/directx/d3d11_interop.cpp @@ -202,7 +202,7 @@ public: if (use_nv12) { - cv::cvtColor(m_frame_bgr, m_frame_i420, CV_BGR2YUV_I420); + cv::cvtColor(m_frame_bgr, m_frame_i420, COLOR_BGR2YUV_I420); convert_I420_to_NV12(m_frame_i420, m_frame_nv12, m_width, m_height); @@ -210,7 +210,7 @@ public: } else { - cv::cvtColor(m_frame_bgr, m_frame_rgba, CV_BGR2RGBA); + cv::cvtColor(m_frame_bgr, m_frame_rgba, COLOR_BGR2RGBA); // process video frame on CPU UINT subResource = ::D3D11CalcSubresource(0, 0, 1); @@ -336,7 +336,7 @@ public: } cv::Mat frame_nv12(m_height + (m_height / 2), m_width, CV_8UC1, mappedTex.pData, mappedTex.RowPitch); - cv::cvtColor(frame_nv12, m_frame_rgba, CV_YUV2RGBA_NV12); + cv::cvtColor(frame_nv12, m_frame_rgba, COLOR_YUV2RGBA_NV12); m_pD3D11Ctx->Unmap(m_pSurfaceNV12_cpu_copy, subResource); } diff --git a/samples/directx/d3d9_interop.cpp b/samples/directx/d3d9_interop.cpp index 03c8a6bc84..881f6ac9e7 100644 --- a/samples/directx/d3d9_interop.cpp +++ b/samples/directx/d3d9_interop.cpp @@ -108,7 +108,7 @@ public: if (!m_cap.read(m_frame_bgr)) return -1; - cv::cvtColor(m_frame_bgr, m_frame_rgba, CV_BGR2BGRA); + cv::cvtColor(m_frame_bgr, m_frame_rgba, COLOR_BGR2BGRA); D3DLOCKED_RECT memDesc = { 0, NULL }; RECT rc = { 0, 0, m_width, m_height }; diff --git a/samples/directx/d3d9ex_interop.cpp b/samples/directx/d3d9ex_interop.cpp index 6d526ba052..3ddf4c27a9 100644 --- a/samples/directx/d3d9ex_interop.cpp +++ b/samples/directx/d3d9ex_interop.cpp @@ -108,7 +108,7 @@ public: if (!m_cap.read(m_frame_bgr)) return -1; - cv::cvtColor(m_frame_bgr, m_frame_rgba, CV_BGR2BGRA); + cv::cvtColor(m_frame_bgr, m_frame_rgba, COLOR_BGR2BGRA); D3DLOCKED_RECT memDesc = { 0, NULL }; RECT rc = { 0, 0, m_width, m_height }; diff --git a/samples/opengl/opengl_interop.cpp b/samples/opengl/opengl_interop.cpp index ccfbccd6af..5690ee1e8b 100644 --- a/samples/opengl/opengl_interop.cpp +++ b/samples/opengl/opengl_interop.cpp @@ -207,7 +207,7 @@ public: if (!m_cap.read(m_frame_bgr)) return -1; - cv::cvtColor(m_frame_bgr, m_frame_rgba, CV_RGB2RGBA); + cv::cvtColor(m_frame_bgr, m_frame_rgba, COLOR_RGB2RGBA); if (do_buffer) buffer.copyFrom(m_frame_rgba, cv::ogl::Buffer::PIXEL_UNPACK_BUFFER, true); diff --git a/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp b/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp index dbf7fde351..a7f23adeae 100644 --- a/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp +++ b/samples/winrt/FaceDetection/FaceDetection/MainPage.xaml.cpp @@ -47,7 +47,7 @@ void FaceDetection::MainPage::InitBtn_Click(Platform::Object^ sender, Windows::U // load Image and Init recognizer cv::Mat image = cv::imread("Assets/group1.jpg"); groupFaces = cv::Mat(image.rows, image.cols, CV_8UC4); - cv::cvtColor(image, groupFaces, CV_BGR2BGRA); + cv::cvtColor(image, groupFaces, COLOR_BGR2BGRA); cv::winrt_initContainer(cvContainer); cv::imshow(window_name, groupFaces); diff --git a/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp b/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp index c911787867..d41521734a 100644 --- a/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp +++ b/samples/winrt/OcvImageProcessing/OcvImageProcessing/MainPage.xaml.cpp @@ -47,7 +47,7 @@ MainPage::MainPage() // Image loading OpenCV way ... way more simple cv::Mat image = cv::imread("Assets/Lena.png"); Lena = cv::Mat(image.rows, image.cols, CV_8UC4); - cvtColor(image, Lena, CV_BGR2BGRA); + cvtColor(image, Lena, COLOR_BGR2BGRA); UpdateImage(Lena); #else @@ -184,8 +184,8 @@ cv::Mat OcvImageProcessing::MainPage::ApplyGrayFilter(const cv::Mat& image) { cv::Mat result; cv::Mat intermediateMat; - cv::cvtColor(image, intermediateMat, CV_RGBA2GRAY); - cv::cvtColor(intermediateMat, result, CV_GRAY2BGRA); + cv::cvtColor(image, intermediateMat, COLOR_RGBA2GRAY); + cv::cvtColor(intermediateMat, result, COLOR_GRAY2BGRA); return result; } @@ -194,7 +194,7 @@ cv::Mat OcvImageProcessing::MainPage::ApplyCannyFilter(const cv::Mat& image) cv::Mat result; cv::Mat intermediateMat; cv::Canny(image, intermediateMat, 80, 90); - cv::cvtColor(intermediateMat, result, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, result, COLOR_GRAY2BGRA); return result; } @@ -213,7 +213,7 @@ cv::Mat OcvImageProcessing::MainPage::ApplyFindFeaturesFilter(const cv::Mat& ima std::vector features; image.copyTo(result); - cv::cvtColor(image, intermediateMat, CV_RGBA2GRAY); + cv::cvtColor(image, intermediateMat, COLOR_RGBA2GRAY); detector->detect(intermediateMat, features); for( unsigned int i = 0; i < std::min(features.size(), (size_t)50); i++ ) diff --git a/samples/winrt_universal/PhoneTutorial/MainPage.xaml.cpp b/samples/winrt_universal/PhoneTutorial/MainPage.xaml.cpp index de3c554bf5..77dc9f7685 100644 --- a/samples/winrt_universal/PhoneTutorial/MainPage.xaml.cpp +++ b/samples/winrt_universal/PhoneTutorial/MainPage.xaml.cpp @@ -84,10 +84,10 @@ void PhoneTutorial::MainPage::Process_Click(Platform::Object^ sender, Windows::U // convert to grayscale cv::Mat intermediateMat; - cv::cvtColor(mat, intermediateMat, CV_RGB2GRAY); + cv::cvtColor(mat, intermediateMat, COLOR_RGB2GRAY); // convert to BGRA - cv::cvtColor(intermediateMat, mat, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, mat, COLOR_GRAY2BGRA); // copy processed image back to the WriteableBitmap memcpy(pPixels, mat.data, 4 * height*width); diff --git a/samples/wp8/OcvImageManipulation/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp b/samples/wp8/OcvImageManipulation/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp index f3e3a01d6f..c319b4c084 100644 --- a/samples/wp8/OcvImageManipulation/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp +++ b/samples/wp8/OcvImageManipulation/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp @@ -136,22 +136,22 @@ namespace PhoneXamlDirect3DApp1Comp void Direct3DInterop::ApplyGrayFilter(cv::Mat* mat) { cv::Mat intermediateMat; - cv::cvtColor(*mat, intermediateMat, CV_RGBA2GRAY); - cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA); + cv::cvtColor(*mat, intermediateMat, COLOR_RGBA2GRAY); + cv::cvtColor(intermediateMat, *mat, COLOR_GRAY2BGRA); } void Direct3DInterop::ApplyCannyFilter(cv::Mat* mat) { cv::Mat intermediateMat; cv::Canny(*mat, intermediateMat, 80, 90); - cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, *mat, COLOR_GRAY2BGRA); } void Direct3DInterop::ApplyBlurFilter(cv::Mat* mat) { cv::Mat intermediateMat; // cv::Blur(image, intermediateMat, 80, 90); - cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, *mat, COLOR_GRAY2BGRA); } void Direct3DInterop::ApplyFindFeaturesFilter(cv::Mat* mat) @@ -160,7 +160,7 @@ namespace PhoneXamlDirect3DApp1Comp cv::Ptr detector = cv::FastFeatureDetector::create(50); std::vector features; - cv::cvtColor(*mat, intermediateMat, CV_RGBA2GRAY); + cv::cvtColor(*mat, intermediateMat, COLOR_RGBA2GRAY); detector->detect(intermediateMat, features); for( unsigned int i = 0; i < std::min(features.size(), (size_t)50); i++ ) diff --git a/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp b/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp index 295fed43a0..e3158080c8 100644 --- a/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp +++ b/samples/wp8/OcvRotatingCube/PhoneXamlDirect3DApp1/PhoneXamlDirect3DApp1Comp/Direct3DInterop.cpp @@ -19,15 +19,15 @@ namespace PhoneXamlDirect3DApp1Comp void Direct3DInterop::ApplyGrayFilter(const cv::Mat& image) { cv::Mat intermediateMat; - cv::cvtColor(image, intermediateMat, CV_RGBA2GRAY); - cv::cvtColor(intermediateMat, image, CV_GRAY2BGRA); + cv::cvtColor(image, intermediateMat, COLOR_RGBA2GRAY); + cv::cvtColor(intermediateMat, image, COLOR_GRAY2BGRA); } void Direct3DInterop::ApplyCannyFilter(const cv::Mat& image) { cv::Mat intermediateMat; cv::Canny(image, intermediateMat, 80, 90); - cv::cvtColor(intermediateMat, image, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, image, COLOR_GRAY2BGRA); } void Direct3DInterop::ApplySepiaFilter(const cv::Mat& image) diff --git a/samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp b/samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp index 7e0c0df272..a1240f2f8d 100644 --- a/samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp +++ b/samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp @@ -31,10 +31,10 @@ IAsyncOperation^>^ OpenCVLib::ProcessAsync(IVector^ input, { // convert to grayscale cv::Mat intermediateMat; - cv::cvtColor(mat, intermediateMat, CV_RGB2GRAY); + cv::cvtColor(mat, intermediateMat, COLOR_RGB2GRAY); // convert to BGRA - cv::cvtColor(intermediateMat, mat, CV_GRAY2BGRA); + cv::cvtColor(intermediateMat, mat, COLOR_GRAY2BGRA); std::vector output; CopyMatrixToVector(mat, output, size);