The stereoCalibZed.yaml file is for zed camera only. It is added to test dfs-opencv using zed camera.
You should change the file if you try to use other camera.
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(dfs-adaptation)
BuildRequires: pkgconfig(opencv)
+BuildRequires: pkgconfig(libtzplatform-config)
%description
OpenCV based Dept-from-Stereo implementation
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
%endif
+export CXXFLAGS+=" -DDFS_CALIB_FILE_PATH=\\\"%{TZ_SYS_RO_SHARE}/%{name}/\\\""
+
%cmake .
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_datadir}/%{name}
+cp res/*.yaml %{buildroot}%{_datadir}/%{name}/
%make_install
%license LICENSE.APLv2
%defattr(-,root,root,-)
%{_libdir}/*.so
+%{_datadir}/%{name}/*.yaml
--- /dev/null
+%YAML:1.0
+LEFT_CAM_VGA: !!opencv-matrix
+ rows: 3
+ cols: 3
+ dt: d
+ data: [ 263.7425, 0., 333.64, 0., 263.5325, 184.129, 0., 0., 1. ]
+LEFT_CAM_DISTCOEFFS: !!opencv-matrix
+ rows: 5
+ cols: 1
+ dt: d
+ data: [ -0.0397725, 0.00826312, -0.00435501, -0.000558719, 0.000138723 ]
+RIGHT_CAM_VGA: !!opencv-matrix
+ rows: 3
+ cols: 3
+ dt: d
+ data: [ 264.02, 0., 335.0625, 0., 263.8875, 182.037, 0., 0., 1. ]
+RIGHT_CAM_DISTCOEFFS: !!opencv-matrix
+ rows: 5
+ cols: 1
+ dt: d
+ data: [ -0.0416412, 0.00967152, -0.00473998, 0.000477674, 0.00033336 ]
+STEREO_TRANSLATION: !!opencv-matrix
+ rows: 3
+ cols: 1
+ dt: d
+ data: [ 119.814, -0.0286845, 0.0224355 ]
+STEREO_ROTATION: !!opencv-matrix
+ rows: 3
+ cols: 1
+ dt: d
+ data: [ 0.0017263, 0.00115139, -0.000467542 ]
\ No newline at end of file
#include "dfs_opencv_private.h"
#include <dlog.h>
+#include <opencv2/core/persistence.hpp>
+
+#define DEFAULT_STEREO_CALIB_FILE_NAME "stereoCalibZed.yaml"
namespace DfsAdaptationImpl
{
mP2(96*3),
mPreFilterCap(63),
mDispMat(),
- mDepthData()
+ mDepthData(),
+ mCalibFilePath(DFS_CALIB_FILE_PATH),
+ mStereoParam(),
+ mIsStereoCalibrated(false),
+ mUpdateStereoCalibration(false)
{
LOGI("ENTER");
+ mCalibFilePath += std::string(DEFAULT_STEREO_CALIB_FILE_NAME);
LOGI("LEAVE");
}
LOGI("LEAVE");
}
+ void DfsOCV::InitializeStereoCalibration()
+ {
+ LOGI("ENTER");
+
+ cv::Mat intrinsicTest;
+ try {
+ cv::FileStorage fs(mCalibFilePath, cv::FileStorage::READ);
+ if (!fs.isOpened()) {
+ LOGE("Failed to open calib file %s", mCalibFilePath.c_str());
+ throw std::ios_base::failure("calibration");
+ }
+
+ fs["LEFT_CAM_VGA"] >> mStereoParam.baceCamera.intrinsic;
+ fs["LEFT_CAM_DISTCOEFFS"] >> mStereoParam.baceCamera.distCoeffs;
+
+ fs["RIGHT_CAM_VGA"] >> mStereoParam.extraCamera.intrinsic;
+ fs["RIGHT_CAM_DISTCOEFFS"] >> mStereoParam.extraCamera.distCoeffs;
+
+ fs["STEREO_TRANSLATION"] >> mStereoParam.translation;
+ fs["STEREO_ROTATION"] >> mStereoParam.rotation;
+
+ mIsStereoCalibrated = true;
+
+ } catch (const std::exception& e) {
+ LOGE("Failed to read calibration data %s", e.what());
+ throw std::ios_base::failure("calibration");
+ }
+
+ LOGI("LEAVE");
+ }
+
void DfsOCV::Initialize(DfsParameter& param)
{
LOGI("ENTER");
mDfsOcv = cv::StereoSGBM::create(1, mNumDisparities, mBlockSize);
this->SetParameters();
+
+ try {
+ this->InitializeStereoCalibration();
+ } catch (const std::exception& e) {
+ throw e;
+ }
+
LOGI("LEAVE");
}
namespace DfsAdaptationImpl
{
+ typedef struct _CameraParam {
+ cv::Mat intrinsic;
+ cv::Mat distCoeffs;
+
+ _CameraParam()
+ {
+ intrinsic = cv::Mat(cv::Size(3,3), CV_32FC1);
+ distCoeffs = cv::Mat(cv::Size(1,5), CV_32FC1);
+ }
+ } CameraParam;
+
+ typedef struct _StereoParam {
+ CameraParam baceCamera;
+ CameraParam extraCamera;
+
+ cv::Mat translation;
+ cv::Mat rotation;
+
+ _StereoParam()
+ {
+ translation = cv::Mat(cv::Size(1,3), CV_32FC1);
+ rotation = cv::Mat(cv::Size(1,3), CV_32FC1);
+ }
+ } StereoParam;
+
class DfsOCV : public IDfsAdaptation
{
private:
cv::Mat mDispMat;
DfsData mDepthData;
+ std::string mCalibFilePath;
+ StereoParam mStereoParam;
+ bool mIsStereoCalibrated;
+ bool mUpdateStereoCalibration;
+
void SetParameters();
int ConvertDfsDataTypeToCV(int type);
+ void InitializeStereoCalibration();
public:
DfsOCV();
~DfsOCV();