diff --git a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp
index 89c78b12beb84c12508fd7e41bc3eea9365cdaa7..bd9f02537a4d135d1c2d45bcbed8be2abf914042 100644
--- a/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp
+++ b/components/rgbd-sources/src/algorithms/fixstars_sgm.cpp
@@ -25,11 +25,11 @@ void FixstarsSGM::compute(const cv::cuda::GpuMat &l, const cv::cuda::GpuMat &r,
 	cv::cuda::cvtColor(r, rbw, cv::COLOR_BGR2GRAY);
 
 	if (disp.type() != CV_16SC1 || disp.rows != l.rows || disp.cols != l.cols) {
-		disp = GpuMat(l.rows, l.cols, CV_16SC1, cv::Scalar(0));
+		disp = GpuMat(l.rows, l.cols, CV_16SC1);
 	}
 
 	if (!ssgm_) { // todo: move to constructor
-		ssgm_ = new sgm::StereoSGM(l.cols, l.rows, max_disp_, 8, 16, l.step, disp.step,
+		ssgm_ = new sgm::StereoSGM(l.cols, l.rows, max_disp_, 8, 16, lbw.step, disp.step / sizeof(short),
 			sgm::EXECUTE_INOUT_HOST2HOST, sgm::StereoSGM::Parameters(10,120,0.95f,true));
 	}
 
diff --git a/components/rgbd-sources/src/calibrate.cpp b/components/rgbd-sources/src/calibrate.cpp
index f9d0f253297e444518d9a58598c74eda60e94476..51767128eca13de622e4113ff8c53390cd9ef9fa 100644
--- a/components/rgbd-sources/src/calibrate.cpp
+++ b/components/rgbd-sources/src/calibrate.cpp
@@ -116,8 +116,15 @@ bool Calibrate::_loadCalibration(cv::Size img_size, std::pair<Mat, Mat> &map1, s
 }
 
 void Calibrate::rectifyStereo(GpuMat &l, GpuMat &r, Stream &stream) {
-	cv::cuda::remap(l, l, map1_gpu_.first, map2_gpu_.first, INTER_LINEAR);
-	cv::cuda::remap(r, r, map1_gpu_.second, map2_gpu_.second, INTER_LINEAR);
+	// cv::cuda::remap() can not use same Mat for input and output
+	
+	GpuMat l_tmp(l.size(), l.type());
+	GpuMat r_tmp(r.size(), r.type());
+	cv::cuda::remap(l, l_tmp, map1_gpu_.first, map2_gpu_.first, cv::INTER_LINEAR, 0, cv::Scalar(), stream);
+	cv::cuda::remap(r, r_tmp, map1_gpu_.second, map2_gpu_.second, cv::INTER_LINEAR, 0, cv::Scalar(), stream);
+	stream.waitForCompletion();
+	l = l_tmp;
+	r = r_tmp;
 }
 
 bool Calibrate::isCalibrated() {