Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpDetectorQRCode.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Base class for bar code detection.
32
*/
33
34
#include <visp3/core/vpConfig.h>
35
36
#ifdef VISP_HAVE_ZBAR
37
38
#include <visp3/detection/vpDetectorQRCode.h>
39
40
BEGIN_VISP_NAMESPACE
44
vpDetectorQRCode::vpDetectorQRCode
() :
m_scanner
()
45
{
46
// configure the reader
47
m_scanner
.set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 1);
48
}
49
56
bool
vpDetectorQRCode::detect
(
const
vpImage<unsigned char>
&I)
57
{
58
bool
detected =
false
;
59
m_message
.clear();
60
m_polygon
.clear();
61
m_nb_objects
= 0;
62
63
m_scanner
.set_config(zbar::ZBAR_NONE, zbar::ZBAR_CFG_ENABLE, 1);
64
unsigned
int
width = I.getWidth();
65
unsigned
int
height = I.getHeight();
66
67
// wrap image data
68
zbar::Image img(width, height,
"Y800"
, I.bitmap, (
unsigned
long
)(width * height));
69
70
// scan the image for barcodes
71
m_nb_objects
=
static_cast<
size_t
>
(
m_scanner
.scan(img));
72
73
// extract results
74
for
(zbar::Image::SymbolIterator symbol = img.symbol_begin(); symbol != img.symbol_end(); ++symbol) {
75
m_message
.push_back(symbol->get_data());
76
detected =
true
;
77
78
std::vector<vpImagePoint> polygon;
79
for
(
unsigned
int
i = 0; i < static_cast<unsigned int>(symbol->get_location_size()); i++) {
80
polygon.push_back(
vpImagePoint
(symbol->get_location_y(i), symbol->get_location_x(i)));
81
}
82
m_polygon
.push_back(polygon);
83
}
84
85
// clean up
86
img.set_data(
nullptr
, 0);
87
88
return
detected;
89
}
90
END_VISP_NAMESPACE
91
#elif !defined(VISP_BUILD_SHARED_LIBS)
92
// Work around to avoid warning: libvisp_core.a(vpDetectorQRCode.cpp.o) has
93
// no symbols
94
void
dummy_vpDetectorQRCode() { }
95
#endif
vpDetectorBase::m_message
std::vector< std::string > m_message
Message attached to each object.
Definition
vpDetectorBase.h:129
vpDetectorBase::m_polygon
std::vector< std::vector< vpImagePoint > > m_polygon
For each object, defines the polygon that contains the object.
Definition
vpDetectorBase.h:128
vpDetectorBase::m_nb_objects
size_t m_nb_objects
Number of detected objects.
Definition
vpDetectorBase.h:130
vpDetectorQRCode::m_scanner
zbar::ImageScanner m_scanner
QR code detector.
Definition
vpDetectorQRCode.h:122
vpDetectorQRCode::vpDetectorQRCode
vpDetectorQRCode()
Definition
vpDetectorQRCode.cpp:44
vpDetectorQRCode::detect
bool detect(const vpImage< unsigned char > &I) VP_OVERRIDE
Definition
vpDetectorQRCode.cpp:56
vpImagePoint
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition
vpImagePoint.h:82
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
detection
src
barcode
vpDetectorQRCode.cpp
Generated by
1.17.0