c++ - cv::Mat , get value at row column without knowing the type of the matrix -



c++ - cv::Mat , get value at row column without knowing the type of the matrix -

so trying value of matrix, type not know, using row , column value. want implement following:

bool somefunction(cv::mat m){ homecoming m(1,0) != 0; }

i know error out since need specify type m.at< type >(1,0) not know type.

i tried doing following: m.at< m.type() >(1,0) that, of course, errors out.

i wondering potentially work here. thanks!

a not elegant solution. utilize depth , switch case.

#include<cv.h> #include<stdint.h> using namespace cv; using namespace std; bool somefunction(mat m) { switch (m.depth()){ case cv_8u: homecoming m.at<uint8_t>(1,0) != 0; case cv_8s: homecoming m.at<int>(1,0) != 0; case cv_16u: homecoming m.at<uint16_t>(1,0) != 0; case cv_16s: homecoming m.at<int16_t>(1,0) != 0; case cv_32s: homecoming m.at<int32_t>(1,0) != 0; case cv_32f: homecoming m.at<float>(1,0) != 0; case cv_64f: homecoming m.at<double>(1,0) != 0; } } int main() { mat m(2,2, cv_8uc1); cout << somefunction(m) << endl; }

c++ opencv matrix

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -