I wrote this event triggered picture saving sketch. I want to put the pics in the tenser flow later.
I have 2 cameras connected in the same time and after I bring the video in, I turn it into grayscale right away with the filter.
Then, when I get the right signal from the arduino, I save the two pics in sequential order.
The video shows as grayscale, but the pics are saved as color.
What to do?
Thanks a lot , here is the code:
BTW, is there a way to run tenser flow in Processing?
// size(1900, 1000, JAVA2D);
size(1300, 610);
createGUI();
customGUI();
streamer = new AP_Sync(this, "COM5", 115200);
String[] cameras = Capture.list();
if (cameras == null) {
println("Failed to retrieve the list of available cameras, will try the default...");
video = new Capture(this, 640, 480);
video2 = new Capture(this, 640, 480);
}
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else
{
println("Available cameras:");
printArray(cameras);
video = new Capture(this, "name=USB Camera,size=640x480,fps=30");
video2 = new Capture(this, "name=USB Camera-Video2,size=640x480,fps=30");
video.start();
video2.start();
}
font = loadFont("AgencyFB-Bold-200.vlw");
frameRate (30);
}
void captureEvent(Capture video) {
video.read();
video2.read();
}
void draw() {
background(bk);
video.loadPixels();
video2.loadPixels();
image(video, 0, 0);
image(video2, 660, 0);
filter(GRAY);
PImage videoCropped = video.get();
PImage video2Cropped = video2.get();
// filter(THRESHOLD,.1);
stroke(w);
strokeWeight(3);
line (320, 0, 320, 500);
//println(Aquire+" is Aquire");
textFont(font, 25);
fill(w);
if (Ready ==1)// comes from the Arduino
{
Aquire= false;
delay (100);
Seq=Seq +1;
String Next = str(Seq);
String VideoFileNameFinalV1 = "GoodPotsV1/"+ Next+"_GoodPotsV1.png";
String VideoFileNameFinalV2 = "GoodPotsV2/"+ Next+"_GoodPotsV2.png";
videoCropped.save(VideoFileNameFinalV1);
video2Cropped.save(VideoFileNameFinalV2);
delay (500);
text("POT PRESENT", 10, 790);
}
else
{ // Aquire= true;
text("POT ABSENT", 10, 790);
}
text("VIDEO 1 ", 10, 510 );
text("VIDEO 2 ", 660, 510 );
/*
*/
}// end of draw