MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / DimKeep

Function DimKeep

jni/stasm/misc.cpp:278–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276// The returned matrix may or may not use the same buffer as mat.
277
278MAT DimKeep(const MAT& mat, int nrows, int ncols)
279{
280 if (mat.rows == nrows && mat.cols == ncols) // no change needed?
281 return mat;
282 if (mat.rows * mat.cols == nrows * ncols) // same number of elements?
283 {
284 CV_Assert(mat.isContinuous());
285 MAT newmat(mat);
286 newmat.rows = nrows;
287 newmat.cols = ncols;
288 newmat.step = ncols * sizeof(newmat(0));
289 return newmat;
290 }
291 // copy as much of the data as will fit in the new matrix
292 MAT newmat(nrows, ncols, 0.);
293 int minrows = MIN(nrows, mat.rows);
294 for (int i = 0; i < minrows; i++)
295 {
296 const double* const rowbuf = mat.ptr<double>(i);
297 double* const rowbuf1 = newmat.ptr<double>(i);
298 for (int j = 0; j < ncols; j++)
299 rowbuf1[j] = rowbuf[j];
300 }
301 return newmat;
302}
303
304const MAT ArrayAsMat( // create a MAT from a C array of doubles
305 int nrows, // in

Callers 5

ConformShapeToModFunction · 0.85
ShapeModMethod · 0.85
Shape77As22Function · 0.85
Shape77As76Function · 0.85
ConvertShapeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected