cvscanlines.cpp.svn-base
来自「非结构化路识别」· SVN-BASE 代码 · 共 2,039 行 · 第 1/4 页
SVN-BASE
2,039 行
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
} /* if */
} /* if */
r_point[0] = 0;
r_point[1] = (float) height;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
assert( error == CV_NO_ERR );
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = (float) height;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
l_point[0] = (float) width;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
} /* if */
} /* if */
return error;
} /* icvlGetStartEnd1 */
/*===========================================================================*/
CvStatus
icvGetStartEnd2( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
{
CvMatrix3 *F;
int width, height;
float l_diagonal[3];
float r_diagonal[3];
float l_point[3], r_point[3], epiline[3];
CvStatus error = CV_OK;
F = matrix;
width = imgSize.width - 1;
height = imgSize.height - 1;
l_diagonal[0] = (float) 1 / width;
l_diagonal[1] = (float) 1 / height;
l_diagonal[2] = -1;
r_diagonal[0] = (float) height / width;
r_diagonal[1] = -1;
r_diagonal[2] = 0;
r_point[0] = 0;
r_point[1] = 0;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
assert( error == CV_NO_ERR );
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = (float) height;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
l_point[0] = (float) width;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
} /* if */
} /* if */
r_point[0] = (float) width;
r_point[1] = (float) height;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
assert( error == CV_NO_ERR );
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = (float) height;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
l_point[0] = (float) width;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
} /* if */
return error;
} /* icvlGetStartEnd2 */
/*===========================================================================*/
CvStatus
icvGetStartEnd3( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
{
CvMatrix3 *F;
int width, height;
float l_diagonal[3];
float r_diagonal[3];
float l_point[3], r_point[3], epiline[3];
CvStatus error = CV_OK;
F = matrix;
width = imgSize.width - 1;
height = imgSize.height - 1;
l_diagonal[0] = (float) height / width;
l_diagonal[1] = -1;
l_diagonal[2] = 0;
r_diagonal[0] = (float) 1 / width;
r_diagonal[1] = (float) 1 / height;
r_diagonal[2] = -1;
r_point[0] = 0;
r_point[1] = 0;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
assert( error == CV_NO_ERR );
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = (float) height;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
l_point[0] = (float) width;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
} /* if */
} /* if */
r_point[0] = (float) width;
r_point[1] = (float) height;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
assert( error == CV_NO_ERR );
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = (float) height;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
l_point[0] = (float) width;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[2] = l_point[0];
l_start_end[3] = l_point[1];
r_start_end[2] = r_point[0];
r_start_end[3] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
} /* if */
} /* if */
return error;
} /* icvlGetStartEnd3 */
/*===========================================================================*/
CvStatus
icvGetStartEnd4( CvMatrix3 * matrix, CvSize imgSize, float *l_start_end, float *r_start_end )
{
CvMatrix3 *F;
int width, height;
float l_diagonal[3];
float r_diagonal[3];
float l_point[3], r_point[3], epiline[3];
CvStatus error;
F = matrix;
width = imgSize.width - 1;
height = imgSize.height - 1;
l_diagonal[0] = (float) height / width;
l_diagonal[1] = -1;
l_diagonal[2] = 0;
r_diagonal[0] = (float) height / width;
r_diagonal[1] = -1;
r_diagonal[2] = 0;
r_point[0] = 0;
r_point[1] = 0;
r_point[2] = 1;
icvMultMatrixVector3( F, r_point, epiline );
error = icvCrossLines( l_diagonal, epiline, l_point );
if( error != CV_NO_ERR )
return error;
if( l_point[0] >= 0 && l_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
{
if( l_point[0] < 0 )
{
l_point[0] = 0;
l_point[1] = 0;
l_point[2] = 1;
icvMultMatrixTVector3( F, l_point, epiline );
error = icvCrossLines( r_diagonal, epiline, r_point );
assert( error == CV_NO_ERR );
if( r_point[0] >= 0 && r_point[0] <= width )
{
l_start_end[0] = l_point[0];
l_start_end[1] = l_point[1];
r_start_end[0] = r_point[0];
r_start_end[1] = r_point[1];
}
else
return CV_BADFACTOR_ERR;
}
else
{ /* if( l_point[0] > width ) */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?