@@ -67,23 +67,23 @@ auto StereoMatchingPipeline::Initialize(Resolution resolution) noexcept -> Statu
6767 switch (resolution)
6868 {
6969 case Resolution::SMALL :
70- imageHeight_ = 320 ;
71- imageWidth_ = 640 ;
70+ matchingHeight_ = 320 ;
71+ matchingWidth_ = 640 ;
7272 break ;
7373 case Resolution::MEDIUM :
74- imageHeight_ = 480 ;
75- imageWidth_ = 640 ;
74+ matchingHeight_ = 480 ;
75+ matchingWidth_ = 640 ;
7676 break ;
7777 case Resolution::LARGE :
78- imageHeight_ = 720 ;
79- imageWidth_ = 1280 ;
78+ matchingHeight_ = 720 ;
79+ matchingWidth_ = 1280 ;
8080 break ;
8181 default :
8282 LogError (" Invalid resolution specified for LRConsistencyPipeline." );
8383 return Status{StatusCategory::USER , StatusCode::INVALID_ARGUMENT };
8484 }
8585
86- auto status = pipeline_.Initialize (imageHeight_, imageWidth_ );
86+ auto status = pipeline_.Initialize (matchingHeight_, matchingWidth_ );
8787 return status;
8888}
8989
@@ -145,8 +145,8 @@ auto StereoMatchingPipeline::RunImpl(const cv::Mat &leftImage, const cv::Mat &ri
145145 rightGray = rightImage.clone ();
146146 }
147147
148- cv::resize (leftGray, leftGray, cv::Size (imageWidth_, imageHeight_ ));
149- cv::resize (rightGray, rightGray, cv::Size (imageWidth_, imageHeight_ ));
148+ cv::resize (leftGray, leftGray, cv::Size (matchingWidth_, matchingHeight_ ));
149+ cv::resize (rightGray, rightGray, cv::Size (matchingWidth_, matchingHeight_ ));
150150 leftGray.convertTo (leftGray, CV_32FC1 );
151151 rightGray.convertTo (rightGray, CV_32FC1 );
152152 cv::Mat leftDisparity = cv::Mat::zeros (leftGray.size (), CV_32FC1 );
@@ -160,6 +160,9 @@ auto StereoMatchingPipeline::RunImpl(const cv::Mat &leftImage, const cv::Mat &ri
160160 // If maxDisparityDifference is greater than 0, perform left-right consistency check
161161 if (maxDisparityDifference > 0 .0F )
162162 {
163+ // Scale maxDisparityDifference to fit the processing size
164+ float tmpMaxDisparityDifference = maxDisparityDifference * (static_cast <float >(matchingWidth_) / static_cast <float >(leftImage.cols ));
165+
163166 cv::Mat leftGrayFlipped;
164167 cv::Mat rightGrayFlipped;
165168
@@ -176,7 +179,7 @@ auto StereoMatchingPipeline::RunImpl(const cv::Mat &leftImage, const cv::Mat &ri
176179 cv::flip (rightDisparity, rightDisparity, 1 );
177180
178181 cv::Mat lrCheckedDisparity = cv::Mat::zeros (leftDisparity.size (), CV_32FC1 );
179- if (!LRConsistencyCheck (leftDisparity, rightDisparity, lrCheckedDisparity, maxDisparityDifference ))
182+ if (!LRConsistencyCheck (leftDisparity, rightDisparity, lrCheckedDisparity, tmpMaxDisparityDifference ))
180183 {
181184 return Status{StatusCategory::RETINIFY , StatusCode::FAIL };
182185 }
@@ -190,7 +193,7 @@ auto StereoMatchingPipeline::RunImpl(const cv::Mat &leftImage, const cv::Mat &ri
190193
191194 // resize disparity to original image size
192195 cv::resize (disparity, disparity, leftImage.size (), 0 , 0 , cv::INTER_NEAREST );
193- disparity = disparity * (static_cast <float >(leftImage.cols ) / static_cast <float >(imageWidth_ ));
196+ disparity = disparity * (static_cast <float >(leftImage.cols ) / static_cast <float >(matchingWidth_ ));
194197 }
195198 catch (const std::exception &e)
196199 {
0 commit comments