mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #23264 from AleksandrPanov:add_detect_qr_with_aruco
Add detect qr with aruco #23264 Using Aruco to detect finder patterns to search QR codes. TODO (in next PR): - add single QR detect (update `detect()` and `detectAndDecode()`) - need reduce full enumeration of finder patterns - need add finder pattern info to `decode` step - need to merge the pipeline of the old and new algorithm [Current results:](https://docs.google.com/spreadsheets/d/1ufKyR-Zs-IGXwvqPgftssmTlceVjiQX364sbrjr2QU8/edit#gid=1192415584) +20% total detect, +8% total decode in OpenCV [QR benchmark](https://github.com/opencv/opencv_benchmarks/tree/develop/python_benchmarks/qr_codes)  78.4% detect, 58.7% decode vs 58.5 detect, 50.5% decode in default [main.py.txt](https://github.com/opencv/opencv/files/10762369/main.py.txt)  add new info to [google docs](https://docs.google.com/spreadsheets/d/1ufKyR-Zs-IGXwvqPgftssmTlceVjiQX364sbrjr2QU8/edit?usp=sharing) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
+12
-4
@@ -12,6 +12,7 @@ using namespace cv;
|
||||
static int liveQRCodeDetect();
|
||||
static int imageQRCodeDetect(const string& in_file);
|
||||
|
||||
static bool g_useArucoBased = false;
|
||||
static bool g_modeMultiQR = false;
|
||||
static bool g_detectOnly = false;
|
||||
|
||||
@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
|
||||
const string keys =
|
||||
"{h help ? | | print help messages }"
|
||||
"{i in | | input image path (also switches to image detection mode) }"
|
||||
"{aruco_based | false | use Aruco-based QR code detector instead of contour-based }"
|
||||
"{detect | false | detect QR code only (skip decoding) }"
|
||||
"{m multi | | use detect for multiple qr-codes }"
|
||||
"{o out | qr_code.png | path to result file }"
|
||||
@@ -75,6 +77,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
g_modeMultiQR = cmd_parser.has("multi") && cmd_parser.get<bool>("multi");
|
||||
g_detectOnly = cmd_parser.has("detect") && cmd_parser.get<bool>("detect");
|
||||
g_useArucoBased = cmd_parser.has("aruco_based") && cmd_parser.get<bool>("aruco_based");
|
||||
|
||||
g_saveDetections = cmd_parser.has("save_detections") && cmd_parser.get<bool>("save_detections");
|
||||
g_saveAll = cmd_parser.has("save_all") && cmd_parser.get<bool>("save_all");
|
||||
@@ -157,7 +160,7 @@ void drawQRCodeResults(Mat& frame, const vector<Point>& corners, const vector<cv
|
||||
|
||||
static
|
||||
void runQR(
|
||||
QRCodeDetector& qrcode, const Mat& input,
|
||||
const QRCodeDetectorBase& qrcode, const Mat& input,
|
||||
vector<Point>& corners, vector<cv::String>& decode_info
|
||||
// +global: bool g_modeMultiQR, bool g_detectOnly
|
||||
)
|
||||
@@ -191,7 +194,7 @@ void runQR(
|
||||
}
|
||||
|
||||
static
|
||||
double processQRCodeDetection(QRCodeDetector& qrcode, const Mat& input, Mat& result, vector<Point>& corners)
|
||||
double processQRCodeDetection(const QRCodeDetectorBase& qrcode, const Mat& input, Mat& result, vector<Point>& corners)
|
||||
{
|
||||
if (input.channels() == 1)
|
||||
cvtColor(input, result, COLOR_GRAY2BGR);
|
||||
@@ -229,7 +232,9 @@ int liveQRCodeDetect()
|
||||
cout << "Press 'd' to switch between decoder and detector" << endl;
|
||||
cout << "Press ' ' (space) to save result into images" << endl;
|
||||
cout << "Press 'ESC' to exit" << endl;
|
||||
QRCodeDetector qrcode;
|
||||
QRCodeDetectorBase qrcode = QRCodeDetector();
|
||||
if (g_useArucoBased)
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -310,7 +315,10 @@ int imageQRCodeDetect(const string& in_file)
|
||||
<< " on image: " << input.size() << " (" << typeToString(input.type()) << ")"
|
||||
<< endl;
|
||||
|
||||
QRCodeDetector qrcode;
|
||||
QRCodeDetectorBase qrcode = QRCodeDetector();
|
||||
if (g_useArucoBased)
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
|
||||
vector<Point> corners;
|
||||
vector<cv::String> decode_info;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user