Skip to content

Commit

Permalink
samples: avoid using of legacy C-like API (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Mar 29, 2018
1 parent 7dc88f2 commit e28cc97
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion samples/directx/d3d10_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class D3D10WinApp : public D3DSample
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);

Expand Down
6 changes: 3 additions & 3 deletions samples/directx/d3d11_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ class D3D11WinApp : public D3DSample

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);

m_pD3D11Ctx->UpdateSubresource(m_pSurfaceNV12, 0, 0, m_frame_nv12.data, (UINT)m_frame_nv12.step[0], (UINT)m_frame_nv12.total());
}
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);
Expand Down Expand Up @@ -336,7 +336,7 @@ class D3D11WinApp : public D3DSample
}

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);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/directx/d3d9_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class D3D9WinApp : public D3DSample
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 };
Expand Down
2 changes: 1 addition & 1 deletion samples/directx/d3d9ex_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class D3D9ExWinApp : public D3DSample
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 };
Expand Down
2 changes: 1 addition & 1 deletion samples/opengl/opengl_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class GLWinApp : public WinApp
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -213,7 +213,7 @@ cv::Mat OcvImageProcessing::MainPage::ApplyFindFeaturesFilter(const cv::Mat& ima
std::vector<cv::KeyPoint> 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++ )
Expand Down
4 changes: 2 additions & 2 deletions samples/winrt_universal/PhoneTutorial/MainPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -160,7 +160,7 @@ namespace PhoneXamlDirect3DApp1Comp
cv::Ptr<cv::FastFeatureDetector> detector = cv::FastFeatureDetector::create(50);
std::vector<cv::KeyPoint> 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++ )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ IAsyncOperation<IVectorView<int>^>^ OpenCVLib::ProcessAsync(IVector<int>^ 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<int> output;
CopyMatrixToVector(mat, output, size);
Expand Down

0 comments on commit e28cc97

Please sign in to comment.