use of org.bytedeco.javacpp.indexer.DoubleRawIndexer in project BoofCV by lessthanoptimal.
the class UtilOpenCV method toMat.
public static Mat toMat(DMatrixRMaj in) {
Mat out = new Mat(in.numRows, in.numCols, CV_64F);
DoubleRawIndexer indexer = out.createIndexer();
for (int i = 0; i < in.numRows; i++) {
for (int j = 0; j < in.numCols; j++) {
indexer.put(i, j, in.get(i, j));
}
}
return out;
}
use of org.bytedeco.javacpp.indexer.DoubleRawIndexer in project BoofCV by lessthanoptimal.
the class UtilOpenCV method loadPinholeRadial.
/**
* Loads a pinhole camera model with radian and tangential distortion in OpenCV format
*
* @param fileName path to file
* @return CameraPinholeRadial
*/
public static CameraPinholeRadial loadPinholeRadial(String fileName) {
FileStorage fs = new FileStorage(new File(fileName).getAbsolutePath(), FileStorage.READ);
IntPointer width = new IntPointer(1);
IntPointer height = new IntPointer(1);
read(fs.get("image_width"), width, -1);
read(fs.get("image_height"), height, -1);
Mat K = new Mat();
read(fs.get("camera_matrix"), K);
Mat distortion = new Mat();
read(fs.get("distortion_coefficients"), distortion);
CameraPinholeRadial boof = new CameraPinholeRadial();
boof.width = width.get();
boof.height = height.get();
DoubleRawIndexer indexerK = K.createIndexer();
boof.fx = indexerK.get(0, 0);
boof.skew = indexerK.get(0, 1);
boof.fy = indexerK.get(1, 1);
boof.cx = indexerK.get(0, 2);
boof.cy = indexerK.get(1, 2);
DoubleRawIndexer indexerD = distortion.createIndexer();
if (distortion.rows() >= 5)
boof.setRadial(indexerD.get(0, 0), indexerD.get(1, 0), indexerD.get(4, 0));
else if (distortion.rows() >= 2)
boof.setRadial(indexerD.get(0, 0), indexerD.get(1, 0));
if (distortion.rows() >= 5)
boof.fsetTangental(indexerD.get(2, 0), indexerD.get(3, 0));
return boof;
}
Aggregations