Inplace Mat::convertTo (Bug #1)
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
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
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
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
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
updating tutorial #1
Merge pull request #1 from Itseez/2.4
Add calculating integral image using IPP
Merge pull request #1 from ImAlsoGreg/master
add include limits, for compilers that dont add it implicitly
Merge pull request #1 from Itseez/2.4
2.4
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