I deleted the duplicate thread, avoid this please. You can edit this topic to improve the subject line or the content.
↧
Re : PLEASE HELP!!! Serial Error
↧
Re : PLEASE HELP!!! Serial Error
..and check if Arduino.list()[0] is really your Ardu !! Probably its on another index of your usb-devices.
↧
↧
Re : PLEASE HELP!!! Serial Error
ok!
well I managed to get rid of the following error:
The error I am getting is: Error inside Serial.<init.()
But it still doesn't seem to be working at all
this is what I get in the black box under the code:
Dec 29 06:29:44 Mac-2.local java[9693] <Error>: CGContextGetCTM: invalid context 0x0
Dec 29 06:29:44 Mac-2.local java[9693] <Error>: CGContextSetBaseCTM: invalid context 0x0
Dec 29 06:29:44 Mac-2.local java[9693] <Error>: CGContextGetCTM: invalid context 0x0
Dec 29 06:29:44 Mac-2.local java[9693] <Error>: CGContextSetBaseCTM: invalid context 0x0
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[Ljava.lang.String;@457d21
Then the grey box appears which I should be able to "command" my arduino. But when I press 'e' nothing happens. Not sure whats up. :(
↧
Re : Video list array, out of memory
I'm sorry to insist but i don't find a solution.
I just want to intantiate a video and play different video with the element.
At this time, the first video play but stay in the memory when i call the second.
I would like to remove the first one.
Thank you for your help.
↧
No font in exported PDF
I have tried literally dozens of plotting, drawing, image processing, and page layout programs, including freeware and expensive commercial software, to do what I consider a moronically simple task. None of them do, in a simple manner, what I want to do. All I want to do is to create a circular layout with text on a circular path, some lines, and some images positioned at various points around the circle. Processing is by far the most feature-rich, simplest to script program I have found. While I'm sure I can create exactly what I want with it, the huge stumbling block is the PDF export library. I have tried for hours to get the exported PDF to contain the font that I specified in the script. No matter what font I try, I keep getting no fonts at all. The PDF displays text with some generic default font:
Here is the script:
- // The message to be displayedString message = "text along a curve";PFont f;// The radius of a circlefloat r = 100;import processing.pdf.*;void setup() {size(400, 400);String[] fontList = PFont.list();println(fontList);f = createFont("Georgia",40,true);textFont(f);// The text must be centered!textAlign(CENTER);smooth();noLoop();beginRecord(PDF, "text_along_a_curve.pdf");}void draw() {background(255);// Start in the center and draw the circletranslate(width / 2, height / 2);noFill();stroke(0);ellipse(0, 0, r*2, r*2);// We must keep track of our position along the curvefloat arclength = 0;// For every boxfor (int i = 0; i < message.length(); i++){// Instead of a constant width, we check the width of each character.char currentChar = message.charAt(i);float w = textWidth(currentChar);// Each box is centered so we move half the widtharclength += w/2;// Angle in radians is the arclength divided by the radius// Starting on the left side of the circle by adding PIfloat theta = PI + arclength / r;pushMatrix();// Polar to cartesian coordinate conversiontranslate(r*cos(theta), r*sin(theta));// Rotate the boxrotate(theta+PI/2); // rotation is offset by 90 degrees// Display the characterfill(0);text(currentChar,0,0);popMatrix();// Move halfway againarclength += w/2;}endRecord();}
I have read and reread the PDF Export page and found it not that helpful and outdated. I tried using textMode(SHAPE) as advised there and it threw an exception. There is talk about adding a .ttf file to the data directory. What data directory? "I don't see no data directory." So I am at wits' end about how to do this. I'm tired of "riddles in the dark." Being able to control the font in the output PDF is mandatory. Without this ability, the program is all but useless to me. So how do I go about doing this?
↧
↧
Re : No font in exported PDF
You create the data directory in the folder your sketch is in. However if you know where the ttf fonts are stored on your system it is easier just to enter the path (then you can pick and choose). See example below for my linux box.
- myFont = createFont("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 18);
↧
many copy calls lead to OutOfMemoryError
Hi everyone,
I'm working on a program, which slices up images and draws these slices on the screen. But no matter if I try PGraphics or PImages after a while my program simply crashes because of the OutOfMemoryError.
I have simplified my program so that is easy go trough it. But it seems like if the copy call leaves something in the memory, which is not cleaned up.
- PImage s1, s2;
- int left = 1;
- int mode = 0;
- int sliceW = 50;
- PImage pg;
- @Override
- public void setup() {
- super.setup();
- s1 = loadImage("1.jpg");
- s2 = loadImage("2.jpg");
- size(s1.width * 2,s1.height);
- pg = createImage((int)( s1.width * .5f), s1.height , RGB);
- }
- @Override
- public void draw() {
- Object[] leftG = getSlice(getPart(false, left == 1 ? s1 : s2), sliceW);
- Object[] rightG = getSlice(getPart(true, left == 1 ? s2 : s1), sliceW);
- switch (mode) {
- case 0: // simple copy
- image((PImage) leftG[0], (Integer) leftG[1], 0);
- image((PImage) rightG[0], width - (Integer) rightG[1], 0);
- break;
- }
- }
- private Object[] getSlice(PImage pg, int size) {
- PImage slice = createImage(size, pg.height, RGB);
- int x = (int) random(pg.width - size);
- slice.copy(pg, x, 0, size, pg.height, 0, 0, size, pg.height);
- return new Object[] { slice, x };
- }
- private PImage getPart(boolean left, PImage img) {
- int pgX = (int) (img.width * .5f);
- int pgY = img.height;
- if (left)
- pg.copy(img, 0, 0, pgX, pgY, 0, 0, pgX, pgY);
- else
- pg.copy(img, (int) img.width - pgX, 0, pgX, pgY, 0, 0, pgX, pgY);
- return pg;
- }
↧
Re : many copy calls lead to OutOfMemoryError
you might want to look here:
https://forum.processing.org/topic/pimage-memory-leak-example#25080000001807951
↧
Re : many copy calls lead to OutOfMemoryError
The problem is almost certainly caused by line 30
PImage slice = createImage(size, pg.height, RGB);
since this is called from the draw method it is creating a new image approximately 60 times a second and I suspect that the garbage collector is not keeping up with the program.
You need to think carefully about what you want to achieve and design an algorithm that does not invlove creating PImage every frame.
PImage slice = createImage(size, pg.height, RGB);
since this is called from the draw method it is creating a new image approximately 60 times a second and I suspect that the garbage collector is not keeping up with the program.
You need to think carefully about what you want to achieve and design an algorithm that does not invlove creating PImage every frame.
↧
↧
Re : many copy calls lead to OutOfMemoryError
hey you two
Thank you for the resonses. In this simplified version of the program I could indeed use the same PImage over and over again, not creating it 60times per second. In my actual program. the slices have different size, so I could create it with the maximum size and just "copy" the portion I need on the screen.
But the suggestes workaround in the link calling
- g.removeCache((PImage) leftG[0]);
- g.removeCache((PImage) rightG[0]);
↧
Re : No font in exported PDF
Thanks for the speedy reply. I am using the Windows version and I tried this, but it only selected the correct font for the graphics window, just as before. The PDF still contains no font information. A-r-r-r-r-g-g-g-g-g-h-h-h-h! I need a way to embed the fonts into the PDF. Does anyone know how to do that? Once I can do this, doing everything else is trivial.
↧
Error inside Serial.() when I change to Size(x,y) to P3D
I have a sketch that uses serial communication to get data from an arduino.
It also displays a circle on the screen as part of a calibration routine.
It works fine, but I decided it would look a little cooler to make the circle (ellipse) into a sphere
so I tried simply changing
size(currentWindowX, currentWindowY);
to
size(currentWindowX, currentWindowY,P3D);
so that I can use the sphere command
but just adding P3D to my size(x,y) line gave me the following error. If I get rid of the P3D it immediately works fine again???? Is there an issue with serial in P3D mode????
Error inside Serial.<init>()
Here is the error log:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] "COM6"
[1] "COM10"
Connecting to -> COM6
[0] "COM6"
[1] "COM10"
Connecting to -> COM6
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at ProcessingALIRELATIVEBETA3.setup(ProcessingALIRELATIVEBETA3.java:126)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at processing.opengl.PGL.requestDraw(PGL.java:814)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:707)
at processing.mode.java.runner.Runner.reportException(Runner.java:652)
at processing.mode.java.runner.Runner.exception(Runner.java:595)
at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367)
at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255)
at processing.mode.java.runner.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at ProcessingALIRELATIVEBETA3.setup(ProcessingALIRELATIVEBETA3.java:126)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at processing.opengl.PGL.requestDraw(PGL.java:814)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
[0] "COM6"
[1] "COM10"
Connecting to -> COM6
[0] "COM6"
[1] "COM10"
Connecting to -> COM6
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at ProcessingALIRELATIVEBETA3.setup(ProcessingALIRELATIVEBETA3.java:126)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at processing.opengl.PGL.requestDraw(PGL.java:814)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:707)
at processing.mode.java.runner.Runner.reportException(Runner.java:652)
at processing.mode.java.runner.Runner.exception(Runner.java:595)
at processing.mode.java.runner.EventThread.exceptionEvent(EventThread.java:367)
at processing.mode.java.runner.EventThread.handleEvent(EventThread.java:255)
at processing.mode.java.runner.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at ProcessingALIRELATIVEBETA3.setup(ProcessingALIRELATIVEBETA3.java:126)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.opengl.PGL$PGLListener.display(PGL.java:2472)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:548)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:533)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:280)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:904)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:822)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:543)
at processing.opengl.PGL.requestDraw(PGL.java:814)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1566)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:662)
↧
Re : No font in exported PDF
Indeed, the PDF doesn't embed the font, and the PDF reference doesn't tell it should do it...
At work, we use iText (the library generating the PDF) in Java2D mode (ie. drawing on a PDF surface instead of a classical Java2D / Swing surface) to generate a PDF, and we have a similar issue.
From my initial searches, we have to specify the directory where the fonts are, which is very annoying for a portable program (that must run on any system). In Processing, if the font is on the data folder, it might be easier. But you still have to mess with iText directly, which might be difficult from Processing (I haven't tried).
At work, we use iText (the library generating the PDF) in Java2D mode (ie. drawing on a PDF surface instead of a classical Java2D / Swing surface) to generate a PDF, and we have a similar issue.
From my initial searches, we have to specify the directory where the fonts are, which is very annoying for a portable program (that must run on any system). In Processing, if the font is on the data folder, it might be easier. But you still have to mess with iText directly, which might be difficult from Processing (I haven't tried).
↧
↧
Re : Error inside Serial.() when I change to Size(x,y) to P3D
Is size() the first line of setup()?
↧
Re : No font in exported PDF
Yeah, the PDF Export library page doesn't tell you a whole lot. It is mostly very confusing. The code examples are somewhat inconsitent and there is no real reference material. Just examples. I set out to try the example code to see which example might work. I modified the first one and, to my surprise, it worked.
I do get the selected font to display in the PDF now but it is still not embedded. I printed the output PDF to another PDF using NitroPDF and it embedded the font but it was the wrong font. So if I send it to say, a service provider, it may not print correctly. I tried different fonts but NitroPDF always embeds TrueType CourierNew, which I believe is the default font I was getting before. So problem still not entirely solved. I wonder how Acrobat is getting the font information if it is not embedded.
- import processing.pdf.*;
void setup() {
size(400, 400, PDF, "filename.pdf");
}
void draw() {
// Draw something good here
PFont f;
textAlign(CENTER);
f = createFont("Times New Roman", 40);
textFont(f, 40);
background(255);
String message = "Times New Roman text along a curve";
// The radius of a circle
float r = 100;
// Start in the center and draw the circle
translate(width / 2, height / 2);
noFill();
stroke(0);
ellipse(0, 0, r*2, r*2);
// We must keep track of our position along the curve
float arclength = 0;
// For every box
for (int i = 0; i < message.length(); i++)
{
// Instead of a constant width, we check the width of each character.
char currentChar = message.charAt(i);
float w = textWidth(currentChar);
// Each box is centered so we move half the width
arclength += w/2;
// Angle in radians is the arclength divided by the radius
// Starting on the left side of the circle by adding PI
float theta = PI + arclength / r;
pushMatrix();
// Polar to cartesian coordinate conversion
translate(r*cos(theta), r*sin(theta));
// Rotate the box
rotate(theta+PI/2); // rotation is offset by 90 degrees
// Display the character
fill(0);
text(currentChar,0,0);
popMatrix();
// Move halfway again
arclength += w/2;
}
// Exit the program
println("Finished.");
exit();
}
I do get the selected font to display in the PDF now but it is still not embedded. I printed the output PDF to another PDF using NitroPDF and it embedded the font but it was the wrong font. So if I send it to say, a service provider, it may not print correctly. I tried different fonts but NitroPDF always embeds TrueType CourierNew, which I believe is the default font I was getting before. So problem still not entirely solved. I wonder how Acrobat is getting the font information if it is not embedded.
↧
Re : Using Noise in Video Input
I'm surprised no one got to you in a year. I just came by this by chance. Nice code. Very interesting approach. If you haven't already, you should take a look at the optical flow sketch by Hidetoshi Simodaira it very neatly demonstrates how to use bit shifting to get diffs in rgb values to detect movement, flow etc. It's a trip. I spent a couple years mastering the technique. Though my thunder was all stolen by the Kinect hacking story. I do plan to release something based upon optical flow, some day.
Enjoy,
in the comments of the sketch I left a link to the version I "tweaked" to make it run under 2.0x.
Sid
↧
Re : How to port old PGraphicsOpenGL code to Processing 2 alpha - Additive Blending
also, is anyone else getting this weird image noise on the start of their sketch? seems to be a visual leftover from the last time the sketch was exited. didn't get it in 2.0b6, but i am getting it in 2.0b7...
↧
↧
Re : Long delay in Processing and Arduino Serial
Hi all,
I just encountered this Processing/Arduino bug recently. My serial code, which was working properly with earlier versions of Processing/Arduino, now suffers from huge delays. My Processing code doesn't wait for a reply from Arduino. It only checks if the serial port is open during the draw() loop. I've also tried simply writing to the serial port without checking as well.
If the USB FTDI adapter is plugged in (whether the Arduino is powered or not) the delay occurs. When I pull the FTDI or disable the Processing serial code, it runs fine.
Hmmm.
Michael
I just encountered this Processing/Arduino bug recently. My serial code, which was working properly with earlier versions of Processing/Arduino, now suffers from huge delays. My Processing code doesn't wait for a reply from Arduino. It only checks if the serial port is open during the draw() loop. I've also tried simply writing to the serial port without checking as well.
If the USB FTDI adapter is plugged in (whether the Arduino is powered or not) the delay occurs. When I pull the FTDI or disable the Processing serial code, it runs fine.
Hmmm.
Michael
↧
Re : No font in exported PDF
My understanding of PDF: basically, unless specifically told, it uses bases fonts that Acrobat always has, for portability reasons.
I used a baroque font not installed on my system: it was displayed on screen, but not when I viewed the PDF in a reader.
If I use a font present on my system (instead of in the data folder), it displayed it correctly in the sketch too, but the resulting PDF lacked it.
I think PDF can store the text as curves (if the program generating the PDF told it so), but that's good only for small texts.
I believe it can store the font name, and reuse it if present on the system, but it doesn't seem to do so with Processing generation.
And indeed, it is supposed to be able to embed the font, if its licenses allows it (some are not redistributable). But as I said, it might take some special care with iText, particularly in Java2D mode (the mode used by Processing).
I used a baroque font not installed on my system: it was displayed on screen, but not when I viewed the PDF in a reader.
If I use a font present on my system (instead of in the data folder), it displayed it correctly in the sketch too, but the resulting PDF lacked it.
I think PDF can store the text as curves (if the program generating the PDF told it so), but that's good only for small texts.
I believe it can store the font name, and reuse it if present on the system, but it doesn't seem to do so with Processing generation.
And indeed, it is supposed to be able to embed the font, if its licenses allows it (some are not redistributable). But as I said, it might take some special care with iText, particularly in Java2D mode (the mode used by Processing).
↧
Re : JavaSound Minim Errors
I'm getting these errors even with the RecordAudioInput example from the minim library. The sketch spits out these errors when I save the file. Again, recording and saving both work fine, sound fine, but the errors persist. This seems like a bug to me... I guess I could dig through the minim code to see what generates this error...
↧