How to read / write xml file in Java
Has anyone written the calibration / distortion matrix from Java and have them read by a c++ code using xml?
Has anyone written the calibration / distortion matrix from Java and have them read by a c++ code using xml?
This example writes the calibration and distortion matrix in c++ to either xml or yml, demonstrating the file format. Here's a copy of the code in case the link breaks. Change the suffix to xml to see that format.
#include "opencv2/opencv.hpp"
#include <time.h>
using namespace cv;
int main(int, char** argv)
{
FileStorage fs("test.yml", FileStorage::WRITE);
fs << "frameCount" << 5;
time_t rawtime; time(&rawtime);
fs << "calibrationDate" << asctime(localtime(&rawtime));
Mat cameraMatrix = (Mat_<double>(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1);
Mat distCoeffs = (Mat_<double>(5,1) << 0.1, 0.01, -0.001, 0, 0);
fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs;
fs << "features" << "[";
for( int i = 0; i < 3; i++ )
{
int x = rand() % 640;
int y = rand() % 480;
uchar lbp = rand() % 256;
fs << "{:" << "x" << x << "y" << y << "lbp" << "[:";
for( int j = 0; j < 8; j++ )
fs << ((lbp >> j) & 1);
fs << "]" << "}";
}
fs << "]";
fs.release();
return 0;
}
Asked: 2015-08-02 07:11:03 -0600
Seen: 1,070 times
Last updated: Aug 15 '15
Resolution and camera calibration
Unresolved inclusion in OpenCV+Android tutorial
How to reduce false positives for face detection
How to convert Floating point image to 32-bit single-channel?
OpenCV DescriptorMatcher matches
Record/Store constant refreshing coordinates points into notepad
Conversion between IplImage and MxArray
How can solvePnPRansac be used with double values?
the FileStorage api is not available from java, so i guess, you better write a simple text file (it's just 9 numbers for the cam-matrix, and another 5 for the dist-coeffs)
OK, so what is the xml / yml format for cam/dist data? Did you down vote the question because you know the answer but think the question is trivial or not valid?