本文整理汇总了C++中vpMatrix::getRows方法的典型用法代码示例。如果您正苦于以下问题:C++ vpMatrix::getRows方法的具体用法?C++ vpMatrix::getRows怎么用?C++ vpMatrix::getRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vpMatrix
的用法示例。
在下文中一共展示了vpMatrix::getRows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/*!
\brief Initialisation of a sub matrix
\param m : parent matrix
\param row : row offset
\param col : col offset
\param nrows : number of rows of the sub matrix
\param ncols : number of columns of the sub matrix
*/
void vpSubMatrix::init(vpMatrix &m, const unsigned int & row, const unsigned int &col , const unsigned int & nrows , const unsigned int & ncols){
if(! m.data){
vpERROR_TRACE("\n\t\t SubMatrix parent matrix is not allocated") ;
throw(vpMatrixException(vpMatrixException::subMatrixError,
"\n\t\t SubMatrix parent matrix is not allocated")) ;
}
if(row+nrows <= m.getRows() && col+ncols <= m.getCols()){
data=m.data;
parent =&m;
rowNum = nrows;
colNum = ncols;
pRowNum=m.getRows();
pColNum=m.getCols();
if(rowPtrs)
free(rowPtrs);
rowPtrs=(double**) malloc(nrows * sizeof(double*));
for(unsigned int r=0;r<nrows;r++)
rowPtrs[r]= m.data+col+(r+row)*pColNum;
dsize = pRowNum*pColNum ;
trsize =0 ;
}else{
vpERROR_TRACE("Submatrix cannot be contain in parent matrix") ;
throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError,"Submatrix cannot be contain in parent matrix")) ;
}
}
示例2: throw
/*!
Constructor that creates a row vector from a 1-by-n matrix \e M.
\exception vpException::dimensionError If the matrix is not a 1-by-n matrix.
*/
vpRowVector::vpRowVector (const vpMatrix &M)
: vpArray2D<double>(1, M.getCols())
{
if(M.getRows()!=1) {
throw(vpException(vpException::dimensionError,
"Cannot construct a (1x%d) row vector from a (%dx%d) matrix",
M.getCols(), M.getRows(), M.getCols())) ;
}
for(unsigned int j=0; j< M.getCols(); j++)
(*this)[j] = M[0][j];
}
示例3: throw
/*!
Constructor that creates a column vector from a m-by-1 matrix \e M.
\exception vpException::dimensionError If the matrix is not a m-by-1 matrix.
*/
vpColVector::vpColVector (const vpMatrix &M)
: vpArray2D<double>(M.getRows(), 1)
{
if(M.getCols()!=1) {
throw(vpException(vpException::dimensionError,
"Cannot construct a (%dx1) row vector from a (%dx%d) matrix",
M.getRows(), M.getRows(), M.getCols())) ;
}
for(unsigned int i=0; i< M.getRows(); i++)
(*this)[i] = M[i][0];
}
示例4: throw
/*!
\brief set the value of the interaction matrix.
\param L_ : The matrix corresponding to the interaction matrix you computed.
\exception an exception is thrown if the number of row of the interaction
matrix is different from the dimension of the visual feature as specified
in the constructor
*/
void
vpGenericFeature::setInteractionMatrix(const vpMatrix &L_)
{
if (L_.getRows() != dim_s)
{
std::cout << L_.getRows() <<" " << dim_s << std::endl ;;
vpERROR_TRACE("size mismatch between interaction matrix size "
"and feature dimension");
throw(vpFeatureException(vpFeatureException::sizeMismatchError,
"size mismatch between interaction matrix size "
"and feature dimension"));
}
this->L = L_ ;
}
示例5:
/*!
Compute and return the interaction matrix \f$ L_I \f$. The computation is made
thanks to the values of the luminance features \f$ I \f$
*/
void
vpFeatureLuminance::interaction(vpMatrix &L)
{
double x,y,Ix,Iy,Zinv;
L.resize(dim_s,6) ;
for(int m = 0; m< L.getRows(); m++)
{
Ix = pixInfo[m].Ix;
Iy = pixInfo[m].Iy;
x = pixInfo[m].x ;
y = pixInfo[m].y ;
Zinv = 1 / pixInfo[m].Z;
{
L[m][0] = Ix * Zinv;
L[m][1] = Iy * Zinv;
L[m][2] = -(x*Ix+y*Iy)*Zinv;
L[m][3] = -Ix*x*y-(1+y*y)*Iy;
L[m][4] = (1+x*x)*Ix + Iy*x*y;
L[m][5] = Iy*x-Ix*y;
}
}
}
示例6: axis
/*!
Apply a filter to an image.
\param I : Image to filter
\param Iu : Filtered image along the horizontal axis (u = columns).
\param Iv : Filtered image along the vertical axis (v = rows).
\param M : Separate filter coefficients
*/
void
vpImageFilter::filter(const vpImage<double> &I,
vpImage<double>& Iu,
vpImage<double>& Iv,
const vpMatrix& M)
{
unsigned int size = M.getRows() ;
unsigned int half_size = size/2 ;
Iu.resize(I.getHeight(),I.getWidth()) ;
Iv.resize(I.getHeight(),I.getWidth()) ;
Iu = 0 ;
Iv = 0 ;
for (unsigned int v=half_size ; v < I.getHeight()-half_size ; v++)
{
for (unsigned int u=half_size ; u < I.getWidth()-half_size ; u++)
{
double conv_u = 0 ;
double conv_v = 0 ;
for(unsigned int a = 0 ; a < size ; a++ )
for(unsigned int b = 0 ; b < size ; b++ )
{
double val = I[v-half_size+a][u-half_size+b] ;
conv_u += M[a][b] * val ;
conv_v += M[b][a] * val ;
}
Iu[v][u] = conv_u ;
Iv[v][u] = conv_v ;
}
}
}
示例7:
/*!
Apply a filter to an image.
\param I : Image to filter
\param If : Filtered image.
\param M : Filter coefficients.
*/
void
vpImageFilter::filter(const vpImage<unsigned char> &I,
vpImage<double>& If,
const vpMatrix& M)
{
unsigned int size = M.getRows() ;
unsigned int half_size = size/2 ;
If.resize(I.getHeight(),I.getWidth()) ;
If = 0 ;
for (unsigned int i=half_size ; i < I.getHeight()-half_size ; i++)
{
for (unsigned int j=half_size ; j < I.getWidth()-half_size ; j++)
{
double conv_x = 0 ;
for(unsigned int a = 0 ; a < size ; a++ )
for(unsigned int b = 0 ; b < size ; b++ )
{
double val = I[i-half_size+a][j-half_size+b] ;
conv_x += M[a][b] * val ;
}
If[i][j] = conv_x ;
}
}
}
示例8: reshape
/*!
Reshape the column vector in a matrix.
\param M : the reshaped matrix.
\param nrows : number of rows of the matrix.
\param ncols : number of columns of the matrix.
*/
void vpColVector::reshape(vpMatrix & M,const unsigned int &nrows,const unsigned int &ncols){
if(dsize!=nrows*ncols) {
throw(vpException(vpException::dimensionError,
"Cannot reshape (%dx1) column vector in (%dx%d) matrix",
rowNum, M.getRows(), M.getCols())) ;
}
try {
if ((M.getRows() != nrows) || (M.getCols() != ncols)) M.resize(nrows,ncols);
}
catch(...) {
throw ;
}
for(unsigned int j =0; j< ncols; j++)
for(unsigned int i =0; i< nrows; i++)
M[i][j]=data[j*nrows+i];
}
示例9: singleLineYAML
// writes a matrix into a single line YAML format
string okExperiment::singleLineYAML(const vpMatrix &M)
{
stringstream ss;
unsigned int i,j;
ss << "[";
for(i=0;i<M.getRows();++i)
{
ss << "[";
for(j=0;j<M.getCols()-1;++j)
ss << M[i][j] << ", ";
ss << M[i][j] << "]";
if(i != M.getRows()-1)
ss << ",";
}
ss << "]";
return ss.str();
}
示例10: main
/*!
Operator that allows to multiply a velocity twist transformation matrix by a matrix.
As shown in the example below, this operator can be used to compute the corresponding
camera velocity skew from the joint velocities knowing the robot jacobian.
\code
#include <visp3/core/vpConfig.h>
#include <visp3/robot/vpSimulatorCamera.h>
#include <visp3/core/vpColVector.h>
#include <visp3/core/vpVelocityTwistMatrix.h>
int main()
{
vpSimulatorCamera robot;
vpColVector q_vel(6); // Joint velocity on the 6 joints
// ... q_vel need here to be initialized
vpColVector c_v(6); // Velocity in the camera frame: vx,vy,vz,wx,wy,wz
vpVelocityTwistMatrix cVe; // Velocity skew transformation from camera frame to end-effector
robot.get_cVe(cVe);
vpMatrix eJe; // Robot jacobian
robot.get_eJe(eJe);
// Compute the velocity in the camera frame
c_v = cVe * eJe * q_vel;
return 0;
}
\endcode
\exception vpException::dimensionError If M is not a 6 rows dimension matrix.
*/
vpMatrix
vpVelocityTwistMatrix::operator*(const vpMatrix &M) const
{
if (6 != M.getRows()) {
throw(vpException(vpException::dimensionError,
"Cannot multiply a (6x6) velocity twist matrix by a (%dx%d) matrix",
M.getRows(), M.getCols()));
}
vpMatrix p(6, M.getCols()) ;
for (unsigned int i=0;i<6;i++)
for (unsigned int j=0;j<M.getCols();j++)
{
double s =0 ;
for (unsigned int k=0;k<6;k++)
s += rowPtrs[i][k] * M[k][j];
p[i][j] = s ;
}
return p;
}
示例11: vpException
/*!
initialise the camera from a calibration matrix.
Using a calibration matrix leads to a camera without distorsion
The K matrix in parameters must be like:
\f$ K = \left(\begin{array}{ccc}
p_x & 0 & u_0 \\
0 & p_y & v_0 \\
0 & 0 & 1
\end{array} \right) \f$
\param _K : the 3by3 calibration matrix
*/
void
vpCameraParameters::initFromCalibrationMatrix(const vpMatrix& _K)
{
if(_K.getRows() != 3 || _K.getCols() != 3 ){
throw vpException(vpException::dimensionError, "bad size for calibration matrix");
}
if( std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()){
throw vpException(vpException::badValue, "bad value: K[2][2] must be equal to 1");
}
initPersProjWithoutDistortion (_K[0][0], _K[1][1], _K[0][2], _K[1][2]);
}
示例12: c
/*!
Multiply a row vector by a matrix.
\param M : Matrix.
\warning The number of elements of the row vector must be equal to the number
of rows of the matrix.
\exception vpException::dimensionError If the number of elements of the
row vector is not equal to the number of rows of the matrix.
\return The resulting row vector.
*/
vpRowVector vpRowVector::operator*(const vpMatrix &M) const
{
vpRowVector c(M.getCols());
if (colNum != M.getRows()) {
throw(vpException(vpException::dimensionError,
"Cannot multiply (1x%d) row vector by (%dx%d) matrix",
colNum, M.getRows(), M.getCols())) ;
}
c = 0.0;
for (unsigned int i=0;i<colNum;i++) {
double bi = data[i] ; // optimization em 5/12/2006
for (unsigned int j=0;j<M.getCols();j++) {
c[j]+=bi*M[i][j];
}
}
return c ;
}
示例13: test
bool test(const std::string &s, const vpMatrix &M, const std::vector<double> &bench)
{
static unsigned int cpt = 0;
std::cout << "** Test " << ++cpt << std::endl;
std::cout << s << "(" << M.getRows() << "," << M.getCols() << ") = \n" << M << std::endl;
if(bench.size() != M.size()) {
std::cout << "Test fails: bad size wrt bench" << std::endl;
return false;
}
for (unsigned int i=0; i<M.size(); i++) {
if (std::fabs(M.data[i]-bench[i]) > std::fabs(M.data[i])*std::numeric_limits<double>::epsilon()) {
std::cout << "Test fails: bad content" << std::endl;
return false;
}
}
return true;
}
示例14: p
/*!
Operator that allows to multiply a skew transformation matrix by a matrix.
\exception vpMatrixException::incorrectMatrixSizeError If M is not a 6 rows
dimension matrix.
*/
vpMatrix
vpForceTwistMatrix::operator*(const vpMatrix &M) const
{
if (6 != M.getRows())
{
vpERROR_TRACE("vpForceTwistMatrix mismatch in vpForceTwistMatrix/vpMatrix multiply") ;
throw(vpMatrixException::incorrectMatrixSizeError) ;
}
vpMatrix p(6, M.getCols()) ;
for (unsigned int i=0;i<6;i++) {
for (unsigned int j=0;j<M.getCols();j++) {
double s =0 ;
for (unsigned int k=0;k<6;k++)
s += rowPtrs[i][k] * M[k][j];
p[i][j] = s ;
}
}
return p;
}
示例15: reshape
/*!
\brief reshape the colvector in a matrix
\param m : the reshaped Matrix
\param nrows : number of rows of the matrix
\param ncols : number of columns of the matrix
*/
void vpColVector::reshape(vpMatrix & m,const unsigned int &nrows,const unsigned int &ncols){
if(dsize!=nrows*ncols)
{
vpERROR_TRACE("\n\t\t vpColVector mismatch size for reshape vpSubColVector in a vpMatrix") ;
throw(vpMatrixException(vpMatrixException::incorrectMatrixSizeError,
"\n\t\t \n\t\t vpColVector mismatch size for reshape vpSubColVector in a vpMatrix")) ;
}
try
{
if ((m.getRows() != nrows) || (m.getCols() != ncols)) m.resize(nrows,ncols);
}
catch(vpException me)
{
vpERROR_TRACE("Error caught") ;
std::cout << me << std::endl ;
throw ;
}
for(unsigned int j =0; j< ncols; j++)
for(unsigned int i =0; i< nrows; i++)
m[i][j]=data[j*ncols+i];
}