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

  • Home
  • SEARCH
  • 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 8788797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:13:41+00:00 2026-06-13T22:13:41+00:00

I have previously asked a question about matrix multiplication in OpenCV and managed to

  • 0

I have previously asked a question about matrix multiplication in OpenCV and managed to find the correct answer. However, when I try to do this, I get erroneous results:

#include <iostream>

#include <cmath>

#include "opencv2/core/core.hpp"

using namespace std;

int main() {

// Vars.
int a[4] = {3,2,1,4};
int b[4] = {2,5,6,1};

// Pointers
int *p1, *p2;
int res(5);

// Init.
p1 = &a[0];
p2 = &b[0];

for(int i=0;i<4;i++) {
    res += (*(p1+i) - 2)*(*(p2+i) - 3);
}
cout << res << endl; // This is fine!

unsigned int p[4] = {3,1,2,4};
cv::Mat testMat = cv::Mat(1,4,CV_8U,p);
cout << testMat << endl; // Shows [3, 0, 0, 0] !!!!!
cout << testMat.at<unsigned int>(0,3) << endl; // Displays 4


//cv::Mat resDot = testMat*(testMat.t());
cv::Mat testMatTransp(testMat.t());
cout << testMatTransp.at<unsigned int>(0,0) << endl; // Shows Jibrish 56928323
return(0);
}

Unless I am missing something, this could should print out all the information correctly, right? Am I supposed to call any destructor or anything? I thought it is based on RAII, so unless I use “new” based initialisation, I don’t need to call destructors. Is that right? Any nudge in the right direction would be appreciated!

  • 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-13T22:13:42+00:00Added an answer on June 13, 2026 at 10:13 pm

    in

    cv::Mat testMat = cv::Mat(1,4,CV_8U,p);
    

    CV_8U means 8 bit unsigned. If you change it to

    cv::Mat testMat = cv::Mat(1,4,CV_32S,p);
    

    it should work. Alternatively, changing

    unsigned int p[4] = {3,1,2,4};
    

    to

    unsigned char p[4] = {3,1,2,4};
    

    should work too

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

Sidebar

Related Questions

I've previously asked a question about an issue I have been experiencing with CSharpOptParse
I have previously asked a question about how can I write a code block
I previously asked this question about how to make versioned serializaion using boost::serialization::access I
I've previously asked a question of about Delegates does anyone have a must have
I have previously solved a similar problem in this question , where I asked
I previously asked a question about a delphi and a C/C++ DLL. I have
Ok, so I previously asked a question asking about my options, I have looked
This question is about the same program I previously asked about . To recap,
I previously asked this question XMLParser Advice . However I am still unable to
Previously Id asked this question Putting a simple expression language into java about allowing

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.