The arduino with the camera sent me information about the image, and I wrote a processing program to display it with point(), but after I completely display the image, if I display the image again, the image I took last time will remain.
In the code below, before starting to display the image, we create a gradation image, display it, and then display the image we took.
I also initialized using background(0); but
background(255); and
background(0);
The color of the image to be displayed will also be affected by the background color to be initialized as shown in . If the background color is reddish, the image will be reddish, and if the background color is bluish, the image will be bluish. Why does this happen when it shouldn't affect every pixel?
import processing.serial.*;
Serial port;
int start = 0;
inth = 240;
intw = 320;
int count = 0;
int pixel = 0;
void setup()
{
size (320,240);
port = new Serial(this, "COM4", 1000000);
frameRate (300000);
stroke(0);
rectMode (CENTER);
}
void keyPressed() {
port.write(key);
}
void draw()
{
// Once you receive data from the serial port,
if(port.available()>0){
intc = port.read();
if(c==118){//v
start = 1;
println("start");
// background(255);
// Check gradation background color
for(inti=0;i<h;i++){
for(int j=0;j<w;j++){
stroke(color(i,j,j));
point(j, i);
}
}
} else if(c==122) {//z
println("end");
println("count");
println(count);
count = 0;
start = 0;
} else if (start>0) {
count = count +1;
Strings = str(char(c));
intf = unhex(s);
// println(hex(f));
if((count)%4==1)pixel+=f*4096;
if((count)%4==2)pixel+=f*256;
if((count)%4==3)pixel+=f*16;
if((count)%4==0){
pixel+=f;
int R = 0;
int G = 0;
int B = 0;
if(pixel%2==1)G+=32;
if((pixel>>1)%2==1)G+=65;
if((pixel>>2)%2==1)G+=130;
if((pixel>>3)%2==1)R+=8;
if((pixel>>4)%2==1)R+=16;
if((pixel>>5)%2==1)R+=33;
if((pixel>>6)%2==1)R+=66;
if((pixel>>7)%2==1)R+=132;
if((pixel>>8)%2==1)B+=8;
if((pixel>>9)%2==1)B+=16;
if((pixel>>10)%2==1)B+=33;
if((pixel>>11)%2==1)B+=66;
if((pixel>>12)%2==1)B+=132;
if((pixel>>13)%2==1)G+=4;
if((pixel>>14)%2==1)G+=8;
if((pixel>>15)%2==1)G+=16;
intx = 16;
stroke(color(R,G,B);
point((count-132)/4%320,(count-132)/4/320);
pixel = 0;
}
}
}
}
I don't have an arduino at the moment, so I can't check it, but
Isn't this phenomenon a feature (?) of processing regardless of arduino?
void draw(){
background(0);
hereinafter abbreviated
Try putting the instructions to clear the background in draw().
The previous state is cleared.
For your information
Introduction to Processing 6
It is also stated in that the previous drawing remains.
Or, instead of putting it in the beginning of draw, depending on what you want to do
background(0);
You may need to put in the right place.
If you display the image again, the afterimage of the previous image will remain.
If you didn't take any action to erase it, there's no element to disappear.Drawing a computer is not like preparing a new piece of paper, but rather drawing a new piece of paper from the top on the previously written piece of paper.I think it would be better if the previous picture remained except for the part that was re-drawn from above.
I also initialized using background(0);
I think initialization is a little different, but did you still have images after running background()? I don't think so."It is not clearly stated, but since then, I think it is a completely different description from ""remaining afterimage"", but is it correct?"
If the background color is reddish, the image will be reddish, and if the background color is bluish, the image will be bluish. It shouldn't have any effect if it's painted out one pixel at a time
I don't think so.The human eye is rather loose.The red and blue parts of the strong color drag my senses, and the image part looks red/blue, isn't it just visible?
Why don't you record images using PC screen capture and compare each capture at the pixel level when blue or red (or black or white)?
© 2024 OneMinuteCode. All rights reserved.