Ask Your Question
0

Basic matrix operations producing null pointer members

asked 2013-01-04 07:52:23 -0600

UltraBird gravatar image

updated 2013-01-04 07:55:44 -0600

Please bear with me, I'm totally new to OpenCV. array1 and array2 primitive arrays of doubles, of the same length.

cv::Mat_<double> A (lengthOfArray1, 1, array1);
cv::Mat_<double> B (lengthOfArray1, 1, array2);
cv::Mat_<double> C = A - B;

The problem is that what I get for C is an array with the right dimensions but a null pointer data, refcount, datastart, dataend, datalimit, and allocator. I must be doing something silly.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-01-04 13:39:35 -0600

Your code no problem.

    int lengthOfArray1 = 10;
    int lengthOfArray2 = 10;

    double* array1 = new double[lengthOfArray1];
    double* array2 = new double[lengthOfArray2];

    for (int i=0;i < 10;i++)
    {
        array1[i] = 20;
        array2[i] = 10;
    }

  cv::Mat_<double> A (lengthOfArray1, 1, array1);
  cv::Mat_<double> B (lengthOfArray2, 1, array2);
  cv::Mat_<double> C = A - B;

  cout << C << endl;

image description

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-01-04 07:52:23 -0600

Seen: 385 times

Last updated: Jan 04 '13