Ask Your Question

salkuma's profile - activity

2014-05-12 02:01:20 -0600 received badge  Supporter (source)
2014-04-15 04:01:06 -0600 commented question Opencv 2.4.8 & VS2012

You could find a solution here and tutorial page

2014-04-04 02:22:14 -0600 commented answer Assertion failed error

Surely, I tested on visual studio 2012. I used 300 x 300 size color jpg file and worked find. Would you let me know size of image you use? and plz double check image path.

2014-04-03 21:41:36 -0600 answered a question Assertion failed error

I don't figure out what you supposed to do, but what you need to know is,

since assignment of matrix multiplication only supports certain types such as CV_32FC1, CV_32FC2, CV_64FC1, and CV_64FC2 as assertion failure shows, "img" and "d" must follow one of these types and also "img" and "d" have to be the same type.

I don't know properties of "33.jpg" yet, imread would set img as channel of 3 if "33.jpg" is color image. So, "img" divides into three matrices for each channel with 32F or 64F type. Then do multiplication.

Or, simply use convertTo() and reshape() to make correct types. For example,

img.convertTo(img, CV_64F);
d.convertTo(d, CV_64F);
img.reshape(1);
d.reshape(1);
e = img*d;

Update:

I missed several things. Here's full code.

Mat img = imread ("D:\\33.jpg");
Mat a,b,c,d,e;
a = getGaussianKernel(img.cols,300,CV_64F);
b = getGaussianKernel(img.rows,300,CV_64F);
double minVal;     
double maxVal;

c = img;    // assign img to c because d must be the same dimension to img
cv::minMaxLoc(c, &minVal, &maxVal);
d = c/maxVal;

img.convertTo(img, CV_64F);       // convert Depth for multiplication
d.convertTo(d, CV_64F);

Mat imgPlanes[3], dPlanes[3], res[3];
split(img, imgPlanes);                 // split 3 channels to 1 channel matrices
split(d, dPlanes);

res[0] = imgPlanes[0]*dPlanes[0];   // I guess this is what you supposed to multiply
res[1] = imgPlanes[1]*dPlanes[1];
res[2] = imgPlanes[2]*dPlanes[2];

merge(res, 3, img);            // combine single channels to one multi-channel

return 0;

Also, I would like to mention that reshape() makes channels to columns. For instance, if 300 (row) x 300 (col) x 3 (ch) reshapes to 1 channel matrix, it will be changed to 300 (row) x 900 (col) x 1 (ch).

2014-03-05 07:51:46 -0600 received badge  Necromancer (source)
2014-03-05 04:26:08 -0600 commented answer missing cv::Mat::zeros(int ndims, const int* sz, int type)

Its good trick! Thank you.

2014-03-04 20:16:58 -0600 answered a question missing cv::Mat::zeros(int ndims, const int* sz, int type)

You could refer to Missing Mat::zeros(int ndims, const int* sz, int type) which is exactly the same problem asked and added Mat::zeros() missing function. However, both opencv 2.4 and 2.4.8.2-pre are still not found this function. The strange thing is that opencv master branch in github of which I guess for opencv 3.0 has Mat::zeros(int ndims, const int* sz, int type) implementation, here. Does anybody know about why 2.4.x removed this?

Thank you in advance.

2014-02-10 01:03:47 -0600 received badge  Editor (source)
2014-02-10 01:03:19 -0600 asked a question Duplicated declaration in ts.hpp

Hi all. I found a sort of duplicated declaration while I was digging opencv test code. I use Windows7 + cmake + vs2012 with opencv 2.4.7. In ts.hpp,

// ts.hpp
// ...
namespace cvtest {
// ...
class CV_EXPORTS TS;                   // declare
// ...
class BaseTest;                        // declare
class TS;                              // duplicated declare (?)
// ...
class CV_EXPORTS TS { /* ... */ }                // definition
class CV_EXPORTS BaseTest { /* ... */ }          // definition
// ...
}
// ...

So, I deleted "class BaseTest;" and "class TS;" lines then compiled. Everything was going well. Are there other reasons for remaining these?