samples: avoid using of legacy C-like API (part 2)

This commit is contained in:
Alexander Alekhin 2018-03-29 14:17:23 +03:00
parent 7dc88f26f2
commit e28cc973bf
11 changed files with 25 additions and 25 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<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++ )

View File

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

View File

@ -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<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++ )

View File

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

View File

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