DM二維碼識別庫DMDECODER的使用--MFC常式

來源:互聯網
上載者:User

標籤:

    DM碼和QR碼是當今比較主流的二維碼,其中QR碼容量大,容量密度為16kb,DM碼容量要小一點,可在僅僅25mm²的面積上編碼30個數字,但是DM碼的容錯率更高,所以實際的工業生產中經常使用DM碼作為產品的標籤。

    DMDECODER是一款比較好用的DM碼解析軟體,包含有一個DLL和一個lib,使用這個庫也比較容易我們先看組成

    

使用該庫第一步是匯入庫路徑和庫函數如下

//匯入dll#define DLL_EXPORT __declspec(dllexport)  extern "C" DLL_EXPORT int _stdcall DataMatrix_decode(const char* filename); //    DataMatrix_decode_rt --> 對裝置採集的映像進行即時處理//    imageData   : 指向映像資料區的指標(24位位元影像)//    width       : 映像寬度//    height      : 映像高度extern "C" DLL_EXPORT int _stdcall DataMatrix_decode_rt(unsigned char* imageData, int width, int height); extern "C" DLL_EXPORT int _stdcall DataMatrix_output(unsigned char* message); 

然後解碼過程是這樣的

char* file = (char*)malloc(sourceFilePath.GetLength()+1);//待解碼圖片路徑        for(int i = 0; i < sourceFilePath.GetLength();i++)        {            file[i] = sourceFilePath.GetAt(i);        }        file[sourceFilePath.GetLength()] = 0;        int length = DataMatrix_decode(file); //解碼並返回碼字長度(解碼失敗則返回-1)        if(length>0)        {            unsigned char* message = (unsigned char*)malloc(sizeof(char)*(length+1));            DataMatrix_output(message);//將解碼碼字儲存到數組中            message[length] = 0;            convertString.Empty();            convertString.AppendFormat("%s",message);            CString show;            show.Empty();            show = convertString.Left(convertString.GetLength()-12);            ((CEdit*)GetDlgItem(IDC_EDIT_COVERT_RESULT))->SetWindowText(show);            free(message);        }    

完整的MFC工程如下

注意結果尾巴上的著作權標誌tonxong.com去掉哦

工程路徑

http://download.csdn.net/detail/dengrengong/8608187

 

DM二維碼識別庫DMDECODER的使用--MFC常式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.