mirror of
https://github.com/opencv/opencv.git
synced 2024-12-25 18:18:04 +08:00
32 lines
568 B
C++
32 lines
568 B
C++
#include <fstream>
|
|
#include "camera.hpp"
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
|
|
CameraInfo CameraInfo::load(const string &path)
|
|
{
|
|
FileStorage fs(path, FileStorage::READ);
|
|
CV_Assert(fs.isOpened());
|
|
|
|
CameraInfo cam;
|
|
if (!fs["R"].isNone())
|
|
fs["R"] >> cam.R;
|
|
if (!fs["K"].isNone())
|
|
fs["K"] >> cam.K;
|
|
return cam;
|
|
}
|
|
|
|
|
|
void CameraInfo::save(const string &path)
|
|
{
|
|
FileStorage fs(path, FileStorage::WRITE);
|
|
CV_Assert(fs.isOpened());
|
|
|
|
if (!R.empty())
|
|
fs << "R" << R;
|
|
if (!K.empty())
|
|
fs << "K" << K;
|
|
}
|