mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
fixed bug with possible memory corruption in CvMat m = iarray.getMat(); expressions (ticket #1054)
This commit is contained in:
parent
d998c73769
commit
2dc981aaa8
@ -1899,7 +1899,7 @@ bool cv::findChessboardCorners( const InputArray& _image, Size patternSize,
|
||||
{
|
||||
int count = patternSize.area()*2;
|
||||
vector<Point2f> tmpcorners(count+1);
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat(); CvMat c_image = image;
|
||||
bool ok = cvFindChessboardCorners(&c_image, patternSize,
|
||||
(CvPoint2D32f*)&tmpcorners[0], &count, flags ) > 0;
|
||||
if( count > 0 )
|
||||
@ -1919,7 +1919,7 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
|
||||
Mat corners = _corners.getMat();
|
||||
if( corners.empty() )
|
||||
return;
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat(); CvMat c_image = _image.getMat();
|
||||
int nelems = corners.checkVector(2, CV_32F, true);
|
||||
CV_Assert(nelems >= 0);
|
||||
cvDrawChessboardCorners( &c_image, patternSize, (CvPoint2D32f*)corners.data,
|
||||
|
@ -3294,11 +3294,14 @@ void cv::projectPoints( const InputArray& _opoints,
|
||||
CvMat *pdpdrot=0, *pdpdt=0, *pdpdf=0, *pdpdc=0, *pdpddist=0;
|
||||
|
||||
_ipoints.create(npoints, 1, CV_MAKETYPE(depth, 2), -1, true);
|
||||
CvMat imagePoints = _ipoints.getMat();
|
||||
CvMat objectPoints = opoints;
|
||||
CvMat cameraMatrix = _cameraMatrix.getMat();
|
||||
CvMat rvec = _rvec.getMat(), tvec = _tvec.getMat();
|
||||
CvMat distCoeffs = _distCoeffs.getMat();
|
||||
CvMat c_imagePoints = _ipoints.getMat();
|
||||
CvMat c_objectPoints = opoints;
|
||||
Mat cameraMatrix = _cameraMatrix.getMat();
|
||||
Mat distCoeffs = _distCoeffs.getMat();
|
||||
Mat rvec = _rvec.getMat(), tvec = _tvec.getMat();
|
||||
CvMat c_cameraMatrix = cameraMatrix;
|
||||
CvMat c_rvec = rvec, c_tvec = tvec;
|
||||
CvMat c_distCoeffs = distCoeffs;
|
||||
int ndistCoeffs = distCoeffs.rows + distCoeffs.cols - 1;
|
||||
|
||||
if( _jacobian.needed() )
|
||||
@ -3312,8 +3315,8 @@ void cv::projectPoints( const InputArray& _opoints,
|
||||
pdpddist = &(dpddist = jacobian.colRange(10, 10+ndistCoeffs));
|
||||
}
|
||||
|
||||
cvProjectPoints2( &objectPoints, &rvec, &tvec, &cameraMatrix, &distCoeffs,
|
||||
&imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio );
|
||||
cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, &c_distCoeffs,
|
||||
&c_imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio );
|
||||
}
|
||||
|
||||
cv::Mat cv::initCameraMatrix2D( const InputArrayOfArrays& objectPoints,
|
||||
@ -3378,7 +3381,8 @@ void cv::calibrationMatrixValues( const InputArray& _cameraMatrix, Size imageSiz
|
||||
double& fovx, double& fovy, double& focalLength,
|
||||
Point2d& principalPoint, double& aspectRatio )
|
||||
{
|
||||
CvMat c_cameraMatrix = _cameraMatrix.getMat();
|
||||
Mat cameraMatrix = _cameraMatrix.getMat();
|
||||
CvMat c_cameraMatrix = cameraMatrix;
|
||||
cvCalibrationMatrixValues( &c_cameraMatrix, imageSize, apertureWidth, apertureHeight,
|
||||
&fovx, &fovy, &focalLength, (CvPoint2D64f*)&principalPoint, &aspectRatio );
|
||||
}
|
||||
@ -3453,11 +3457,14 @@ void cv::stereoRectify( const InputArray& _cameraMatrix1, const InputArray& _dis
|
||||
double alpha, Size newImageSize,
|
||||
Rect* validPixROI1, Rect* validPixROI2 )
|
||||
{
|
||||
CvMat c_cameraMatrix1 = _cameraMatrix1.getMat();
|
||||
CvMat c_cameraMatrix2 = _cameraMatrix2.getMat();
|
||||
CvMat c_distCoeffs1 = _distCoeffs1.getMat();
|
||||
CvMat c_distCoeffs2 = _distCoeffs2.getMat();
|
||||
CvMat c_R = _Rmat.getMat(), c_T = _Tmat.getMat();
|
||||
Mat cameraMatrix1 = _cameraMatrix1.getMat(), cameraMatrix2 = _cameraMatrix2.getMat();
|
||||
Mat distCoeffs1 = _distCoeffs1.getMat(), distCoeffs2 = _distCoeffs2.getMat();
|
||||
Mat Rmat = _Rmat.getMat(), Tmat = _Tmat.getMat();
|
||||
CvMat c_cameraMatrix1 = cameraMatrix1;
|
||||
CvMat c_cameraMatrix2 = cameraMatrix2;
|
||||
CvMat c_distCoeffs1 = distCoeffs1;
|
||||
CvMat c_distCoeffs2 = distCoeffs2;
|
||||
CvMat c_R = Rmat, c_T = Tmat;
|
||||
|
||||
int rtype = CV_64F;
|
||||
_Rmat1.create(3, 3, rtype);
|
||||
@ -3486,7 +3493,8 @@ bool cv::stereoRectifyUncalibrated( const InputArray& _points1, const InputArray
|
||||
_Hmat1.create(3, 3, rtype);
|
||||
_Hmat2.create(3, 3, rtype);
|
||||
Mat F = _Fmat.getMat();
|
||||
CvMat c_pt1 = _points1.getMat(), c_pt2 = _points2.getMat();
|
||||
Mat points1 = _points1.getMat(), points2 = _points2.getMat();
|
||||
CvMat c_pt1 = points1, c_pt2 = points2;
|
||||
CvMat c_F, *p_F=0, c_H1 = _Hmat1.getMat(), c_H2 = _Hmat2.getMat();
|
||||
if( F.size() == Size(3, 3) )
|
||||
p_F = &(c_F = F);
|
||||
@ -3498,7 +3506,8 @@ cv::Mat cv::getOptimalNewCameraMatrix( const InputArray& _cameraMatrix,
|
||||
Size imgSize, double alpha, Size newImgSize,
|
||||
Rect* validPixROI )
|
||||
{
|
||||
CvMat c_cameraMatrix = _cameraMatrix.getMat(), c_distCoeffs = _distCoeffs.getMat();
|
||||
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
|
||||
CvMat c_cameraMatrix = cameraMatrix, c_distCoeffs = distCoeffs;
|
||||
|
||||
Mat newCameraMatrix(3, 3, CV_MAT_TYPE(c_cameraMatrix.type));
|
||||
CvMat c_newCameraMatrix = newCameraMatrix;
|
||||
|
@ -1106,12 +1106,12 @@ cv::Mat cv::findFundamentalMat( const InputArray& _points1, const InputArray& _p
|
||||
void cv::computeCorrespondEpilines( const InputArray& _points, int whichImage,
|
||||
const InputArray& _Fmat, OutputArray _lines )
|
||||
{
|
||||
Mat points = _points.getMat();
|
||||
Mat points = _points.getMat(), F = _Fmat.getMat();
|
||||
int npoints = points.checkVector(2);
|
||||
CV_Assert( npoints >= 0 && (points.depth() == CV_32F || points.depth() == CV_32S));
|
||||
|
||||
_lines.create(npoints, 1, CV_32FC3, -1, true);
|
||||
CvMat c_points = points, c_lines = _lines.getMat(), c_F = _Fmat.getMat();
|
||||
CvMat c_points = points, c_lines = _lines.getMat(), c_F = F;
|
||||
cvComputeCorrespondEpilines(&c_points, whichImage, &c_F, &c_lines);
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,9 @@ void cv::solvePnP( const InputArray& _opoints, const InputArray& _ipoints,
|
||||
|
||||
_rvec.create(3, 1, CV_64F);
|
||||
_tvec.create(3, 1, CV_64F);
|
||||
Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat();
|
||||
CvMat c_objectPoints = opoints, c_imagePoints = ipoints;
|
||||
CvMat c_cameraMatrix = _cameraMatrix.getMat(), c_distCoeffs = _distCoeffs.getMat();
|
||||
CvMat c_cameraMatrix = cameraMatrix, c_distCoeffs = distCoeffs;
|
||||
CvMat c_rvec = _rvec.getMat(), c_tvec = _tvec.getMat();
|
||||
cvFindExtrinsicCameraParams2(&c_objectPoints, &c_imagePoints, &c_cameraMatrix,
|
||||
c_distCoeffs.rows*c_distCoeffs.cols ? &c_distCoeffs : 0,
|
||||
|
@ -146,9 +146,10 @@ double cv::getWindowProperty(const string& winname, int prop_id)
|
||||
return cvGetWindowProperty(winname.c_str(),prop_id);
|
||||
}
|
||||
|
||||
void cv::imshow( const string& winname, const InputArray& img )
|
||||
void cv::imshow( const string& winname, const InputArray& _img )
|
||||
{
|
||||
CvMat c_img = img.getMat();
|
||||
Mat img = _img.getMat();
|
||||
CvMat c_img = img;
|
||||
cvShowImage( winname.c_str(), &c_img );
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,8 @@ void cv::cornerSubPix( const InputArray& _image, InputOutputArray _corners,
|
||||
Mat corners = _corners.getMat();
|
||||
int ncorners = corners.checkVector(2);
|
||||
CV_Assert( ncorners >= 0 && corners.depth() == CV_32F );
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat();
|
||||
CvMat c_image = image;
|
||||
|
||||
cvFindCornerSubPix( &c_image, (CvPoint2D32f*)corners.data, ncorners,
|
||||
winSize, zeroZone, criteria );
|
||||
|
@ -1109,7 +1109,8 @@ void cv::HoughLines( const InputArray& _image, OutputArray _lines,
|
||||
double srn, double stn )
|
||||
{
|
||||
Ptr<CvMemStorage> storage = cvCreateMemStorage(STORAGE_SIZE);
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat();
|
||||
CvMat c_image = image;
|
||||
CvSeq* seq = cvHoughLines2( &c_image, storage, srn == 0 && stn == 0 ?
|
||||
CV_HOUGH_STANDARD : CV_HOUGH_MULTI_SCALE,
|
||||
rho, theta, threshold, srn, stn );
|
||||
@ -1121,7 +1122,8 @@ void cv::HoughLinesP( const InputArray& _image, OutputArray _lines,
|
||||
double minLineLength, double maxGap )
|
||||
{
|
||||
Ptr<CvMemStorage> storage = cvCreateMemStorage(STORAGE_SIZE);
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat();
|
||||
CvMat c_image = image;
|
||||
CvSeq* seq = cvHoughLines2( &c_image, storage, CV_HOUGH_PROBABILISTIC,
|
||||
rho, theta, threshold, minLineLength, maxGap );
|
||||
seqToMat(seq, _lines);
|
||||
@ -1133,7 +1135,8 @@ void cv::HoughCircles( const InputArray& _image, OutputArray _circles,
|
||||
int minRadius, int maxRadius )
|
||||
{
|
||||
Ptr<CvMemStorage> storage = cvCreateMemStorage(STORAGE_SIZE);
|
||||
CvMat c_image = _image.getMat();
|
||||
Mat image = _image.getMat();
|
||||
CvMat c_image = image;
|
||||
CvSeq* seq = cvHoughCircles( &c_image, storage, method,
|
||||
dp, min_dist, param1, param2, minRadius, maxRadius );
|
||||
seqToMat(seq, _circles);
|
||||
|
@ -810,8 +810,8 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i
|
||||
void cv::inpaint( const InputArray& _src, const InputArray& _mask, OutputArray _dst,
|
||||
double inpaintRange, int flags )
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
_dst.create( src.size(), src.type() );
|
||||
CvMat c_src = src, c_mask = _mask.getMat(), c_dst = _dst.getMat();
|
||||
CvMat c_src = src, c_mask = mask, c_dst = _dst.getMat();
|
||||
cvInpaint( &c_src, &c_mask, &c_dst, inpaintRange, flags );
|
||||
}
|
||||
|
@ -607,7 +607,8 @@ Moments::operator CvMoments() const
|
||||
cv::Moments cv::moments( const InputArray& _array, bool binaryImage )
|
||||
{
|
||||
CvMoments om;
|
||||
CvMat c_array = _array.getMat();
|
||||
Mat arr = _array.getMat();
|
||||
CvMat c_array = arr;
|
||||
cvMoments(&c_array, &om, binaryImage);
|
||||
return om;
|
||||
}
|
||||
|
@ -303,9 +303,10 @@ cvWatershed( const CvArr* srcarr, CvArr* dstarr )
|
||||
}
|
||||
|
||||
|
||||
void cv::watershed( const InputArray& src, InputOutputArray markers )
|
||||
void cv::watershed( const InputArray& _src, InputOutputArray markers )
|
||||
{
|
||||
CvMat c_src = src.getMat(), c_markers = markers.getMat();
|
||||
Mat src = _src.getMat();
|
||||
CvMat c_src = _src.getMat(), c_markers = markers.getMat();
|
||||
cvWatershed( &c_src, &c_markers );
|
||||
}
|
||||
|
||||
|
@ -291,11 +291,12 @@ cvCamShift( const void* imgProb, CvRect windowIn,
|
||||
|
||||
|
||||
cv::RotatedRect cv::CamShift( const InputArray& _probImage, Rect& window,
|
||||
TermCriteria criteria )
|
||||
TermCriteria criteria )
|
||||
{
|
||||
CvConnectedComp comp;
|
||||
CvBox2D box;
|
||||
CvMat c_probImage = _probImage.getMat();
|
||||
Mat probImage = _probImage.getMat();
|
||||
CvMat c_probImage = probImage;
|
||||
cvCamShift(&c_probImage, window, (CvTermCriteria)criteria, &comp, &box);
|
||||
window = comp.rect;
|
||||
return RotatedRect(Point2f(box.center), Size2f(box.size), box.angle);
|
||||
@ -304,7 +305,8 @@ cv::RotatedRect cv::CamShift( const InputArray& _probImage, Rect& window,
|
||||
int cv::meanShift( const InputArray& _probImage, Rect& window, TermCriteria criteria )
|
||||
{
|
||||
CvConnectedComp comp;
|
||||
CvMat c_probImage = _probImage.getMat();
|
||||
Mat probImage = _probImage.getMat();
|
||||
CvMat c_probImage = probImage;
|
||||
int iters = cvMeanShift(&c_probImage, window, (CvTermCriteria)criteria, &comp );
|
||||
window = comp.rect;
|
||||
return iters;
|
||||
|
@ -1865,12 +1865,12 @@ cvEstimateRigidTransform( const CvArr* matA, const CvArr* matB, CvMat* matM, int
|
||||
return 1;
|
||||
}
|
||||
|
||||
cv::Mat cv::estimateRigidTransform( const InputArray& A,
|
||||
const InputArray& B,
|
||||
cv::Mat cv::estimateRigidTransform( const InputArray& src1,
|
||||
const InputArray& src2,
|
||||
bool fullAffine )
|
||||
{
|
||||
Mat M(2, 3, CV_64F);
|
||||
CvMat matA = A.getMat(), matB = B.getMat(), matM = M;
|
||||
Mat M(2, 3, CV_64F), A = src1.getMat(), B = src2.getMat();
|
||||
CvMat matA = A, matB = B, matM = M;
|
||||
cvEstimateRigidTransform(&matA, &matB, &matM, fullAffine);
|
||||
return M;
|
||||
}
|
||||
|
@ -445,7 +445,8 @@ cvSegmentMotion( const CvArr* mhiimg, CvArr* segmask, CvMemStorage* storage,
|
||||
void cv::updateMotionHistory( const InputArray& _silhouette, InputOutputArray _mhi,
|
||||
double timestamp, double duration )
|
||||
{
|
||||
CvMat c_silhouette = _silhouette.getMat(), c_mhi = _mhi.getMat();
|
||||
Mat silhouette = _silhouette.getMat();
|
||||
CvMat c_silhouette = silhouette, c_mhi = _mhi.getMat();
|
||||
cvUpdateMotionHistory( &c_silhouette, &c_mhi, timestamp, duration );
|
||||
}
|
||||
|
||||
@ -465,7 +466,8 @@ double cv::calcGlobalOrientation( const InputArray& _orientation, const InputArr
|
||||
const InputArray& _mhi, double timestamp,
|
||||
double duration )
|
||||
{
|
||||
CvMat c_orientation = _orientation.getMat(), c_mask = _mask.getMat(), c_mhi = _mhi.getMat();
|
||||
Mat orientation = _orientation.getMat(), mask = _mask.getMat(), mhi = _mhi.getMat();
|
||||
CvMat c_orientation = orientation, c_mask = mask, c_mhi = mhi;
|
||||
return cvCalcGlobalOrientation(&c_orientation, &c_mask, &c_mhi, timestamp, duration);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user