Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to use template <typename t=""> with different Mat.depth

I'm trying to get back same values from Mat object in different cv::Mat types I've wrote a function that works with CV_32F type my goal is writing a generic function that operates with the other types (CV_8U | CV_16U | CV_16S | CV_32S | CV_64F)

void MaxMin(cv::Mat& m){
    float max, min;
    for(int i=0;i<m.rows;i++){
        for(int j=0;j<m.cols;j++){
            if(max < m.at<float>(i,j)){
                max = m.at<float>(i,j);
            }
            if(min > m.at<float>(i,j)){
                min = m.at<float>(i,j);
            }
        }
    }
    std::cout<<"Max "<<max<<" Min "<<min<<std::endl;
}

how to use template <typename t=""> with different Mat.depth

I'm trying to get back same values from Mat object in different cv::Mat types I've wrote a function that works with CV_32F type my goal is writing a generic function that operates with the other types (CV_8U | CV_16U | CV_16S | CV_32S | CV_64F)

please no Simple IF Statements

void MaxMin(cv::Mat& m){
    float max, min;
    for(int i=0;i<m.rows;i++){
        for(int j=0;j<m.cols;j++){
            if(max < m.at<float>(i,j)){
                max = m.at<float>(i,j);
            }
            if(min > m.at<float>(i,j)){
                min = m.at<float>(i,j);
            }
        }
    }
    std::cout<<"Max "<<max<<" Min "<<min<<std::endl;
}