2016-05-03 22 views
0

私たちはSony SmartEyeGlass用のアプリケーションを開発しています。まず、Android StudioとAndroidタブレットで作成しました。今、サンプルカメラエクステンションサンプルを使ってプロジェクトを統合しています。しかし、多くの詳細があります。誰かがこの問題について助けることができますか?QRコード読み取りアプリケーションをSony SmartEyeGlassに統合するにはどうすればよいですか?

答えて

0

サンプルカメラの拡張機能は、QRコードリーダーを作成するのに最適な場所です。 SampleCameraControl.javaには、cameraEventOperationという関数があります。この関数では、カメラデータをビットマップにプルダウンする方法の例が表示されます。ここでは参照用のコードは次のとおりです。

private void cameraEventOperation(CameraEvent event) { 

    if ((event.getData() != null) && ((event.getData().length) > 0)) { 
     data = event.getData(); 
     bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); 
    } 

あなたは、このデータを取得し、QRコードをスキャンするために、あなたのQRコードリーダーに送信することができます。これが役に立ったら教えてください!あなたはGoogleのZxingライブラリにビットマップを渡すために、このような機能を使用することができます

-----更新----。これを非同期タスクのようなものに入れてください:

import com.google.zxing.BarcodeFormat; 
import com.google.zxing.BinaryBitmap; 
import com.google.zxing.ChecksumException; 
import com.google.zxing.DecodeHintType; 
import com.google.zxing.FormatException; 
import com.google.zxing.LuminanceSource; 
import com.google.zxing.MultiFormatReader; 
import com.google.zxing.NotFoundException; 
import com.google.zxing.RGBLuminanceSource; 
import com.google.zxing.Reader; 
import com.google.zxing.Result; 
import com.google.zxing.common.HybridBinarizer; 
//This function sends the provided bitmap to Google Zxing 
public static String readBarcodeImage(Bitmap bMap) { 
    String contents = null; 

    int[] intArray = new int[bMap.getWidth()*bMap.getHeight()]; 
    //copy pixel data from the Bitmap into the 'intArray' array 
    bMap.getPixels(intArray, 0, bMap.getWidth(), 0, 0, bMap.getWidth(), bMap.getHeight()); 

    LuminanceSource source = new RGBLuminanceSource(bMap.getWidth(), bMap.getHeight(), intArray); 
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 

    Reader reader = new MultiFormatReader();// use this otherwise ChecksumException 
    try { 

     Hashtable<DecodeHintType,Object> hints=new Hashtable<DecodeHintType,Object>(); 
     hints.put(DecodeHintType.TRY_HARDER,Boolean.TRUE); 

     Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>(); 

     decodeFormats.add(BarcodeFormat.QR_CODE); 

     hints.put(DecodeHintType.POSSIBLE_FORMATS,decodeFormats); 

     Result result = reader.decode(bitmap, hints); 
     BarcodeFormat format = result.getBarcodeFormat(); 
     contents = result.getText() + " : "+format.toString(); 

    } catch (NotFoundException e) { e.printStackTrace(); } 
    catch (ChecksumException e) { e.printStackTrace(); } 
    catch (FormatException e) { e.printStackTrace(); } 
    return contents; 
}  
+0

私たちはZbarライブラリを使っています。 qrコードの読み取りに問題がありますか?我々はプロジェクトを完了しなかったので。 –

+0

Zbarライブラリにビットマップを送信して処理することはできますか?そうなら、あなたはSmartEyeglassでそれを使用できるはずです。あなたはどんな問題に直面しましたか? –

+0

Zbarライブラリはビットマップを使用していませんが、_data_変数型はバイト配列ですか?したがって、ビットマップではなく、バイト配列として_data_を使用しています。私たちはZxing Libraryで作業しようとしましたが、Zbarよりも複雑です。あなたがZxingの使用を手伝ってくれたら、それを続けることができます。サンプルプロジェクトやコードのように。 –

関連する問題