|
@@ -125,8 +125,11 @@ string paperPreIdentify::readQrCode(PaperPage sPage)
|
|
|
Mat roiMat = tImg(Rect(0, 0, tImg.cols / 4, tImg.rows / 5));
|
|
|
Mat imgGray;
|
|
|
cvtColor(roiMat, imgGray, CV_BGR2GRAY); // 灰度化
|
|
|
+ erode(imgGray, imgGray, Mat()); //图片腐蚀,缩小高亮(白色)区域
|
|
|
+// imwrite("/storage/emulated/0/Pictures/AAA.jpg", imgGray);
|
|
|
+// //OpenCV自带的QRCode识别方法
|
|
|
// QRCodeDetector tDetector;
|
|
|
-// strRet = tDetector.detectAndDecode(roiMat);
|
|
|
+// string strRet1 = tDetector.detectAndDecode(imgGray);
|
|
|
m_nAnchorsToQrCode = 0;
|
|
|
strRet = ZbarDecoder(imgGray, m_nAnchorsToQrCode);
|
|
|
if (strRet.length() > 0)
|
|
@@ -135,7 +138,7 @@ string paperPreIdentify::readQrCode(PaperPage sPage)
|
|
|
{
|
|
|
roiMat = tImg(Rect(tImg.cols * 3 / 4, tImg.rows * 4 / 5, tImg.cols / 4, tImg.rows / 5));
|
|
|
cvtColor(roiMat, imgGray, CV_BGR2GRAY);
|
|
|
-// strRet = tDetector.detectAndDecode(roiMat);
|
|
|
+ erode(imgGray, imgGray, Mat()); //图片腐蚀,缩小高亮(白色)区域
|
|
|
//opencv容易出现识别出二维码但是decode返回空的问题,改用ZBar库识别二维码
|
|
|
strRet = ZbarDecoder(imgGray, m_nAnchorsToQrCode);
|
|
|
m_nAnchorsToQrCode += tImg.rows * 4 / 5;
|