int sz[3] = {4, 4, 4}; cv::Mat (3, sz, CV_32FC3); cv::randu( m, -1.0f, 1.0f); // fill with random numbers from -1.0 to 1.0 float max = 0.0f; // minimum possible value of L2 norm cv::MatConstIterator<cv::Vec3f> it = m.begin(); while( it != m.end() ) { len2 = (*it)[0]*(*it)[0]+(*it)[1]*(*it)[1]+(*it)[2]*(*it)[2]; if( len2 > max ) max = len2; it++; }
int sz[3] = {4, 4, 4}; cv::Mat (3, sz, CV_32FC3); cv::randu( m, -1.0f, 1.0f); // fill with random numbers from -1.0 to 1.0 float max = 0.0f; // minimum possible value of L2 norm cv::MatConstIterator_<cv::Vec3f> it = m.begin<cv::Vec3f>(); while( it != m.end<cv::Vec3f>() ) { float len2 = (*it)[0]*(*it)[0]+(*it)[1]*(*it)[1]+(*it)[2]*(*it)[2]; if( len2 > max ) max = len2; it++; std::cout<<max<<std::endl; } return0; }
近期评论