C++ cv::mat::clone() does not copy the last entry for 1D cv::mat objects (Bug #2266)


Added by Roy Wang over 12 years ago. Updated over 12 years ago.


Status:Cancelled Start date:2012-08-13
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:core
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Test machine: Gateway NV53 laptop (AMD Turion II X2 M500, 4GB ram), Ubuntu 12.04, OpenCV 2.4.2 Release (installed from source), programming IDE is QT-Creator 2.4.1 (QT 4.8.0 32-bit).

 1  int somenum=5; // this could be any positive number
 2  cv::Mat Array1(somenum,1,CV_64F);
 3  cv::Mat Array2(somenum,2,CV_64F);
 4
 5  for(int i=0;i<Array1.rows;i++)
 6      Array1.at<double>(i,1)=(double)i;
 7
 8  for(int i=0;i<Array2.rows;i++)
 9      Array2.at<double>(i,1)=(double)i;
10
11  cv::Mat Array1clone=Array1.clone();
12  for(int i=0;i<Array1clone.rows;i++)
13      qDebug("Array1clone coordinates: r%d value is %.2f\n",i,Array1clone.at<double>(i,1));
14
15  cv::Mat Array2clone=Array2.clone();
16  for(int i=0;i<Array2clone.rows;i++)
17      qDebug("Array2clone coordinates: r%d value is %.2f\n",i,Array2clone.at<double>(i,1));

output:

Array1clone coordinates: r0 value is 0.00
Array1clone coordinates: r1 value is 1.00
Array1clone coordinates: r2 value is 2.00
Array1clone coordinates: r3 value is 3.00
Array1clone coordinates: r4 value is 5.00
Array2clone coordinates: r0 value is 0.00
Array2clone coordinates: r1 value is 1.00
Array2clone coordinates: r2 value is 2.00
Array2clone coordinates: r3 value is 3.00
Array2clone coordinates: r4 value is 4.00

Array1 is created as a 1D cv::mat object, and Array2 is created as a 2D cv::mat object. Array1 and Array2 are supposed to have {0,1,2,3,4} in the first column, but for some reason the clone version of Array1, Array1clone, contains garbage data (5) in the last entry.


Associated revisions

Revision 0a90d6dd
Added by Roman Donchenko about 11 years ago

Merge pull request #2266 from vpisarev:ipp_norm_fix

History

Updated by Andrey Kamaev over 12 years ago

Please, use wiki formatting creating tickets.

  • Description changed from Test machine: Gateway NV53 laptop (AMD Turion II X2 M500, 4GB ram), Ubuntu 12... to Test machine: Gateway NV53 laptop (AMD Turion II X2 M500, 4GB ram), Ubuntu 12... More
  • Assignee set to Vadim Pisarevsky
  • Category set to core

Updated by Roy Wang over 12 years ago

Sorry Andrey, I will use the guideline next time.

Please close this issue, because I forgot OpenCV uses 0-start indexing instead of 1-start indexing. I clearly used 1-start indexing, and thus got an undesirable result. There is no problem with the cv::mat::clone() function. Sorry for the inconvenience.

Updated by Andrey Kamaev over 12 years ago

Ok. closing as not an issue.

  • Status changed from Open to Cancelled
  • Target version set to 2.4.3
  • Assignee changed from Vadim Pisarevsky to Andrey Kamaev

Also available in: Atom PDF