Skip to content

Commit

Permalink
wechat: fix uninitialized values in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin committed Mar 20, 2024
1 parent bf95e79 commit 270d2aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,6 @@ bool FinderPatternFinder::handlePossibleCenter(int* stateCount, size_t i, size_t
}
float estimatedHorizontalModuleSize = (float)stateCountTotal / 7.0f;

float estimatedVerticalModuleSize;

// try different size according to the estimatedHorizontalModuleSize
float tolerateModuleSize =
estimatedHorizontalModuleSize > 4.0 ? estimatedHorizontalModuleSize / 2.0f : 1.0f;
Expand All @@ -1082,7 +1080,9 @@ bool FinderPatternFinder::handlePossibleCenter(int* stateCount, size_t i, size_t
int image_width = image_->getWidth();
for (int k = 0; k < CENTER_CHECK_TIME; k++) {
float possibleCenterJ = possbileCenterJs[k];
if (possibleCenterJ < 0 || possibleCenterJ >= image_width) continue;
if (possibleCenterJ < 0 || possibleCenterJ >= image_width)
continue;
float estimatedVerticalModuleSize = 0;
float centerI = crossCheckVertical(i, (size_t)possibleCenterJ, stateCount[2],
stateCountTotal, estimatedVerticalModuleSize);

Expand Down Expand Up @@ -1505,4 +1505,4 @@ Ref<BitMatrix> FinderPatternFinder::getImage() { return image_; }
vector<Ref<FinderPattern>>& FinderPatternFinder::getPossibleCenters() { return possibleCenters_; }

} // namespace qrcode
} // namespace zxing
} // namespace zxing
6 changes: 3 additions & 3 deletions modules/wechat_qrcode/test/test_qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ TEST(Objdetect_QRCode_points_position, rotate45) {
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat image(800, 800, CV_8UC1);
Mat image(800, 800, CV_8UC1, Scalar(0));
const int pixInBlob = 4;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Rect2f rec(static_cast<float>((image.cols - qrSize.width)/2),
Expand Down Expand Up @@ -364,7 +364,7 @@ TEST(Objdetect_QRCode_Big, regression) {
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat largeImage(4032, 3024, CV_8UC1);
Mat largeImage(4032, 3024, CV_8UC1, Scalar(0));
const int pixInBlob = 4;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Mat roiImage = largeImage(Rect((largeImage.cols - qrSize.width)/2, (largeImage.rows - qrSize.height)/2,
Expand Down Expand Up @@ -395,7 +395,7 @@ TEST(Objdetect_QRCode_Tiny, regression) {
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat tinyImage(80, 80, CV_8UC1);
Mat tinyImage(80, 80, CV_8UC1, Scalar(0));
const int pixInBlob = 2;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Mat roiImage = tinyImage(Rect((tinyImage.cols - qrSize.width)/2, (tinyImage.rows - qrSize.height)/2,
Expand Down

0 comments on commit 270d2aa

Please sign in to comment.