Inplace Mat::convertTo (Bug #1)


Added by Vadim Pisarevsky over 15 years ago. Updated over 9 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

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

Description

Mat::convertTo used with inplace matrix cause buffer overflow if
destination data type is different from source data type.

At the source code for the function (cxconvert.cpp) there is no check for
inplace case, so destination matrix is created using required type. This
operation will overwrite *this data in case *this is same of destination,
as is for inplace operation.

// create a 5x5x1ch float matrix and assign 0.5 to all elements
cv::Mat_<float> MyMatFloat = cv::Mat(5 , 5, CV_32FC1,cv::Scalar(0.5));

// declare an unsigned char matrix
cv::Mat_<uchar> MyMatUChar;

// inplace convertTo. Here you will have error
MyMatFloat.convertTo(MyMatFloat,CV_8UC1,255.0,0);

// This will work fine, all destination elements will have the value
127
MyMatFloat.convertTo(MyMatUChar,CV_8UC1,255.0,0);


Related issues

related to Bug #1981: read_csv crashes when reading a csv file with only one co... Done 2012-05-24
related to Patch #1362: velSize in optflowbm.cpp is wrong Done

Associated revisions

Revision 26dbe3c9
Added by bornet about 19 years ago

Patch from Kertesz Csaba:

#1: It solves a value range problem by such a v4l2 image properties which have
too narrow value range: e.g. 0-7

#2: General bug in my last patch. v4l (VIDIOCGPICT) gives back the default
image properties and changes the webcam to the default state. There is no
feedback from v4l if user modifies the image properties of a device. The
functionality after these modification is normal: OpenCV returns with the
default or last adjusted value of an image property.

git-svn-id: file://localhost/home/tolik/svnrepo/trunk/opencv@451 c5418bc3-7546-4aae-8bad-fa6f2f3e53e6

Revision 33ee1fc4
Added by bornet about 19 years ago

Patch from Kertesz Csaba:

#1: It solves a value range problem by such a v4l2 image properties which have
too narrow value range: e.g. 0-7

#2: General bug in my last patch. v4l (VIDIOCGPICT) gives back the default
image properties and changes the webcam to the default state. There is no
feedback from v4l if user modifies the image properties of a device. The
functionality after these modification is normal: OpenCV returns with the
default or last adjusted value of an image property.

git-svn-id: file://localhost/home/tolik/svnrepo/trunk@451 c5418bc3-7546-4aae-8bad-fa6f2f3e53e6

Revision d69b1a46
Added by Vadim Pisarevsky over 16 years ago

1.0 promoted to 1.1 (1.1 technology preview #1 for now)

git-svn-id: file://localhost/home/tolik/svnrepo/trunk@1311 c5418bc3-7546-4aae-8bad-fa6f2f3e53e6

Revision 94e9fa56
Added by Vadim Pisarevsky over 16 years ago

1.0 promoted to 1.1 (1.1 technology preview #1 for now)

git-svn-id: file://localhost/home/tolik/svnrepo/trunk/opencv@1311 c5418bc3-7546-4aae-8bad-fa6f2f3e53e6

Revision 99299b36
Added by Andrey Pavlenko about 12 years ago

updating tutorial #1

Revision df4b67a7
Added by kdrobnyh over 11 years ago

Merge pull request #1 from Itseez/2.4

Add calculating integral image using IPP

Revision 34f6b17c
Added by Eric Christiansen over 11 years ago

Merge pull request #1 from ImAlsoGreg/master

add include limits, for compilers that dont add it implicitly

Revision c098c189
Added by Maks Naumov almost 11 years ago

Merge pull request #1 from Itseez/2.4

2.4

Revision b2c59225
Added by sbokov over 9 years ago

Merge pull request #1 from Itseez/master

Update

History

Updated by Vadim Pisarevsky over 15 years ago

fxed in SVN 2307

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Updated by Maksim Shabunin over 9 years ago

test 1

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/mshabunin/test2/issues/841

Updated by Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/mshabunin/test2/issues/132

Also available in: Atom PDF