......
.
Per la realizzazione di questo codice si sono utilizzate le funzioni delle librerie dinamiche di ''
".
Public Struct QrCodeHeader
model As Integer
version As Integer
level As Integer
charactor_size As Integer
byte_size As Integer
End Struct
Private Const CV_LOAD_IMAGE_UNCHANGED As Short = -1
Private Const DEFAULT_ADAPTIVE_TH_SIZE As Byte = 25
Private Const DEFAULT_ADAPTIVE_TH_DELTA As Byte = 10
Library "libopencv_highgui:2.4.0"
' IplImage* cvLoadImage( const char* filename, int flags )
Private Extern cvLoadImage(filename As String, flagLIC As Integer) As Pointer
Library "libopencv_core:2.4.0"
' void cvReleaseImage(IplImage * image)
Private Extern cvReleaseImage(img As Pointer)
Library "libdecodeqr:0.9.3"
' QrDecoderHandle qr_decoder_open ()
Private Extern qr_decoder_open() As Pointer
' short qr_decoder_decode_image (QrDecoderHandle decoder, IplImage *src, int adaptive_th_size, int adaptive_th_delta)
Private Extern qr_decoder_decode_image(decoderP As Pointer, srcP As Pointer, adaptive_th_size As Integer, adaptive_th_delta As Integer) As Short
' int qr_decoder_get_header (QrDecoderHandle decoder, QrCodeHeader *header)
Private Extern qr_decoder_get_header(decoderP As Pointer, header As Pointer) As Integer
' int qr_decoder_get_body (QrDecoderHandle decoder, unsigned char *buf, int buf_size)
Private Extern qr_decoder_get_body(decoderP As Pointer, buf As Pointer, buf_size As Integer) As Integer
' void qr_decoder_close (QrDecoderHandle decoder)
Private Extern qr_decoder_close(decoderP As Pointer)
Public Sub Button1_Click()
Dim header, immago, decoder, buf As Pointer
Dim qdh As QrCodeHeader
header = Alloc(SizeOf(gb.Byte), 24)
' Viene caricata l'immagine del "QR Code":
immago = cvLoadImage("/percorso/della/immagine/del/Qr Code", CV_LOAD_IMAGE_UNCHANGED)
If immago == 0 Then Error.Raise("Errore !")
' Viene inizializzata la libreria "decoderqr":
decoder = qr_decoder_open()
If decoder == 0 Then Error.Raise("Errore !")
' Effettua la decodifica utilizzando parametri di default:
qr_decoder_decode_image(decoder, immago, DEFAULT_ADAPTIVE_TH_SIZE, DEFAULT_ADAPTIVE_TH_DELTA)
If qr_decoder_get_header(decoder, header) > 0 Then
qdh = Header
buf = Alloc(qdh.byte_size + 1)
qr_decoder_get_body(decoder, buf, qdh.byte_size + 1)
' Dereferenziando il "pointer", viene mostrato il testo del "QR Code":
Print String@(buf)
Endif
' Va in chiusura:
qr_decoder_close(decoder)
cvReleaseImage(VarPtr(immago))
Free(buf)
Free(header)
End