Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9076241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:04:04+00:00 2026-06-16T19:04:04+00:00

Consider two matrices as input parameters of the following sample_method() method, I want to

  • 0

Consider two matrices as input parameters of the following sample_method() method, I want to merge the two matrices m1 and m2 in a new matrix m12. I read this reference and then also this reference, but these two solutions copy the data from source matrices to the destination matrix.

bool sample_method(const Mat& m1, const Mat& m2)
{
    if(m1.cols != m2.cols)
    {
        cout << "Error: m1.cols != m2.cols" << endl;
        return false;
    }

    Mat m12(m1.rows+m2.rows,m1.cols,DataType<float>::type);
    // merging m1 and m2
    m12(Rect(0,0,m1.cols,m1.rows)) = m1;
    m12(Rect(0,m1.rows,m2.cols,m2.rows)) = m2;

    return true;
}

How could I concatenate two Mat in a single Mat without copying the data?
Why my code does not work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:04:05+00:00Added an answer on June 16, 2026 at 7:04 pm

    I don’t think you are ever going to get that to work. A Mat object has one pointer to its data and then parameters that help it to interpret that data. You are asking to make a Mat out of two unrelated blocks of memory, there is no way to do that without somehow storing a pointer to both of them and Mat does not have a member variable to put it in..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I frequently use the NSDate compare method - but I want to consider two
Consider the following two EXPLAINs: EXPLAIN SELECT * FROM sales WHERE title != 'The'
Consider the following two Java files that contain a simplified version of my issue
Consider two forms: form1 and form2 form1 calls form2 : form2 frm = new
Consider two following pieces of code - the only difference between them is a
I have two matrices A and B with same number of rows. Consider a
I have two matrices I want to perform a loop on. My problem is
Consider the following two methods, written in pseudo code, that fetches a complex data
Today, I've stumbled over the following: Consider two classes NewClass and NewClass1, which have
I've been thinking of the following. Consider two files: A.cpp: template<class T> void g(T)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.