IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

Lecture de codes barres (qr code) avec zxing


Sujet :

MATLAB

  1. #1
    Futur Membre du Club
    Femme Profil pro
    chef de laboration
    Inscrit en
    Janvier 2017
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : Algérie

    Informations professionnelles :
    Activité : chef de laboration
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 7
    Points : 6
    Points
    6
    Par défaut Lecture de codes barres (qr code) avec zxing
    bonjour
    j'essai d'executer le programme suivant mais un message d'erreur :


    "??? Undefined variable "ErrorCorrectionLevel" or class "ErrorCorrectionLevel.M".

    Error in ==> encode_qr at 94
    qr_quality = ErrorCorrectionLevel.M;"


    que je n'arrive pas a comprendre sachant que j'ai télecharger zxing et je les copier dans ma racine MATLAB

    merci d'avance


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    function qr = encode_qr(message, varargin)
    % ENCODE_QR create a 2D QR code containing a message
    %  
    % This function creates a QR code containing a string message. The QR code
    % can be of varying sizes.
    %
    % Note that this function requires zxing (<a href="http://code.google.com/p/zxing/" target="_blank">http://code.google.com/p/zxing/</a>)
    % installed, and core/core.jar, javase/javase.jar on the classpath
    %
    % This is the second attempt, based on the code of Lior Shapira, with the
    % update to ZXing v. 2.1 codebase and 'parsepropval' for cleaner list of
    % the parameters
    %   Parameters:
    %
    %       message - string containing message
    %       'Size' - size of the QR code, in pixels. As QR is quadratic, you
    %               can supply either scalar or vector. Of you supply vector, 
    %               the size must be equal. If the parameter is not supplied.
    %               it is determined from 'Version'.
    %       'Version', 'v[1..40]' - version of the QR code
    %       'Quality', 'L|M|H|Q' - quality of the error correction (Low,
    %                           Medium, High, super (not suree ;)
    %                           'M' quality is the default
    %       'Character_set' - charecter set for encoding QR code. 'UTF-8' is
    %                       set to default, other values to be retrieved from 
    %       <a href="https://github.com/zxing/zxing/blob/master/core/src/com/google/zxing/common/CharacterSetECI.java" target="_blank">https://github.com/zxing/zxing/blob/...terSetECI.java</a>
    %           Using 'Character_set' any other than 'ISO-8859-1' will probably
    %           make QR unreadable to any other QR decoder, except ZXing's
    %
    %   Returns:
    %
    %       qr - logical matrix of size s containing the QR code
    %
    %   Example:
    %       encode_qr(message, 'Character_set', 'ISO-8859-1')
    %       encode_qr(message, 'Size', 25)
    %       encode_qr(message, 'Size', [33 33])
    %       encode_qr(message, 'Version', 3, 'Quality', 'h', 'Character_set', 'UTF-16BE')
    %
     
    %% AUTHOR    : Lior Shapira 
    %% $DATE     : 02-Nov-2010 11:20:45 $ 
    %% $Revision : 1.00 $ 
    %% DEVELOPED : 7.11.0.584 (R2010b) 
    %% FILENAME  : encode_qr.m 
     
    import com.google.zxing.qrcode.QRCodeWriter;
    import com.google.zxing.BarcodeFormat;
    import com.google.zxing.EncodeHintType;
    import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
     
     
    %% parse arguments
    % using parsepropval from <a href="http://www.mathworks.com/matlabcentral/fileexchange/22671-parse-propertyvalue-pairs-and-structures/content/parsepropval.m" target="_blank">http://www.mathworks.com/matlabcentr...parsepropval.m</a>
    props.size = [ 1 1 ]; % WRONG SIZE. Intentional
    props.version = 'v1';
    props.quality = 'M';
    props.character_set = 'UTF-8';
     
    props = parsepropval(props,varargin{:});
    qr_init = 17;   % minimal size of the QR code
    qr_delta = 4;   % size of the quiet zone
     
    qr_quality = ['L' 'M' 'Q' 'H']; % error correction quality
     
    % check supplied version
    if (isa(props.version,'char') || isa(props.version,'numeric'))
        if isa(props.version,'char')
            qr_ver = str2num(props.version(2:end));
            if not(strcmpi(props.version(1),'v'))
                error('Try removing quotes at "version" parameter value')
            end
        else
            qr_ver = props.version;
        end
    else
        error('"version" must be string "v[1..40]" or numerical value [1..40]')
    end
     
    if ((qr_ver < 1) || (qr_ver > 40))
        error('"version" must be in [1..40] range')
    end
     
    if (props.size(1) == 1)  % matrix size was supplied, don't recalculate
        props.size = qr_init+qr_delta*qr_ver;
    end
     
     % check quality
     if isempty(strfind(qr_quality, upper(props.quality)))
         error('"quality" must be string "L | M | Q | H"')
     else
         switch upper(props.quality)
             case 'M'
                 qr_quality = ErrorCorrectionLevel.M;
             case 'L'
                 qr_quality = ErrorCorrectionLevel.L;
             case 'H'
                 qr_quality = ErrorCorrectionLevel.H;
             case 'Q'
                 qr_quality = ErrorCorrectionLevel.Q;
         end
     end
     
     % check supplied size
    if isscalar(props.size)
        props.size = [props.size props.size];
    end
     
     % re-check size
     if (props.size(1) == props.size(2)) % must be equal
        tmp = props.size(1) - 17;
        if not(mod(tmp,4) == 0)
            error('Matrix does not meet sizing requirements (17+N*4)')
        end
    else
        error('Matrix must be square')
    end
     
     
    %% encoding qr
    qr_writer = QRCodeWriter;
    qr_hints = java.util.Hashtable;
     
    % use hint for encoding type
    qr_hints.put(EncodeHintType.ERROR_CORRECTION, qr_quality);
     
    % use hint for character set
    qr_hints.put(EncodeHintType.CHARACTER_SET, props.character_set);
     
    M_java = qr_writer.encode(message, BarcodeFormat.QR_CODE, props.size(2), props.size(1), qr_hints);
    qr = zeros(M_java.getHeight(), M_java.getWidth());
    for i=1:M_java.getHeight()
        for j=1:M_java.getWidth()
            qr(i,j) = M_java.get(j-1,i-1);
        end
    end
     
    clear qr_writer;
    clear M_java;
     
    qr = 1-logical(qr);
     
    % Created with NEWFCN.m by Frank Gonzlez-Morphy  
    % Contact...: <a href="mailto:frank.gonzalez-morphy@mathworks.de">frank.gonzalez-morphy@mathworks.de</a>  
    % ===== EOF ====== [encode_qr.m] ======

  2. #2
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 302
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 302
    Points : 53 163
    Points
    53 163
    Par défaut
    Il faut ajouter le chemin vers zxing avec javaclasspath

    Voici un bout de code que j'utilisais :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    pathName = ...
     
    jarPaths = {fullfile(pathName, 'zxing', 'core-3.2.0.jar') 
                fullfile(pathName, 'zxing', 'javase-3.2.0.jar')};
     
    javaclasspath(jarPaths);
    À toi d'adapter les chemins selon la version de zxing que tu utilises.
    Ingénieur indépendant en mécatronique - Conseil, conception et formation
    • Conception mécanique (Autodesk Fusion 360)
    • Impression 3D (Ultimaker)
    • Développement informatique (Python, MATLAB, C)
    • Programmation de microcontrôleur (Microchip PIC, ESP32, Raspberry Pi, Arduino…)

    « J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" » (Saint Huck)

  3. #3
    Futur Membre du Club
    Femme Profil pro
    chef de laboration
    Inscrit en
    Janvier 2017
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : Algérie

    Informations professionnelles :
    Activité : chef de laboration
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 7
    Points : 6
    Points
    6
    Par défaut ou est ce que je doit ecrire ce bout de programme!
    je vous remercie pour votre réponse, je veux juste savoir ou je doit écrire ce bout de programme, est ce que je doit l'ajouter avant ma fonction ou bien à l'intérieur ?

  4. #4
    Futur Membre du Club
    Femme Profil pro
    chef de laboration
    Inscrit en
    Janvier 2017
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : Algérie

    Informations professionnelles :
    Activité : chef de laboration
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 7
    Points : 6
    Points
    6
    Par défaut
    pour moi le chemin est donné par ces fonction:

    import com.google.zxing.qrcode.QRCodeWriter;
    import com.google.zxing.BarcodeFormat;
    import com.google.zxing.EncodeHintType;
    import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

    mais a chaque fois je j'execute un message d'érreur s'affiche pour me dire que il ne les connait pas

  5. #5
    Futur Membre du Club
    Femme Profil pro
    chef de laboration
    Inscrit en
    Janvier 2017
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : Algérie

    Informations professionnelles :
    Activité : chef de laboration
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 7
    Points : 6
    Points
    6
    Par défaut
    qu'est s que je doit ecrire a la place de ces 3 points
    pathName = ...

  6. #6
    Rédacteur/Modérateur

    Avatar de Jerome Briot
    Homme Profil pro
    Freelance mécatronique - Conseil, conception et formation
    Inscrit en
    Novembre 2006
    Messages
    20 302
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Freelance mécatronique - Conseil, conception et formation

    Informations forums :
    Inscription : Novembre 2006
    Messages : 20 302
    Points : 53 163
    Points
    53 163
    Par défaut
    Citation Envoyé par marina1236 Voir le message
    qu'est s que je doit ecrire a la place de ces 3 points
    pathName = ...
    Tu dois mettre le chemin vers le dossier contenant zxing.

    Par exemple si zxing est installé dans le dossier D:\work\zxing :

    Il faudra peut être adapter les numéros de version dans les noms des .jar
    Ingénieur indépendant en mécatronique - Conseil, conception et formation
    • Conception mécanique (Autodesk Fusion 360)
    • Impression 3D (Ultimaker)
    • Développement informatique (Python, MATLAB, C)
    • Programmation de microcontrôleur (Microchip PIC, ESP32, Raspberry Pi, Arduino…)

    « J'étais le meilleur ami que le vieux Jim avait au monde. Il fallait choisir. J'ai réfléchi un moment, puis je me suis dit : "Tant pis ! J'irai en enfer" » (Saint Huck)

  7. #7
    Futur Membre du Club
    Femme Profil pro
    chef de laboration
    Inscrit en
    Janvier 2017
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 40
    Localisation : Algérie

    Informations professionnelles :
    Activité : chef de laboration
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2017
    Messages : 7
    Points : 6
    Points
    6
    Par défaut
    ok merci

Discussions similaires

  1. Lecture par Douchette lecteur de code barre
    Par tleboukaka dans le forum Bases de données
    Réponses: 10
    Dernier message: 13/09/2015, 17h05
  2. Lecture bizarre à partir du lecteur code barre
    Par BYALI dans le forum Composants VCL
    Réponses: 8
    Dernier message: 18/11/2014, 11h50
  3. Génération de codes EAN et codes barres
    Par Supercalifragilis dans le forum Autres Logiciels
    Réponses: 3
    Dernier message: 29/08/2014, 21h04
  4. Gestion des code EAN + impression code barres
    Par jakadam dans le forum Conception
    Réponses: 2
    Dernier message: 18/05/2011, 21h32
  5. Code barre - Recherche code source
    Par Freud44 dans le forum C++
    Réponses: 11
    Dernier message: 03/06/2008, 14h17

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo