1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
CONTENT
1. GENERAL DESCRIPTION OF THE MEDIA VISION PACKAGE
2. USAGE OF PORTING LAYER FOR CHANGING MEDIA VISION ENGINE MODULES
3. OPEN PORT REQUIRED PACKAGES
4. TEST SUITE
1. GENERAL DESCRIPTION OF THE MEDIA VISION PACKAGE
Currently Media Vision package includes three modules: Common, Barcode
detector and Barcode generator. Common module provides two handles (mv_source_h
and mv_engine_config_h) and related fuctionality. It used by barcode detector
and generator modules. mv_source_h is used for wrapping raw image data buffers.
mv_engine_config_h is optional. It can be used for fine tuning of internal
libraries which are used by API. mv_engine_config_h handle usually can be used
by barcode detector and/or generator modules (these modules provide
mv_barcode_detector and mv_barcode_generator internal libraries) in the case
when Native API doesn't cover all features supported by internal libraries.
Using NULL instead of real mv_engine_h handle as functions parameter has to be
taken into account. In most cases API user prefer to ignore detailed
configuration of the modules.
Barcode detector module API provides tools to analyze the image buffers using
mv_barcode_detect() function. This analysis strives to detect barcodes at the
image, determine the type and extract the message. Results can be processed
using mv_barcode_detected_cb callback.
Barcode generator module API provides tools to generate image buffer (or image
file) with barcode. Barcodes generation can be configured by type, message,
size, encoding mode, ECC (error correction level), version (three last setting
are allowed only for QR Codes). One of two functions can be used:
mv_barcode_generate_source() to generate the mv_source_h handle and
mv_barcode_generate_image() to generate the file with barcode image.
2. USAGE OF PORTING LAYER FOR CHANGING MEDIA VISION ENGINE MODULES
By default open source engine libraries are used to provide modules
functionality. But it is possible to substitute them by licensed or other custom
libraries. To enable building of custom library for the Media Vision package,
follow these steps:
a. Find CMakeLists.txt in the root of the package directory and change
MEDIA_VISION_BARCODE_DETECTOR_LICENSE_PORT (for enabling build of a custom
barcode detector library) and/or
MEDIA_VISION_BARCODE_GENERATOR_LICENSE_PORT (for enabling build of a custom
barcode generator library) options to ON. Example:
# only barcode detector module will be customized
option(MEDIA_VISION_BARCODE_DETECTOR_LICENSE_PORT "..." ON)
# barcode generator module will be default
option(MEDIA_VISION_BARCODE_GENERATOR_LICENSE_PORT "..." OFF)
b. Options change will cause CMake to build from different subdirectories of
mv_barcode directory. mv_barcode/barcode_detector and
mv_barcode/barcode_generator subdirectories are used by default.
mv_barcode/barcode_detector_lic and mv_barcode/mv_barcode_generator_lic
subdirectories will be used during build if the corresponding option is ON.
Last two subdirectories already include base structure of the porting layer
projects, and files will be used by main capi-media-vision library. Use this
files to call functions from custom libraries. For example, you can change
mv_barcode_detect_lic.c file in such a way:
#include "mv_barcode_detect_lic.h"
#include "custom_library_header.h"
int mv_barcode_detect_lic(
mv_source_h source,
mv_engine_config_h engine_cfg,
mv_rectangle_s roi,
mv_barcode_detected_cb detect_cb,
void *user_data)
{
mv_quadrangle_s *locations = NULL;
const char *messages = NULL;
mv_barcode_type_e *types = NULL;
// Here the call of the custom barcode detection function from
// custom_library_header.h:
int barcodes_number = custom_library_function(
source, roi, &locations, &messages, &types);
if (barcodes_number > 0)
{
detect_cb(
source, engine_cfg, locations, messages, types, barcodes_number,
user_data);
delete[] locations;
delete[] messages;
delete[] types;
}
return MEDIA_VISION_ERROR_NONE;
}
c. Change the packaging/capi-media-vision.spec to support any packages required
to be found into the system for success build of the custom libraries
(mv_barcode_detector and/or mv_barcode_generator). You also can remove
requirements on open packages that are required by disabled barcode
generator/detector ports. See list of the dependencies in the section 3 of
this README file.
d. Modify mv_barcode/barcode_{detector/generator}_lic/CMakeLists.txt file for
linking required libraries and/or including additional headers. Don't modify
the project name or reset ${MV_BARCODE_DETECTOR_LIB_NAME} variable, because
porting layer use these ones during the build. If it is required to change
projects/libraries names, best solution is to change
MV_BARCODE_DETECTOR_LIB_NAME and/or MV_BARCODE_GENERATOR_LIB_NAME options in
the CMakeLists.txt file that is located in the root of the package sources.
e. If custom libraries support mv_engine_config_h handle attributes, then
default values of these attributes has to be specified into
media-vision-config.json file. This file can be found into the root directory
of the sources. For each attribute three parameters has to be specified:
attribute name, attribute value type and attribute value. For example,
in the following example four attributes are specified:
{
"attributes":
[
{ "name" : "custom_detect_threshold",
"type" : "double",
"value" : 0.82,
},
{ "name" : "custom_detect_cascades_num",
"type" : "integer",
"value" : 50,
},
{ "name" : "custom_detect_use_haar",
"type" : "boolean",
"value" : true,
},
{ "name" : "custom_detect_haar_file_name",
"type" : "string",
"value" : "/usr/share/capi-media-vision/custom_haar.xml",
},
]
}
In above example for each newly created mv_engine_config_h handle four
attributes will be automatically added. These values can be accessed
into the custom modules using Media Vision Common library interface
functions:
mv_engine_config_get_double_attribute(),
mv_engine_config_get_int_attribute(),
mv_engine_config_get_bool_attribute(),
mv_engine_config_get_string_attribute().
For example, following code can be used to get value of the
"custom_detect_threshold" attribute:
mv_engine_conf_h engine_cfg = NULL;
// When configuration is creating, default attributes from
// media-vision-config.json file will be set:
int err = mv_create_engine_config(&engine_cfg);
if (MEDIA_VISION_ERROR_NONE == err)
{
double attribute_value = 0.0;
err = mv_engine_config_get_double_attribute(
engine_cfg, "custom_detect_threshold", &attribute_value);
if (MEDIA_VISION_ERROR_NONE == err)
{
// now attribute_value = 0.82 ("value" : 0.82 in json configuration)
}
}
3. OPEN PORT REQUIRED PACKAGES
Building default barcode detector and generator libraries requires following
dependencies:
Barcode detector: zbar
Barcode generator: zint
You can remove BuildRequires sections for these libraries from
packaging/capi-media-vision.spec file if corresponding module/modules is/are
disabled with options mentioned in 2.a.
4. TEST SUITE
capi-media-vision package includes test suite that allows to check API
functionality. The test suite application provides console interface that allows
to select options for barcode generation and detection.
Generation feature allows to generate barcodes images configured according to
the specified settings (type, message, size, encoding mode, ECC (error
correction level), version). Detection feature detects barcodes at the input
image files, decodes messages and generates output file (in jpeg format) where
locations of detected bercodes can be checked.
|