c++ - conversion between Mat and Mat1b/Mat3b -


i want match code given interface. inside class operateimage in methods use cv::mat format. when putting in submain function uses cv::mat3b , returns cv::mat1b not work. how can change can use written class? sure there must exist simple conversion did not find, beginning in opencv. thank in advance help. grateful if can shortly point out when makes sense use mat1b/mat3b instead of mat, role? (i saw examples using mat.)

cv::mat1b submain(const cv::mat3b& img) {     operateimage opimg(img);     opimg.trafo(img); // being used reference in methods     return img; } 

mat1b , mat3b 2 pre-defined cases of mat types, defined in core.hpp follows:

typedef mat_<uchar> mat1b; ... typedef mat_<vec3b> mat3b; 

that said, conversion between mat , mat1b/mat3b should quite natural/automatic:

mat1b mat1b; mat3b mat3b; mat mat;  mat = mat1b; mat = mat3b; mat1b = mat; mat3b = mat; 

back case, problem should not attributed conversions, way define submain() , how use it. input parameter of submain() const cv::mat3b &, however, you're trying modify header change mat1b inside function.

it fine if change to, e.g.:

cv::mat1b submain(const cv::mat3b& img) {     cv::mat tmp = img.clone();      operateimage opimg(tmp);     opimg.trafo(tmp);     return tmp; } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -