I'm using C++ and OpenCV. Now I want to define a certain Mat type (such as CV_32FC3) to be used by lots of Mats in my code.
To achieve this, I tried:
#define FLOW_TYPE CV_32FC3; cv::Mat BaoOpticalFlow::initialize(cv::Mat & frame1, cv::Mat & frame2) { cv::Mat flow = cv::Mat(frame1.rows, frame1.cols, FLOW_TYPE); } However, this causes errors
expected a ')'
expected an expression
Then I tried,
#define FLOW_TYPE CV_32FC3; cv::Mat BaoOpticalFlow::initialize(cv::Mat & frame1, cv::Mat & frame2) { int test = FLOW_TYPE; cv::Mat flow = cv::Mat(frame1.rows, frame1.cols, test); } Which works, but is ugly in my opinion.
I don't really understand why or how this works, and why the first snippet causes errors. I'm not a C++ expert, so any help is appreciated.