diff --git a/QRCode-OpenCV/CMakeLists.txt b/QRCode-OpenCV/CMakeLists.txt index e926a8fb7..1cb427ce2 100644 --- a/QRCode-OpenCV/CMakeLists.txt +++ b/QRCode-OpenCV/CMakeLists.txt @@ -5,7 +5,7 @@ PROJECT(opencv_tests) if(NOT OpenCV_DIR) set(OpenCV_DIR installations/OpenCV4/lib/cmake/opencv4/) endif() -find_package( OpenCV REQUIRED ) +find_package(OpenCV REQUIRED core highgui objdetect) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) diff --git a/QRCode-OpenCV/qrCodeOpencv.cpp b/QRCode-OpenCV/qrCodeOpencv.cpp index 64036ccc3..8bed223de 100644 --- a/QRCode-OpenCV/qrCodeOpencv.cpp +++ b/QRCode-OpenCV/qrCodeOpencv.cpp @@ -1,4 +1,3 @@ -// #include #include #include #include @@ -10,10 +9,20 @@ using namespace std; void display(Mat &im, Mat &bbox) { - int n = bbox.rows; - for(int i = 0 ; i < n ; i++) - { - line(im, Point2i(bbox.at(i,0),bbox.at(i,1)), Point2i(bbox.at((i+1) % n,0), bbox.at((i+1) % n,1)), Scalar(255,0,0), 3); + int index = 0; + int max_index = (bbox.cols*2); + for(int l = 0 ; l < bbox.cols; l++) { + line( + im, + Point( + bbox.at(0, index), + bbox.at(0, index+1)), + Point( + bbox.at(0, (index+2) % max_index), + bbox.at(0, (index+3) % max_index)), + Scalar(0,255,0), + 2); + index+=2; } imshow("Result", im); }