// stage 4. store the first min(total,linesMax) lines to the output buffer linesMax = std::min(linesMax, (int)_sort_buf.size()); double scale = 1./(numrho+2);
lines.create(linesMax, 1, type); Mat _lines = lines.getMat(); for( i = 0; i < linesMax; i++ ) { LinePolar line; int idx = _sort_buf[i]; int n = cvFloor(idx*scale) - 1; int r = idx - (n+1)*(numrho+2) - 1; line.rho = (r - (numrho - 1)*0.5f) * rho; line.angle = static_cast<float>(min_theta) + n * theta; if (type == CV_32FC2) { _lines.at<Vec2f>(i) = Vec2f(line.rho, line.angle); } else { CV_DbgAssert(type == CV_32FC3); _lines.at<Vec3f>(i) = Vec3f(line.rho, line.angle, (float)accum[idx]); } }