Skip to content

Commit 5c73969

Browse files
authored
Merge pull request #3996 from vpisarev:matshape_inside_mat
Fixed compile errors after MatShape/MatSize refactoring #3996 this is satellite for opencv/opencv#27757 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent 07bc3f6 commit 5c73969

File tree

15 files changed

+57
-52
lines changed

15 files changed

+57
-52
lines changed

modules/fastcv/src/channel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void merge(InputArrayOfArrays _mv, OutputArray _dst)
2626
CV_Assert(mv[i].size == mv[0].size && mv[i].step[0] == mv[0].step[0] && mv[i].type() == CV_8UC1);
2727
}
2828

29-
_dst.create(mv[0].dims, mv[0].size, CV_MAKE_TYPE(CV_8U,count));
29+
_dst.create(mv[0].size, CV_MAKE_TYPE(CV_8U,count));
3030
Mat dst = _dst.getMat();
3131

3232
INITIALIZATION_CHECK;
@@ -89,7 +89,7 @@ void split(InputArray _src, OutputArrayOfArrays _mv)
8989
_mv.create(cn, 1, depth);
9090
for( int k = 0; k < cn; k++ )
9191
{
92-
_mv.create(src.dims, src.size, depth, k);
92+
_mv.create(src.size, depth, k);
9393
}
9494

9595
std::vector<cv::Mat> mv(cn);

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/pipeline_modeling_tool/utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline void generateRandom(cv::Mat& out) {
3838
break;
3939
case CV_16F: {
4040
std::vector<int> dims;
41-
for (int i = 0; i < out.size.dims(); ++i) {
41+
for (int i = 0; i < out.size.dims; ++i) {
4242
dims.push_back(out.size[i]);
4343
}
4444
cv::Mat fp32_mat;

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/samples/text_detection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ GAPI_OCV_KERNEL(OCVPostProcess, PostProcess) {
288288
}
289289

290290
static std::vector<std::size_t> dimsToShape(const cv::MatSize &sz) {
291-
const int n_dims = sz.dims();
291+
const int n_dims = sz.dims;
292292
std::vector<std::size_t> result;
293293
result.reserve(n_dims);
294294

modules/gapi/src/api/gbackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
411411
#if !defined(GAPI_STANDALONE)
412412
// NB: WA for 1D mats.
413413
if (desc.dims.size() == 1u) {
414-
mat.dims = 1;
414+
mat.size.dims = mat.dims = 1;
415415
}
416416
#endif
417417
}

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

0 commit comments

Comments
 (0)