2017-03-08 5 views
0

ヘルプ、私は迷ってしまった!イメージを取得Arduinoから指紋stm32f205

私はArduino Uno R3に接続し、RXTXCommライブラリを使ってJava経由で通信したWaveshareの指紋stm32f205を使用しています。

私は各リクエストのバイトをArduinoに渡すことができましたが、欠点は、トレースのイメージのバイトを受け取ったときにBitmapまたはJPGとして保存できないことです。

データをバイトとして送信する前に、符号なしの整数(0〜255)が表示されていました。

バイトは、バイトの配列と別の整数の配列に格納されます。

バイトをイメージに変換するためにどのアルゴリズムを使用すべきですか教えてください。

このimageは、画像データの送信方法を示します。 enter image description here

答えて

0

RGBの8ビットグレーの配列に変換するには:あなたはRGB配列がBufferedImageに変換することができた後

int[] greyArraySource = ...; 

int[] rgbArray = new int[greyArraySource.length]; 
for(int i=0; i<greyArraySource.length; i++) { 
    int color = (int)aImageData[i]; 
    if(color < 0) 
    { 
     color = 256 + color; 
    } 
    rgbArray[i] = Color.rgb(color,color,color); 
} 

を:

// Initialize BufferedImage 
int width = ...; 
int height = ...; 
BufferedImage bufferedImage = new BufferedImage(width, height, 
    BufferedImage.TYPE_INT_RGB); 

// Set RGB array to the BufferedImage 
BufferedImage.setRGB(0,0,BufferedImage.getWidth(), 
    BufferedImage.getHeight(),rgbArray, 0, BufferedImage.getWidth()); 

JPGにBuffuredImageを変換します

File outputfile = new File("image.jpg"); 
ImageIO.write(bufferedImage, "jpg", outputfile); 

あなたの画像は4ビットで表示されるようです変換を変更する必要があります。配列の値を投稿すると、おそらく私はチェックできます。

+0

@Geekarはあなたが正常に画像を得る持っていますか? – LaurentY

0

@LaurentYに返信いただきありがとうございます。画像は4ビットです。 あなたが提供したコードを少し修正して適用してください。

imgS = cadena.split(","); 
int[] rgbArray = new int[imgS.length]; 
      for(int i=0; i<imgS.length; i++) { 
       int color = Integer.parseInt(imgS[i]); 
       if(color < 0) 
       { 
        color = 256 + color; 
       } 
       rgbArray[i] = new Color(color, color, color).getRGB(); 
      } 
      BufferedImage bufferedImage = new BufferedImage(biWidth, biHeight, 
        BufferedImage.TYPE_INT_RGB); 

      // Set RGB array to the BufferedImage 
      bufferedImage.setRGB(0,0,bufferedImage.getWidth(), bufferedImage.getHeight(),rgbArray, 0, bufferedImage.getWidth()); 
      File outputfile = new File("D:\\finger.jpg"); 
      ImageIO.write(bufferedImage, "jpg", outputfile); 
     } catch (IOException ex) { 
      Logger.getLogger(LeerArduino.class.getName()).log(Level.SEVERE, null, ex); 
     } 

結果はImageです。

ここでは、配列の値をtxtのままにしますFile。各値はコンマで区切られます。

あなたに会いましょう!

-1

私は最近この指紋モジュールを使用しました。 MATLAB上の私のプロジェクトは、私は指紋画像を抽出することができます。シリアルポートターミナルプログラム(iはCoolTermを使用)で、テキストファイルで取り込まれた16進数形式のイメージデータは、スペースのみで区切られています。 あなたのイメージは140x140/2バイトではありません。あなたのtxtファイルをmatlabでスキャンすると、124x148/2 = 9176バイトになります。さらに、この数値を上下のニブル(4ビット)に分割することもできます。まず、これらのuint8を8ビットバイトまたは2桁の16進数に変換する必要があります。私のJavaの知識は十分ではありませんが、MATLABで:

fileID = fopen('Value.txt','r'); A=textscan(fileID,'%u8','Delimiter',','); %text file to matrix YI=reshape(A{1,1},[62,148]); % image reshaped imshow(YI');

このコードとあなたのValue.txtファイルでは、このfinger image

関連する問題