Skip to content

Commit d268f6d

Browse files
committed
fixed compile errors for MatShape/MatSize refactoring
1 parent d031ffd commit d268f6d

File tree

10 files changed

+25
-21
lines changed

10 files changed

+25
-21
lines changed

modules/gapi/include/opencv2/gapi/own/convert.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace cv
1717
{
1818
template<typename T>
1919
std::vector<T> to_own(const cv::MatSize &sz) {
20-
std::vector<T> result(sz.dims());
21-
for (int i = 0; i < sz.dims(); i++) {
20+
std::vector<T> result(sz.dims);
21+
for (int i = 0; i < sz.dims; i++) {
2222
// Note: cv::MatSize is not iterable
2323
result[i] = static_cast<T>(sz[i]);
2424
}

modules/gapi/samples/onevpl_infer_with_advanced_device_selection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
225225
const cv::Size &in_parent_size,
226226
std::vector<cv::Rect> &out_objects) {
227227
const auto &in_ssd_dims = in_ssd_result.size;
228-
GAPI_Assert(in_ssd_dims.dims() == 4u);
228+
GAPI_Assert(in_ssd_dims.dims == 4);
229229

230230
const int MAX_PROPOSALS = in_ssd_dims[2];
231231
const int OBJECT_SIZE = in_ssd_dims[3];

modules/gapi/samples/semantic_segmentation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ G_API_OP(PostProcessing, <cv::GMat(cv::GMat, cv::GMat)>, "sample.custom.post_pro
144144
GAPI_OCV_KERNEL(OCVPostProcessing, PostProcessing) {
145145
static void run(const cv::Mat &in, const cv::Mat &out_blob, cv::Mat &out) {
146146
int C = -1, H = -1, W = -1;
147-
if (out_blob.size.dims() == 4u) {
147+
if (out_blob.size.dims == 4) {
148148
C = 1; H = 2, W = 3;
149-
} else if (out_blob.size.dims() == 3u) {
149+
} else if (out_blob.size.dims == 3) {
150150
C = 0; H = 1, W = 2;
151151
} else {
152152
throw std::logic_error(

modules/gapi/src/api/gmat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace{
8787
#if !defined(GAPI_STANDALONE)
8888
cv::GMatDesc cv::descr_of(const cv::Mat &mat)
8989
{
90-
const auto mat_dims = mat.size.dims();
90+
const auto mat_dims = mat.size.dims;
9191

9292
if (mat_dims <= 2)
9393
return GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}};
@@ -111,7 +111,7 @@ cv::GMatDesc cv::gapi::own::descr_of(const Mat &mat)
111111
#if !defined(GAPI_STANDALONE)
112112
cv::GMatDesc cv::descr_of(const cv::UMat &mat)
113113
{
114-
GAPI_Assert(mat.size.dims() == 2);
114+
GAPI_Assert(mat.size.dims == 2);
115115
return GMatDesc{ mat.depth(), mat.channels(),{ mat.cols, mat.rows } };
116116
}
117117

modules/gapi/src/backends/common/gbackend.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ namespace gimpl {
4646
#if !defined(GAPI_STANDALONE)
4747
int m_dims = m.dims < 2 ? 2 : m.dims;
4848
RMat::View::stepsT steps(m_dims);
49-
const size_t* m_step = m.dims <= 2 ? m.step.buf : m.step.p;
50-
for (int i = 0; i < m_dims; i++) {
51-
steps[i] = m_step[i];
49+
if (m_dims >= 2) {
50+
for (int i = 0; i < m_dims; i++) {
51+
steps[i] = m.step.p[i];
52+
}
53+
} else {
54+
steps[1] = m.step.p[0];
55+
steps[0] = m.cols*steps[1];
5256
}
5357
return RMat::View(cv::descr_of(m), m.data, steps, std::move(cb));
5458
#else

modules/gapi/src/backends/common/serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void read_mat_data(IIStream &is, cv::Mat &m) {
276276

277277
IOStream& operator<< (IOStream& os, const cv::Mat &m) {
278278
#if !defined(GAPI_STANDALONE)
279-
GAPI_Assert(m.size.dims() == 2 && "Only 2D images are supported now");
279+
GAPI_Assert(m.size.dims == 2 && "Only 2D images are supported now");
280280
#else
281281
GAPI_Assert(m.dims.size() == 2 && "Only 2D images are supported now");
282282
#endif

modules/gapi/src/backends/cpu/gnnparsers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class SSDParser
102102
: m_dims(in_ssd_dims), m_maxProp(in_ssd_dims[2]), m_objSize(in_ssd_dims[3]),
103103
m_data(data), m_surface(cv::Rect({0,0}, in_size)), m_size(in_size)
104104
{
105-
GAPI_Assert(in_ssd_dims.dims() == 4u); // Fixed output layout
105+
GAPI_Assert(in_ssd_dims.dims == 4); // Fixed output layout
106106
GAPI_Assert(m_objSize == 7); // Fixed SSD object size
107107
}
108108

@@ -220,7 +220,7 @@ void ParseSSD(const cv::Mat& in_ssd_result,
220220
}
221221

222222
static void checkYoloDims(const MatSize& dims) {
223-
const auto d = dims.dims();
223+
const auto d = dims.dims;
224224
// Accept 1x13x13xN and 13x13xN
225225
GAPI_Assert(d >= 2);
226226
if (d >= 3) {
@@ -252,7 +252,7 @@ void parseYolo(const cv::Mat& in_yolo_result,
252252
const auto& dims = in_yolo_result.size;
253253
checkYoloDims(dims);
254254
int acc = 1;
255-
for (int i = 0; i < dims.dims(); i++) {
255+
for (int i = 0; i < dims.dims; i++) {
256256
acc *= dims[i];
257257
}
258258
const auto num_classes = acc/(5*13*13)-5;

modules/gapi/src/backends/ie/giebackend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ cv::gapi::ie::TraitAs clarifyTrait(const cv::GMetaArg &meta,
236236

237237
inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
238238
const auto &sz = mat.size;
239-
if (sz.dims() == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
239+
if (sz.dims == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
240240
{
241241
// NB: This logic is mainly taken from IE samples
242242
const size_t channels = mat.channels();
@@ -253,7 +253,7 @@ inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
253253
return IE::TensorDesc(toIE(mat.depth()),
254254
IE::SizeVector{1, channels, height, width}, bdesc);
255255
}
256-
return IE::TensorDesc(toIE(mat.depth()), toIE(sz), toIELayout(sz.dims()));
256+
return IE::TensorDesc(toIE(mat.depth()), toIE(sz), toIELayout(sz.dims));
257257
}
258258

259259
// NB: Inference dimmensions always follow NCDHW order
@@ -296,7 +296,7 @@ inline IE::TensorDesc toIE(const cv::Mat &mat,
296296
const cv::gapi::ie::TraitAs hint,
297297
const IE::Layout layout) {
298298
const auto &sz = mat.size;
299-
if (sz.dims() == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
299+
if (sz.dims == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
300300
{
301301
// NB: This logic is mainly taken from IE samples
302302
const size_t channels = mat.channels();

modules/gapi/test/common/gapi_parsers_tests_common.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ParserSSDTest
4848
{
4949
out_boxes.clear();
5050
const auto &in_ssd_dims = in_ssd_result.size;
51-
CV_Assert(in_ssd_dims.dims() == 4u);
51+
CV_Assert(in_ssd_dims.dims == 4);
5252

5353
const int MAX_PROPOSALS = in_ssd_dims[2];
5454
const int OBJECT_SIZE = in_ssd_dims[3];
@@ -99,7 +99,7 @@ class ParserSSDTest
9999
out_boxes.clear();
100100
out_labels.clear();
101101
const auto &in_ssd_dims = in_ssd_result.size;
102-
CV_Assert(in_ssd_dims.dims() == 4u);
102+
CV_Assert(in_ssd_dims.dims == 4);
103103

104104
const int MAX_PROPOSALS = in_ssd_dims[2];
105105
const int OBJECT_SIZE = in_ssd_dims[3];

modules/gapi/test/gapi_sample_pipelines.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,13 @@ TEST(DISABLED_GAPI_Pipeline, GraphOutputIs1DMat)
495495

496496
// NB: Computation is able to write 1D output cv::Mat to empty out_mat.
497497
ASSERT_NO_THROW(cc(cv::gin(in_mat), cv::gout(out_mat)));
498-
ASSERT_EQ(1, out_mat.size.dims());
498+
ASSERT_EQ(1, out_mat.size.dims);
499499
ASSERT_EQ(dim, out_mat.size[0]);
500500

501501
// NB: Computation is able to write 1D output cv::Mat
502502
// to pre-allocated with the same meta out_mat.
503503
ASSERT_NO_THROW(cc(cv::gin(in_mat), cv::gout(out_mat)));
504-
ASSERT_EQ(1, out_mat.size.dims());
504+
ASSERT_EQ(1, out_mat.size.dims);
505505
ASSERT_EQ(dim, out_mat.size[0]);
506506
}
507507

0 commit comments

Comments
 (0)