bug in cvAddS (Bug #420)
Description
The cvAddS function is apparently having problems to deal with 3D arrays. The following report results from runing OpenCV trough my Matlab interface "cvlib_mex"
This call results in calling cvAddS and works fine
x=cvlib_mex('addS', rand(1,5,4), 100);
However, if I increase just 1 in the 3rth dim, I get this error message
x=cvlib_mex('addS', rand(1,5,5), 100);
??? Unexpected Standard exception from MEX file.
What() is:C:\programs\OpenCV_SVN\modules\core\include\opencv2/core/operations.hpp:1838: error:
(-215) cn <= 4
Note that I can call also cvAdd with
x=cvlib_mex('add', rand(1,5,5), rand(1,5,5));
and here it runs fine again.
Sorry if this report does not use a short C code example, but C what I have in cvlib_mex and I have no reason to believe that the error is there. Indeed the two calls are nearly equal, as shown below
if (!strcmp(op,"add"))
cvAdd( src1, src2, dst, NULL );
else if (!strcmp(op,"addS"))
cvAddS( src1, value, dst, NULL );
Joaquim Luis
Associated revisions
Merge pull request #420 from asmaloney:check-mem-alloc
History
Updated by Vadim Pisarevsky over 14 years ago
The following sample in C works well with the latest OpenCV from SVN trunk:
#include "cv.h"
int main(int, char**)
{
int sz[] = {1, 5, 5};
CvMatND* src = cvCreateMatND(3, sz, CV_64F);
CvMatND* dst = cvCreateMatND(3, sz, CV_64F);
CvRNG rng = cvRNG(-1);
cvRandArr(&rng, src, CV_RAND_UNI, cvScalarAll(-100), cvScalarAll(100));
cvAddS(src, cvScalarAll(100), dst, 0);
cvSave("_input.xml", src);
cvSave("_output.xml", dst);
return 0;
}
- Status changed from Open to Done
- (deleted custom field) set to worksforme