gpt4 book ai didi

java - opencv转javacv代码的方法

转载 作者:搜寻专家 更新时间:2023-10-31 01:53:17 24 4
gpt4 key购买 nike

<分区>

我无法将以下代码转换为 javacv:

((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] 这是什么翻译?对我来说它看起来像一个数组,但是 value 的类型是 float。

我不知道如何将值设置为 value

float Saliency::getMean(IplImage * srcArg, CvPoint PixArg, int neighbourhood,    int centerVal)
{
CvPoint P1, P2;
float value;

P1.x = PixArg.x - neighbourhood + 1;
P1.y = PixArg.y - neighbourhood + 1;
P2.x = PixArg.x + neighbourhood + 1;
P2.y = PixArg.y + neighbourhood + 1;

if(P1.x < 0)
P1.x = 0;
else if(P1.x > srcArg->width - 1)
P1.x = srcArg->width - 1;
if(P2.x < 0)
P2.x = 0;
else if(P2.x > srcArg->width - 1)
P2.x = srcArg->width - 1;
if(P1.y < 0)
P1.y = 0;
else if(P1.y > srcArg->height - 1)
P1.y = srcArg->height - 1;
if(P2.y < 0)
P2.y = 0;
else if(P2.y > srcArg->height - 1)
P2.y = srcArg->height - 1;

// we use the integral image to compute fast features
value = (float) (
((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P2.x] +
((int*)(srcArg->imageData + srcArg->widthStep*P1.y))[P1.x] -
((int*)(srcArg->imageData + srcArg->widthStep*P2.y))[P1.x] -
((int*)(srcArg->imageData + srcArg->widthStep*P1.y))[P2.x]
);

value = (value - centerVal)/ (( (P2.x - P1.x) * (P2.y - P1.y))-1) ;

return value;

我的翻译:

        private float getMean(IplImage srcArg, CvPoint PixArg, int neighbourhood, int centerVal)
{
CvPoint P1, P2;
float value;
P1.put( PixArg.x() - neighbourhood + 1, PixArg.y() - neighbourhood + 1);
P2.put( PixArg.x() + neighbourhood + 1, PixArg.y() + neighbourhood + 1);


if(P1.x() < 0)
P1.position(0).put(0);
else if(P1.x() > srcArg.width()- 1)
P1.position(0).put(srcArg.width()- 1);
if(P2.x() < 0)
P2.position(0).put(0);
else if(P2.x() > srcArg.width()- 1)
P2.position(0).put(srcArg.width()- 1);
if(P1.y() < 0)
P1.position(1).put(0);
else if(P1.y() > srcArg.height()- 1)
P1.position(1).put(srcArg.height()- 1);
if(P2.y() < 0)
P2.position(1).put(0);
else if(P2.y() > srcArg.height()- 1)
P2.position(1).put(srcArg.height()- 1);

// we use the integral image to compute fast features
value = (float) (
((int)(srcArg.imageData().get() + srcArg.widthStep()*P2.y()))[P2.x()] +
((int)(srcArg.imageData().get() + srcArg.widthStep()*P1.y()))[P1.x()] -
((int)(srcArg.imageData().get() + srcArg.widthStep()*P2.y()))[P1.x()] -
((int)(srcArg.imageData().get() + srcArg.widthStep()*P1.y()))[P2.x()] );
);
float[] bla= (srcArg.imageData().get()+srcArg.widthStep())[P2.x()];
value = (value - centerVal)/ (( (P2.x - P1.x) * (P2.y - P1.y))-1) ;

return value;
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com