dlbeer / quirc

QR decoder library
Other
865 stars 285 forks source link

Detecting nonexistent qr codes in single (complex) qr code #135

Closed seiferteric closed 1 year ago

seiferteric commented 1 year ago

Hello, I was generating random qr codes in 8-bit data mode with between 1-200 bytes in length and then detecting them with quirc. I am passing the generated image data directly into quirc input, so not cameras involved, just clean bitmap data. Sometimes it will detect more than one (according to quirc_count) when there should always be only one code seen.

I am wondering if this is an issue with detection, or a limitation of qr code spec itself, if in some circumstances, you could have what appears to be a qr code inside of a qr code depending on the data?

Here is an example, it claims to detect 3 codes here: debug

I can provide my test code if needed.

seiferteric commented 1 year ago

Here is another example using the inspect tool. It looks like the corner detection has some issue in that the first one looks fine with top left, top right, bottom right, bottom left, but then the others seem like something went wrong. Maybe the second one thinks it's rotated? But the last one there are negative numbers in the corners which I don't understand, but maybe it allows negative index if it is partially out of frame?

3 QR-codes found:

    45 cells, corners: (4,4) (48,4) (48,48) (4,48)
    [][][][][][][]        []  [][]  [][]  []  [][]      []  []              []  [][][][][][][]
    []          []        []  []      []  [][]    []  []    [][]  []      []    []          []
    []  [][][]  []  [][][]    []    []  [][][][]    [][][]  []  [][]  []  []    []  [][][]  []
    []  [][][]  []      [][][][]  [][]  []  [][][][]      [][]            [][]  []  [][][]  []
    []  [][][]  []    [][]  []        [][]  [][][][][]  []  [][][][]    [][][]  []  [][][]  []
    []          []              [][]      [][]      []    [][]        []        []          []
    [][][][][][][]  []  []  []  []  []  []  []  []  []  []  []  []  []  []  []  [][][][][][][]
                    [][][][]  [][][][]    [][]      []  [][][]  [][]  [][][][]                
    [][][]  [][][][][][]  [][][]    [][][]  [][][][][]  []  []    [][][]      [][]      []    
          []  []  [][][]  [][][]    [][]      [][][][][]  [][][][]        [][]  []  [][]    []
      []  [][][][]  [][][]      []        [][][]      [][]      []  [][][]  [][]  []  []    []
    []  []  [][]  [][][]    []      []    []  [][]    []  [][][]  []    [][][][][][][]        
    [][]  []  [][][]      []  [][][][]              []    []    [][]  [][][][]        []  []  
    []    []  []      [][][]  []  []  [][]  []  []  [][][][][]  []  [][][]    [][][]    []    
    []    []    [][]  []    []  []    [][]          [][][]        [][]  [][]  []          [][]
    []  []    []  [][][][][][]        [][]        [][][][][]  []  [][][][]      [][]  []      
            [][][][][][]    []  []  []      [][]  []          [][][][][][][]  []      []      
    [][]  [][]    [][][][]  []    []  []  [][]      [][]  [][]      [][]        [][][]  [][][]
    []  []  [][][][]    [][]  [][]    [][][]  []  []      [][]        []  [][]    [][]    [][]
      []  [][]    []                  [][]        []  []    []  [][][]  [][]            []  []
        [][][][][][][][]  []      [][]      [][][][][]        []    [][][][][][][][][]  []  []
    []  [][][]      [][]      [][][][]  []  []      [][]  []                []      []        
    [][]    []  []  [][][][]  []  [][]    [][]  []  [][]        []    []  [][]  []  []    [][]
        []  []      []    []  [][]  [][]    []      [][][][][]  []  [][][]  []      []  [][][]
    []    [][][][][][]  [][][][]  [][][][][][][][][][][]  []    [][][][]    [][][][][]    [][]
      []  []  []    []    []  []  [][][]    [][][][]    []  []  [][][]  [][]  [][]        []  
      [][]      [][][][]  [][][]    [][]      []    [][]  []  [][][]        [][]  [][][][][][]
      []      []  [][]    []    [][][][][][][][][]    [][][][][][][][][]  []    []  []    [][]
      [][]  []  [][]    []      [][]  [][]  []  []  [][]        [][]        []                
      [][][]          []  []    [][][]    [][]    []  []  [][][][][]      []    [][]  []      
      [][][][]  []    [][]  []  [][][][][][]  []      [][][]        [][]  []    [][][][][][]  
        []  [][]    [][][][][]    [][]    [][][]  []  [][][]  []  [][]    []    []  [][]  []  
    [][][]    [][][]    []  []  [][]    [][]    [][]    [][]  [][][]        [][]  [][][]      
    [][][]        []    []  []          []        [][]      []  [][][]  [][]  [][]  []    [][]
            []  []                        [][][][]  []  [][][]    [][]  []  [][][]    [][]  []
      [][][][]    [][][][]  []  []  [][][]  []  [][][][]  [][][][][][][]  []  [][][][]  [][]  
    []    [][]  [][]        [][][]  []  []  [][][][][]  [][][][][]  []  [][][][][][][][]    []
                    []    [][]  []        [][]      []  [][][]      [][][][][]      [][][][][]
    [][][][][][][]  [][]  []  []  []  [][][][]  []  [][]  [][]  [][][]      []  []  [][]    []
    []          []  []        [][]  []    [][]      []  [][]    [][][]  []  []      [][][][]  
    []  [][][]  []  [][][][][][]      []    [][][][][][][]  []    [][]    [][][][][][]  []    
    []  [][][]  []    []  []  []    []    [][]    []  [][][][][][]            []              
    []  [][][]  []  []    [][]  []  []  [][]  [][]    []                []  [][]  [][]  []    
    []          []  []    []  []  []  [][]  [][]  []  [][][]  []    []  [][]  [][]  []    []  
    [][][][][][][]  [][][]          []    [][][][][][]    []  []                []  [][]  [][]

  Decoding successful:
    Version: 7
    ECC level: L
    Mask: 0
    Data type: 4 (BYTE)
    Length: 144
    Payload: *Cm>6�;�]&���3��x�Y;��If�{aB��l����,
                                                 �+�M��N0+�lv�xd0٦�Z�I���!E�;p��((�YS~�e�z�X���h�Y͍rp�� �'�qP�H�C�n����;�K ��~^-�~�F�E5��x�

    49 cells, corners: (49,4) (49,46) (5,38) (5,4)
    [][][][][][][]  []              []  []      [][][]  []  [][]    [][]  [][]          [][][][][][][]
    []          []    []      []  [][]    []  []      [][]  []        []  [][]          []            
    []  [][][]  []    []  []  [][]  []  [][][]    [][][][][]  []      []      [][][]    []  [][][][]  
    []  [][][]  []  [][]            [][]      [][][][][]  []  [][][]  [][][][][][][]    []  [][][][]  
    []  [][][]  []  [][][]    [][][][][]      [][][][][]  []  [][][]  [][][][][]        []  [][][][]  
    []          []  [][][]    [][][][]  []  [][][][][][]  [][]          []    [][]      []  [][][][]  
    []          []        []        [][]    []        [][]      [][][]                  []      [][]  
    [][][][][][][]  []  []  []  []  []  []  []  []    []  []  []    []                  []            
                    [][][][]  [][]  [][][]  []  []    []  []  []    []  []    []  []    [][][][][][][]
        []      [][]      [][][]    [][][]  []        [][]    [][][][][]  [][][][][]                  
    []    [][]  []  []    [][][]    []  []  [][][][][][]  [][][]      [][][][]  [][]                  
    []    []    []  [][]        [][][][]  [][][][][][]      [][]      [][][][]  [][][][][][][][]  [][]
          []  []  [][]  [][][]  []      [][]      [][]      [][]      [][][][]  [][][][]  []    []    
            [][][][][][][]    []  [][][][][]      [][][][]          []        [][][]      []    []    
      []  []        [][][][]  []  [][][]  []    [][][]  []    []        []    [][][]    [][][][][]  []
        []    [][][]    [][]  [][]    []    []                []        []      [][][][]  [][][]  []  
    [][]          []    [][][]  []  [][][][][]  []            [][][][][]  [][]      [][][][]  []  []  
          []      []  [][]  [][]        [][][]  []    []  [][]  [][]  []  [][][][]  [][][][]    []  []
          []  [][]      [][][][]  []    [][][]            [][]      [][]  [][][][]        []    []    
          []      []  [][][][][]  []  [][][][][]          [][]      []  []      []  [][][]      []    
    [][][]  [][][]        [][][][][]          []  [][]    [][]          [][][][][][][][][]      []    
    [][]    [][]          [][]      [][]  [][]    [][][]      []    []  []  [][][][][][]  []      []  
    []  []          [][]  []        [][]  [][]        [][]  []  [][][]  []      [][][][][][][][]      
    []  []            [][]  [][][]  [][]      []  [][]  [][][]  [][]    []    [][][][][]  [][][]      
        []  [][][][][][][][][][][]  []    []  []        [][][]      [][]  [][][]  [][][]    [][][]  []
    []      []      []    [][]    []        [][]          [][]            [][][]    [][][][][][]  []  
    [][]    []  []  []                []  [][][][][][][]      [][]                  [][]    [][]  []  
    [][][]  []      [][]  []    []    []  [][]        []  []  [][][]      [][]  [][][][]    [][][]  []
    [][]    [][]    []  [][][]  []        [][]  []    []  []  [][][][][]        [][][][][][][][][][]  
      []    [][][][][]    [][]  []  [][][][][]        [][]    [][][]  []        [][]        [][][][]  
    [][][]      [][]  [][][][][][]    []  [][]        []    [][]  []  []  [][][][][]        [][][][]  
    [][][][][][]  [][]  []  [][][]  []  [][][][][][][][][][][][]    [][]  [][]    []    []  [][]    []
    [][]    []  []  []        [][][]    []    [][][][][][][][][][][]  [][][][]    []        [][]    []
                      []  [][][][][]  []  [][]    [][][]    [][][][]  [][][][][]  [][][][]  [][]  []  
          []        []        [][][][][][][]      [][]      [][][][]  []  [][]    [][][][][][][][]    
      [][][]  [][]    []      [][]        []    [][][][][][][][]      [][][][]    []      []    []    
      []  [][][][]    []      [][][][][]  [][]  []    [][][][][][][][]    [][]  [][][][][]      []  []
          [][]  []    []  [][]      [][]  []  []      []  [][]  [][][]    [][]    [][][][]        [][]
    []    [][][]      []    [][]      [][][]          [][]    [][][][]        []  [][][]  []        []
    [][]    []    [][]        []  []  [][][]      [][]  [][]  [][][][]    []  []    [][][]  []      []
    []  [][]    [][]  [][]    [][][]  [][][]  []  [][][][][][][][][][]    [][]  []      []  [][]  [][]
      [][]      [][][]  []  [][][]  [][][]    [][]  [][][]    [][][][]  []    [][]              [][][]
    []      [][][][]    []  [][]    []      [][][]      [][]    [][]    [][][][][]      []  [][][][][]
    [][]  [][][][][]  []  [][][]    [][][]  [][]          []    [][][]  [][][][][][]        [][][][][]
    [][][][][]    [][][][]  [][][][][][]    []  [][][][]  []            []    []    []    [][][]  []  
    []    [][]      [][][][][]  [][][][]  [][][][]  [][][]              []    []    [][][][]      []  
      [][][][]  []  []    [][]      [][][]  [][][]    []  [][][]              []    [][]          [][]
        []  []      []      [][][]  [][][]  [][][][][][]  [][][]    []  []                        [][]
            [][][][][]  []  [][][]  [][]  [][]        []  []  []    []  []    [][][]    []  [][]  [][]

  Decoding FAILED: ECC failure

    33 cells, corners: (4,47) (4,-10) (39,-17) (26,46)
    [][][][][][]    []          [][][]  [][][][]  [][][][][]          
            []  []  []  [][][][]  []  [][]    [][][][]                
    [][][]  []  []  [][][][]        []    []      [][][]              
    [][][]  []  []  [][][][]  [][]  [][][]  []  []  [][]              
    [][][]    [][]      []    []    [][][]    []      []              
    [][][]    [][][]  []  []    [][][][][]    [][]                    
    [][][]    [][][]  []      []    [][]  [][][][]  [][][]            
                    [][]          [][][]            []                
          []  []    []    [][]    [][][][][]  [][]                    
    [][][][]  []  [][]    [][]      [][][][]  [][][]                  
              [][][][]      [][][][][]  []  [][][][]  []              
          [][]  []          []    [][]  [][]      [][][]              
    []  [][][]  []    [][]  []        []      [][]      []            
      [][][]          []      []      []    []  [][][]                
      []          [][][]  [][][][]    [][][]    []    [][]            
                        [][][][]      [][]  []  []                    
    [][]  [][]    [][][]    [][][][]      [][][]  []                  
    [][]    [][]  [][]      [][][][]      [][]                        
    []        []          []      []  []    []  [][][][]              
      [][][]          [][][][][][][]        []                        
      [][]  [][]    [][][][][][][][]    [][]  []    [][]              
    []  []          [][]  [][][]    [][][][]    [][]  []              
          []  []    [][][][][][]    []  []  []  [][][][]              
        []    []      [][][]  []    [][]  []    []  [][]              
    []  [][]  []      [][][]    []    []  [][][]      []              
      []  [][][]  []  []  []  [][][]  []    [][]                      
          [][][][][][][][]  [][]  [][]    []  []  [][]                
        [][]    []  [][][][][]  [][]          [][]  []                
    []  [][][][][]  []      []    [][][][][]      [][][]              
    [][][][][]  []  []  []  []    []    []  [][][]                    
    [][]    []    []  []    [][][][]    []  []      []                
      []    [][]  [][][][][][][][][]    [][]  [][][][]                
      []    [][][]      [][][][]    []                                

  Decoding FAILED: Format data ECC failure