use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTrifocalLinearPoint7 method createSystem.
DMatrixRMaj createSystem(List<AssociatedTriple> observations) {
int N = observations.size();
DMatrixRMaj A = new DMatrixRMaj(4 * N, 27);
for (int i = 0; i < N; i++) {
AssociatedTriple T = observations.get(i);
Point2D_F64 p1 = T.p1;
Point2D_F64 p2 = T.p2;
Point2D_F64 p3 = T.p3;
for (int k = 0; k < 3; k++) {
fillLine(A, i * 4, 0, 2, 0, 2, k, p1, p2, p3);
fillLine(A, i * 4 + 1, 0, 2, 1, 2, k, p1, p2, p3);
fillLine(A, i * 4 + 2, 1, 2, 0, 2, k, p1, p2, p3);
fillLine(A, i * 4 + 3, 1, 2, 1, 2, k, p1, p2, p3);
// not sure if this is the correct 9. need to think more
// fillLine(A,i*4 ,0,1,0,1,k,p1,p2,p3);
// fillLine(A,i*4+1,0,2,0,1,k,p1,p2,p3);
// fillLine(A,i*4+2,0,2,0,2,k,p1,p2,p3);
// fillLine(A,i*4+3,1,0,1,0,k,p1,p2,p3);
// fillLine(A,i*4+4,1,2,1,0,k,p1,p2,p3);
// fillLine(A,i*4+5,1,0,1,2,k,p1,p2,p3);
// fillLine(A,i*4+6,2,0,2,0,k,p1,p2,p3);
// fillLine(A,i*4+7,2,1,2,0,k,p1,p2,p3);
// fillLine(A,i*4+8,2,1,2,1,k,p1,p2,p3);
}
}
return A;
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class CalibrationIO method loadOpenCV.
/**
* Loads intrinsic parameters in OpenCV format.
*/
public static CameraPinholeBrown loadOpenCV(Reader reader) {
CameraPinholeBrown out = new CameraPinholeBrown();
try {
String filtered = IOUtils.toString(reader);
// It doesn't like the header or that class def
filtered = filtered.replace("%YAML:1.0", "");
filtered = filtered.replace("!!opencv-matrix", "");
Representer representer = new Representer();
representer.getPropertyUtils().setSkipMissingProperties(true);
Yaml yaml = new Yaml(new Constructor(), representer);
Map<String, Object> map = yaml.load(filtered);
int width = getOrThrow(map, "image_width");
int height = getOrThrow(map, "image_height");
DMatrixRMaj K = loadOpenCVMatrix(getOrThrow(map, "camera_matrix"));
DMatrixRMaj distortion = loadOpenCVMatrix(getOrThrow(map, "distortion_coefficients"));
PerspectiveOps.matrixToPinhole(K, width, height, out);
if (distortion.getNumElements() >= 5)
out.setRadial(distortion.get(0), distortion.get(1), distortion.get(4));
else if (distortion.getNumElements() >= 2)
out.setRadial(distortion.get(0), distortion.get(1));
if (distortion.getNumElements() >= 5)
out.fsetTangental(distortion.get(2), distortion.get(3));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return out;
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTrifocalTensor method convertTo.
@Test
void convertTo() {
TrifocalTensor t = new TrifocalTensor();
for (int i = 0; i < 27; i++) t.getT(i / 9).set(i % 9, i);
DMatrixRMaj A = new DMatrixRMaj(27, 1);
t.convertTo(A);
for (int i = 0; i < 27; i++) assertEquals(A.get(i), i);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestTrifocalTensor method convertFrom.
@Test
void convertFrom() {
DMatrixRMaj A = new DMatrixRMaj(27, 1);
for (int i = 0; i < 27; i++) A.set(i, i);
TrifocalTensor t = new TrifocalTensor();
t.convertFrom(A);
for (int i = 0; i < 27; i++) assertEquals(t.getT(i / 9).get(i % 9), i);
}
use of org.ejml.data.DMatrixRMaj in project BoofCV by lessthanoptimal.
the class TestQueueMatrix method constructor_regular.
@Test
void constructor_regular() {
QueueMatrix alg = new QueueMatrix(3, 4);
assertEquals(0, alg.size);
DMatrixRMaj M = alg.grow();
assertEquals(3, M.numRows);
assertEquals(4, M.numCols);
}
Aggregations