How to recieve hex data JPEG camera from Arduino and show image in Processing

import processing.serial.*;
Serial myPort;
String inBuffer;
//String txtImg [];
void setup(){
   
  myPort = new Serial(this, "COM9", 115200);
  myPort.bufferUntil('\n');
  
}

void draw(){
  
}

void keyPressed()
{
  if ((key == 'b') | (key == 'B'))
  {
    myPort.write(98);
 }
}

void serialEvent(Serial p)
{
  inBuffer = p.readString();  // store serial port buffer in global var inBuffer
  //print(inBuffer);  // show the line of serial input
  
  String[] txt = split(inBuffer,' ');
  byte[] sampleBytes = new byte[txt.length];
 for ( int i=0;i<txt.length;i++){
  sampleBytes[i]=byte(unhex(txt[i]));
  print(sampleBytes);
 saveBytes("image1.jpg", sampleBytes);
 }
}

It’s error cant convert Sring to Sring[]*****

1 Like