[英]HTML5 getUserMedia camera focus
我創建了一個簡單的移動應用程序,它顯示相機並使用https://github.com/LazarSoft/jsqrcode解碼QRCodes
因為我的相機模糊,這適用於大QR碼。 有沒有辦法用Javascript聚焦相機? 所以這也適用於較小的圖像或是否有另一種解決方案?
編輯我注意到如果我使用Android應用程序(而不是HTML5版本),它可以處理更多的色差,並可以掃描我的代碼,而jsqrcode不能。 我使用錯誤的庫嗎?
使用ZXING
我的工作代碼:
public void scan() {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.initiateScan();
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// On Scan result we get get to this part
try {
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
if (scanResult != null) {
// CODE
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
還需要將導入com.google.zxing.integration.android
包添加到我的項目中。
HTML5版本甚至可以在您的手機上運行嗎? CanIUse建議它不應該在除黑莓之外的任何移動設備上運行......但它們有時不是最新的。
無論哪種方式 - 懷疑這種新API都是一個通用的解決方案。 您能否看到在手機上使用應用程序(本機代碼)版本以及在桌面上使用支持閃存的版本。 您必須執行自己的設備嗅探:
if( user_has_flash ) {
// Load an HTML5/Flash solution
} else if( is_mobile_device) {
// defer to the native code
// zxing has a phonegap plugin - https://github.com/wildabeast/BarcodeScanner
} else {
alert("Your device does not have scanning capabilities");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.