樹莓派應用:無線掃描儀

傳統的掃描儀都是須要經過USB鏈接到PC上使用的。若是多人共用掃描儀,好比辦公室裏,須要常常插拔,更換PC,安裝驅動,很是麻煩。如今搭載Android系統的智能掃描儀已經出現了,用戶能夠很方便的經過網絡無線掃描。那麼有什麼辦法讓舊的掃描儀也智能化?使用35刀的樹莓派能夠提供一種廉價的解決方案 - 把掃描儀鏈接到樹莓派上,經過樹莓派控制掃描儀,並經過網絡傳輸數據。這樣就不須要花不少錢去購買新的掃描儀了。javascript

測試環境

  • 設備: Raspberry Pi 2
  • 系統: RASPBIAN JESSIE 

傳統掃描儀智能化解決方案

這是一套使用Dynamic Web TWAIN樹莓派版本的解決方案。html

優勢

  • 掃描儀不須要經過USB接口鏈接到PC。
  • 在瀏覽器中操做掃描儀,不須要安裝任何插件。
  • 樹莓派即插即用。自動創建掃描以及網絡鏈接服務。

無線掃描儀

安裝刪除服務

下載安裝包java

安裝:git

sudo dpkg -i dynamic_web_twain-arm-trial.deb

刪除:github

sudo dpkg -r dynamsoft-webtwain-service

代碼示例

  1. Dynamic Web TWAIN中獲取Resources資源目錄。
  2. 建立工程目錄。把Resources資源拷貝到工程根目錄中,並建立一個index.html頁面。
  3. 設置樹莓派的IP地址。這裏是個人:
    var remoteIP = "192.168.8.51";
  4. 禁用AutoLoad屬性:
    Dynamsoft.WebTwainEnv.AutoLoad = false;
  5. 設置序列號。能夠聯繫support@dynamsoft.com獲取試用序列號。源碼中已經包含試用序列號:
    Dynamsoft.WebTwainEnv.ProductKey = "";
  6. 建立Dynamic Web TWAIN對象:
    var HTTP_PORT = 18618;
            var HTTPS_PORT = 18619;
            window.onload = function() {
                Dynamsoft.WebTwainEnv.CreateDWTObject('dwtObjectContainer', remoteIP, HTTP_PORT, HTTPS_PORT, function(obj) {
                    DWObject = obj;
                    DWObject.Width = 270;
                    DWObject.Height = 350;
                    console.log('DWTObject created.');
                    if (DWObject) {
                        var count = DWObject.SourceCount;
                        if (count == 0 && Dynamsoft.Lib.env.bMac) {
                            DWObject.CloseSourceManager();
                            DWObject.ImageCaptureDriverType = 0;
                            DWObject.OpenSourceManager();
                            count = DWObject.SourceCount;
                        }
                        for (var i = 0; i < count; i++)
                            document.getElementById("source").options.add(new Option(DWObject.GetSourceNameItems(i), i)); // Get Data Source names from Data Source Manager and put them in a drop-down box
                    }
                }, function(es) {
                    console.log(es);
                });
            };
  7. 獲取圖像:
    function AcquireImage() {
                if (DWObject) {
                    var OnAcquireImageSuccess, OnAcquireImageFailure;
                    OnAcquireImageSuccess = OnAcquireImageFailure = function() {
                        DWObject.CloseSource();
                    };
     
                    DWObject.SelectSourceByIndex(document.getElementById("source").selectedIndex); //Use method SelectSourceByIndex to avoid the 'Select Source' dialog
                    DWObject.OpenSource();
                    DWObject.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
                    DWObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure);
                }
            }
  8. 把掃描儀鏈接到樹莓派上。打開index.html就能夠經過手機,平板或者PC遠程掃描了。

視頻

https://v.qq.com/x/page/r0341rlc3et.htmlweb

 

源碼

https://github.com/dynamsoftlabs/raspberrypi-document-scanning瀏覽器

相關文章
相關標籤/搜索