Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/fastcv/src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void merge(InputArrayOfArrays _mv, OutputArray _dst)
CV_Assert(mv[i].size == mv[0].size && mv[i].step[0] == mv[0].step[0] && mv[i].type() == CV_8UC1);
}

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

INITIALIZATION_CHECK;
Expand Down Expand Up @@ -89,7 +89,7 @@ void split(InputArray _src, OutputArrayOfArrays _mv)
_mv.create(cn, 1, depth);
for( int k = 0; k < cn; k++ )
{
_mv.create(src.dims, src.size, depth, k);
_mv.create(src.size, depth, k);
}

std::vector<cv::Mat> mv(cn);
Expand Down
4 changes: 2 additions & 2 deletions modules/gapi/include/opencv2/gapi/own/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace cv
{
template<typename T>
std::vector<T> to_own(const cv::MatSize &sz) {
std::vector<T> result(sz.dims());
for (int i = 0; i < sz.dims(); i++) {
std::vector<T> result(sz.dims);
for (int i = 0; i < sz.dims; i++) {
// Note: cv::MatSize is not iterable
result[i] = static_cast<T>(sz[i]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ GAPI_OCV_KERNEL(OCVParseSSD, ParseSSD) {
const cv::Size &in_parent_size,
std::vector<cv::Rect> &out_objects) {
const auto &in_ssd_dims = in_ssd_result.size;
GAPI_Assert(in_ssd_dims.dims() == 4u);
GAPI_Assert(in_ssd_dims.dims == 4);

const int MAX_PROPOSALS = in_ssd_dims[2];
const int OBJECT_SIZE = in_ssd_dims[3];
Expand Down
2 changes: 1 addition & 1 deletion modules/gapi/samples/pipeline_modeling_tool/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ inline void generateRandom(cv::Mat& out) {
break;
case CV_16F: {
std::vector<int> dims;
for (int i = 0; i < out.size.dims(); ++i) {
for (int i = 0; i < out.size.dims; ++i) {
dims.push_back(out.size[i]);
}
cv::Mat fp32_mat;
Expand Down
4 changes: 2 additions & 2 deletions modules/gapi/samples/semantic_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ G_API_OP(PostProcessing, <cv::GMat(cv::GMat, cv::GMat)>, "sample.custom.post_pro
GAPI_OCV_KERNEL(OCVPostProcessing, PostProcessing) {
static void run(const cv::Mat &in, const cv::Mat &out_blob, cv::Mat &out) {
int C = -1, H = -1, W = -1;
if (out_blob.size.dims() == 4u) {
if (out_blob.size.dims == 4) {
C = 1; H = 2, W = 3;
} else if (out_blob.size.dims() == 3u) {
} else if (out_blob.size.dims == 3) {
C = 0; H = 1, W = 2;
} else {
throw std::logic_error(
Expand Down
2 changes: 1 addition & 1 deletion modules/gapi/samples/text_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ GAPI_OCV_KERNEL(OCVPostProcess, PostProcess) {
}

static std::vector<std::size_t> dimsToShape(const cv::MatSize &sz) {
const int n_dims = sz.dims();
const int n_dims = sz.dims;
std::vector<std::size_t> result;
result.reserve(n_dims);

Expand Down
2 changes: 1 addition & 1 deletion modules/gapi/src/api/gbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void createMat(const cv::GMatDesc &desc, cv::Mat& mat)
#if !defined(GAPI_STANDALONE)
// NB: WA for 1D mats.
if (desc.dims.size() == 1u) {
mat.dims = 1;
mat.size.dims = mat.dims = 1;
}
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions modules/gapi/src/api/gmat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace{
#if !defined(GAPI_STANDALONE)
cv::GMatDesc cv::descr_of(const cv::Mat &mat)
{
const auto mat_dims = mat.size.dims();
const auto mat_dims = mat.size.dims;

if (mat_dims <= 2)
return GMatDesc{mat.depth(), mat.channels(), {mat.cols, mat.rows}};
Expand All @@ -111,7 +111,7 @@ cv::GMatDesc cv::gapi::own::descr_of(const Mat &mat)
#if !defined(GAPI_STANDALONE)
cv::GMatDesc cv::descr_of(const cv::UMat &mat)
{
GAPI_Assert(mat.size.dims() == 2);
GAPI_Assert(mat.size.dims == 2);
return GMatDesc{ mat.depth(), mat.channels(),{ mat.cols, mat.rows } };
}

Expand Down
10 changes: 7 additions & 3 deletions modules/gapi/src/backends/common/gbackend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ namespace gimpl {
#if !defined(GAPI_STANDALONE)
int m_dims = m.dims < 2 ? 2 : m.dims;
RMat::View::stepsT steps(m_dims);
const size_t* m_step = m.dims <= 2 ? m.step.buf : m.step.p;
for (int i = 0; i < m_dims; i++) {
steps[i] = m_step[i];
if (m_dims >= 2) {
for (int i = 0; i < m_dims; i++) {
steps[i] = m.step.p[i];
}
} else {
steps[1] = m.step.p[0];
steps[0] = m.cols*steps[1];
}
return RMat::View(cv::descr_of(m), m.data, steps, std::move(cb));
#else
Expand Down
2 changes: 1 addition & 1 deletion modules/gapi/src/backends/common/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void read_mat_data(IIStream &is, cv::Mat &m) {

IOStream& operator<< (IOStream& os, const cv::Mat &m) {
#if !defined(GAPI_STANDALONE)
GAPI_Assert(m.size.dims() == 2 && "Only 2D images are supported now");
GAPI_Assert(m.size.dims == 2 && "Only 2D images are supported now");
#else
GAPI_Assert(m.dims.size() == 2 && "Only 2D images are supported now");
#endif
Expand Down
6 changes: 3 additions & 3 deletions modules/gapi/src/backends/cpu/gnnparsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class SSDParser
: m_dims(in_ssd_dims), m_maxProp(in_ssd_dims[2]), m_objSize(in_ssd_dims[3]),
m_data(data), m_surface(cv::Rect({0,0}, in_size)), m_size(in_size)
{
GAPI_Assert(in_ssd_dims.dims() == 4u); // Fixed output layout
GAPI_Assert(in_ssd_dims.dims == 4); // Fixed output layout
GAPI_Assert(m_objSize == 7); // Fixed SSD object size
}

Expand Down Expand Up @@ -220,7 +220,7 @@ void ParseSSD(const cv::Mat& in_ssd_result,
}

static void checkYoloDims(const MatSize& dims) {
const auto d = dims.dims();
const auto d = dims.dims;
// Accept 1x13x13xN and 13x13xN
GAPI_Assert(d >= 2);
if (d >= 3) {
Expand Down Expand Up @@ -252,7 +252,7 @@ void parseYolo(const cv::Mat& in_yolo_result,
const auto& dims = in_yolo_result.size;
checkYoloDims(dims);
int acc = 1;
for (int i = 0; i < dims.dims(); i++) {
for (int i = 0; i < dims.dims; i++) {
acc *= dims[i];
}
const auto num_classes = acc/(5*13*13)-5;
Expand Down
6 changes: 3 additions & 3 deletions modules/gapi/src/backends/ie/giebackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ cv::gapi::ie::TraitAs clarifyTrait(const cv::GMetaArg &meta,

inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
const auto &sz = mat.size;
if (sz.dims() == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
if (sz.dims == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
{
// NB: This logic is mainly taken from IE samples
const size_t channels = mat.channels();
Expand All @@ -253,7 +253,7 @@ inline IE::TensorDesc toIE(const cv::Mat &mat, cv::gapi::ie::TraitAs hint) {
return IE::TensorDesc(toIE(mat.depth()),
IE::SizeVector{1, channels, height, width}, bdesc);
}
return IE::TensorDesc(toIE(mat.depth()), toIE(sz), toIELayout(sz.dims()));
return IE::TensorDesc(toIE(mat.depth()), toIE(sz), toIELayout(sz.dims));
}

// NB: Inference dimmensions always follow NCDHW order
Expand Down Expand Up @@ -296,7 +296,7 @@ inline IE::TensorDesc toIE(const cv::Mat &mat,
const cv::gapi::ie::TraitAs hint,
const IE::Layout layout) {
const auto &sz = mat.size;
if (sz.dims() == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
if (sz.dims == 2 && hint == cv::gapi::ie::TraitAs::IMAGE)
{
// NB: This logic is mainly taken from IE samples
const size_t channels = mat.channels();
Expand Down
4 changes: 2 additions & 2 deletions modules/gapi/test/common/gapi_parsers_tests_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ParserSSDTest
{
out_boxes.clear();
const auto &in_ssd_dims = in_ssd_result.size;
CV_Assert(in_ssd_dims.dims() == 4u);
CV_Assert(in_ssd_dims.dims == 4);

const int MAX_PROPOSALS = in_ssd_dims[2];
const int OBJECT_SIZE = in_ssd_dims[3];
Expand Down Expand Up @@ -99,7 +99,7 @@ class ParserSSDTest
out_boxes.clear();
out_labels.clear();
const auto &in_ssd_dims = in_ssd_result.size;
CV_Assert(in_ssd_dims.dims() == 4u);
CV_Assert(in_ssd_dims.dims == 4);

const int MAX_PROPOSALS = in_ssd_dims[2];
const int OBJECT_SIZE = in_ssd_dims[3];
Expand Down
8 changes: 4 additions & 4 deletions modules/gapi/test/gapi_sample_pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,13 @@ TEST(DISABLED_GAPI_Pipeline, GraphOutputIs1DMat)

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

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

Expand All @@ -512,7 +512,7 @@ TEST(DISABLED_GAPI_Pipeline, 1DMatBetweenIslands)
cv::Mat out_mat;

cv::Mat ref_mat({dim}, CV_8U);
ref_mat.dims = 1;
ref_mat.size.dims = ref_mat.dims = 1;
ref_mat.setTo(0);

cv::GMat in;
Expand All @@ -534,7 +534,7 @@ TEST(DISABLED_GAPI_Pipeline, 1DMatWithinSingleIsland)
cv::Mat out_mat;

cv::Mat ref_mat({dim}, CV_8U);
ref_mat.dims = 1;
ref_mat.size.dims = ref_mat.dims = 1;
ref_mat.setTo(0);

cv::GMat in;
Expand Down
49 changes: 25 additions & 24 deletions modules/tracking/src/twist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,53 @@ namespace detail
inline namespace tracking
{

void computeInteractionMatrix(const cv::Mat& uv, const cv::Mat& depths, const cv::Mat& K, cv::Mat& J)
void computeInteractionMatrix(const cv::Mat& uv, const cv::Mat& depths, const cv::Mat& K_, cv::Mat& J)
{
CV_Assert(uv.cols == depths.cols);
CV_Assert(depths.type() == CV_32F);
CV_Assert(K.cols == 3 && K.rows == 3);
CV_Assert(K_.cols == 3 && K_.rows == 3 && K_.type() == CV_32F);

J.create(depths.cols * 2, 6, CV_32F);
J.setTo(0);

cv::Mat Kinv;
cv::invert(K, Kinv);
Matx33f K, Kinv;
K_.copyTo(K);
Kinv = K.inv();

cv::Mat xy(3, 1, CV_32F);
cv::Mat Jp(2, 6, CV_32F);
for (int i = 0; i < uv.cols; i++)
{
const float z = depths.at<float>(i);
// skip points with zero depth
if (cv::abs(z) < 0.001f)
continue;

const cv::Point3f p(uv.at<float>(0, i), uv.at<float>(1, i), 1.0);
const cv::Matx31f p(uv.at<float>(0, i), uv.at<float>(1, i), 1.0);

// convert to normalized image-plane coordinates
xy = Kinv * cv::Mat(p);
float x = xy.at<float>(0);
float y = xy.at<float>(1);
Matx31f xy = Kinv * p;
float x = xy(0,0);
float y = xy(1,0);

Matx<float, 2, 6> Jp;

// 2x6 Jacobian for this point
Jp.at<float>(0, 0) = -1 / z;
Jp.at<float>(0, 1) = 0.0;
Jp.at<float>(0, 2) = x / z;
Jp.at<float>(0, 3) = x * y;
Jp.at<float>(0, 4) = -(1 + x * x);
Jp.at<float>(0, 5) = y;
Jp.at<float>(1, 0) = 0.0;
Jp.at<float>(1, 1) = -1 / z;
Jp.at<float>(1, 2) = y / z;
Jp.at<float>(1, 3) = 1 + y * y;
Jp.at<float>(1, 4) = -x * y;
Jp.at<float>(1, 5) = -x;
Jp(0, 0) = -1 / z;
Jp(0, 1) = 0.0;
Jp(0, 2) = x / z;
Jp(0, 3) = x * y;
Jp(0, 4) = -(1 + x * x);
Jp(0, 5) = y;
Jp(1, 0) = 0.0;
Jp(1, 1) = -1 / z;
Jp(1, 2) = y / z;
Jp(1, 3) = 1 + y * y;
Jp(1, 4) = -x * y;
Jp(1, 5) = -x;

Jp = K(cv::Rect(0, 0, 2, 2)) * Jp;
Jp = Matx22f(K(0,0), K(0,1), K(1,0), K(1,1)) * Jp;

// push into Jacobian
Jp.copyTo(J(cv::Rect(0, 2 * i, 6, 2)));
Mat(2, 6, CV_32F, Jp.val).copyTo(J(cv::Rect(0, 2 * i, 6, 2)));
}
}

Expand Down
Loading