【发布时间】:2019-01-31 22:54:36
【问题描述】:
【问题讨论】:
标签: opencv perspective stretch
【问题讨论】:
标签: opencv perspective stretch
我找到了一种使用remap 函数并使用指数函数重新映射每个像素的方法:
cv::Mat mapX, mapY;
mapX.create(m_nRemapHeight, m_nRemapWidth, CV_32FC1);
mapY.create(m_nRemapHeight, m_nRemapWidth, CV_32FC1);
for (int j = 0; j < m_nRemapHeight; j++)
{
for (int i = 0; i < m_nRemapWidth; i++)
{
mapX.at<float>(j, i) = (float)i;
float t = (m_nRemapHeight * 0.5f);
float r = j + t;
float fVal = ((r*r) / (m_nRemapHeight + t * 2));
fVal -= ((t*t) / (m_nRemapHeight + t * 2));
mapY.at<float>(j, i) = fVal;
}
}
cv::remap(srcMat, dstMat, matX, matY, CV_INTER_LINEAR, 0);
【讨论】: