C++中opencv 代码问题

qzxqzy 2016-01-21 12:10:15
 创建矫正模型
GenerationTemplate(pImgSrc);
int centerx = pImgSrc->height/2;
int centery = pImgSrc->width/2;
int radius = 130;
CreateDstmap(m_visualTemplate, centerx, centery, radius, pImgSrc->height,pImgSrc->width,videoHeight,videoWidth);

void FFMpegVideoPlayer::GenerationTemplate(IplImage *pImg)
{
m_visualTemplate = new int[pImg->height*pImg->width];
}

void FFMpegVideoPlayer::CreateDstmap(int *dstMap, int centerx, int centery, int radis, int srcHeigth, int srcWidth, int dstHeigth, int dstWidth)
{



//%为畸变创建一维的查询索引映射数组
//%Input:
//%centerx: 中心点行坐标
//%centery: 中心点列坐标
//%radis : 内园半径
//%srcHeigth:源图像高度
//%srcWidth: 源图像宽度
//%dstHeigth:目标图像高度
//%dstWidth: 目标图像宽度
//%确定外圆半径



int a1,a2,outRadis;
if(centerx < srcHeigth/2)
a1 = centerx;
else
a1 = srcHeigth - centerx;

if(centery < srcWidth/2)
a2 = centery;
else
a2 = srcWidth - centery;

if (a1 < a2)
outRadis = a1;
else
outRadis = a2;

float thea,tempx,xup,yup,xdown,ydown;
int temp1,temp2,indexup,indexdown;
int dstHeiHalf = dstHeigth/2;
for (int ii = 0;ii<dstWidth;ii++)
{
thea = 180.0f/dstWidth*ii;
thea = thea*PI/180;

for(int aa= 0; aa < dstHeiHalf; aa++)
{
tempx = radis + (outRadis-radis)*(aa+1)/dstHeiHalf;
xup = centerx - tempx*sin(thea);
yup = centery - tempx*cos(thea);
xdown = centerx + tempx*sin(thea);
ydown = centery - tempx*cos(thea);
temp1 = int(xup+0.5);
temp2 = int(yup+0.5);
//indexup = temp2*srcHeigth+ temp1;
indexup = temp2+ temp1*srcWidth;
dstMap[ii+(dstHeiHalf-aa-1)*dstWidth] = indexup;

temp1 = int(xdown+0.5);
temp2 = int(ydown+0.5);
// indexdown = temp2*srcHeigth+ temp1 + dstHeiHalf;
indexdown = temp2 + temp1*srcWidth;
dstMap[ii+(dstHeigth-aa-1)*dstWidth] = indexdown;
} //end aa
}//end ii
}

图像展开
Undist(pImgSrc, pImgDst);

int FFMpegVideoPlayer::Undist(IplImage *img, IplImage *dst)
{
if ( m_visualTemplate == NULL || img == NULL || dst == NULL )
{
return -1;
}

for ( int i = 0; i < videoHeight*videoWidth; ++i )
{
*(dst->imageData+i*3+0) = *(img->imageData+m_visualTemplate[i]*3+0);
*(dst->imageData+i*3+1) = *(img->imageData+m_visualTemplate[i]*3+1);
*(dst->imageData+i*3+2) = *(img->imageData+m_visualTemplate[i]*3+2);
}
return 0;
}

有没有大神能帮我把这段代码编写成java代码,编写一部分也可以,非常感激!
...全文
120 回复 打赏 收藏 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧