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 7793725
In Process

The Archive Base Latest Questions

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

I’m probably being incredibly stupid here but I’m having trouble doing some basicaly Mat

  • 0

I’m probably being incredibly stupid here but I’m having trouble doing some basicaly Mat multiplication using OpenCV for Android.

I have two Mat’s both of the same type, CV_64F

mat1 has size: 3 rows, 3 cols
mat2 has size: 3 rows, 1 cols

I want to multiply them to give the product mat3 of size 3 rows, 1 cols.

I’ve tried using:

Mat mat3 = new Mat(3, 1, CvType.CV_64F);
Core.multiply(mat1, mat2, mat3);

But I get an error:

CvException
[org.opencv.core.CvException:/home/andreyk/OpenCV2/trunk/opencv_2.3.1.b2/modules/core/src/arithm.cpp:1253:
error: (-209) The operation is neither ‘array op array’ (where arrays
have the same size and the same number of channels), nor ‘array op
scalar’, nor ‘scalar op array’ in function void cv::arithm_op(const
cv::_InputArray&, const cv::_InputArray&, const cv::_OutputArray&,
const cv::_InputArray&, int, void (*)(const uchar, size_t, const
uchar*, size_t, uchar*, size_t, cv::Size, void*), bool, void*)

What am I doing wrong?

Thanks for any help in advance.

EDIT:
If it helps, the 3×3 matrix mat2 is the result of Imgproc.getPerspectiveTransform and the rest of the code is as follows:

Mat mat1 = new Mat(3, 1, CvType.CV_64F);
mat1.put(0, 0, 2.0);
mat1.put(1, 0, 0.5);
mat1.put(2, 0, 1.0);

Mat mat3 = new Mat(3, 1, CvType.CV_64F);
Core.multiply(mat2, mat1, mat3);
  • 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-01T22:34:43+00:00Added an answer on June 1, 2026 at 10:34 pm

    You are basicly trying to perform the following operation now:

    [ 0 ]   [ 0 1 2 ]
    [ 1 ] * [ 3 4 5 ]
    [ 2 ]   [ 6 7 8 ]
    

    In here * is multiplication. A matrix multiplication cannot be done this way. Read on matrix multiplications here.

    The operation you would like to perform is :

                [ 0 1 2 ]
    [ 0 1 2 ] * [ 3 4 5 ]
                [ 6 7 8 ]
    

    To get your code working make the following changes:

    Mat mat1 = new Mat(1, 3, CvType.CV_64F); // A matrix with 1 row and 3 columns
    mat1.put(0, 0, 2.0); // Set row 1 , column 1
    mat1.put(0, 1, 0.5); // Set row 1 , column 2
    mat1.put(0, 2, 1.0); // Set row 1 , column 3
    

    EDIT

    Also, you’re using the method Core.multiply. In the documentation of OpenCv it mentions:
    The function multiply calculates the per-element product of two matrices.
    If you are looking for a matrix product, not per-element product, see Core.gemm().

    The function gemm(src1, src2, alpha, src3, beta, dest, flags) performs the multiplication according to the following function:

    dest = alpha * src1 * src2 + beta * src3
    

    Basic matrix multiplcation (in your case) is done by:

    Core.gemm(mat2, mat1, 1, NULL, 0, mat3, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

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.