Quantcast
Channel: Processing Forum
Viewing all 1768 articles
Browse latest View live

Re : Java Error in processing Mac OS X 10.7.5

$
0
0
something i posted on a different forum:

ah, the dreaded PortInUseException...

you don't want to see it, but often when working with Serial in Java/Processing, you do.

 

two tips for getting around it.

 

 

the first tip:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262317780

 

basically --

make a new folder in the root/var folder called 'lock', with super-user privileges (sudo),

set permissions on that folder to read/write for the current user.

 

apparently the PortInUseException stems from the RXTX lib trying to write a serial lock file to that folder and failing.  the above clears it up.

 

 

however, sometimes trying to run an application using Serial on system startup sporadically tosses a PortInUseException.

i'm not sure what causes this, but you can work around it with the second tip:

https://forum.processing.org/topic/recover-from-portinuseexception

 

note, this also allows, for example, the ability to have one program connected to the serial port, have another launch and fail to connect, the first closes, and the second automatically picks up the serial port as soon as it's made available by the closure of the first.


java.lang.UnsatisfiedLinkError

$
0
0
Hello,

I have some problems with new video library, i can't play videos neither capture with webcam.
Im running Processing 2.0b7 on Mac OSX Snow Leopard (10.6.8) and I launch program in 32-bit mode.

I have this error:
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Unable to load library 'gstreamer-0.10': dlopen(libgstreamer-0.10.dylib, 9): image not found
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:379)
at org.gstreamer.lowlevel.GNative.loadNativeLibrary(GNative.java:48)
at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:45)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
at org.gstreamer.Gst.<clinit>(Gst.java:97)
at codeanticode.gsvideo.GSVideo.initImpl(Unknown Source)
at codeanticode.gsvideo.GSVideo.init(Unknown Source)
at codeanticode.gsvideo.GSMovie.initGStreamer(Unknown Source)
at codeanticode.gsvideo.GSMovie.<init>(Unknown Source)
at sketch_videoCores.setVid(sketch_videoCores.java:37)
at sketch_videoCores.setup(sketch_videoCores.java:32)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:680)  

Anyone can help me?





Re : String to number, serial port?

$
0
0
Thx!

I tried this one but I got an error. So I use float now, that nearly works. But Processing converts my string to 0.0 but is has to be a bigger number, at least bigger than 100. Do you know what the problem could be?



 if(doc != null) {
    // this is the command that selects the data from the result expression
    Element data = doc.select(path).first();
    waarde = data.text();
    println(waarde); //thats the string, it prints the right number.
    println(f); //thats the float f, it prints 0.0
 




about whether they felt

$
0
0
they initiate a cascade of benefits. And this is something you could start doing today, having learned even just this much more about how love works.
stoke city vs man city live stream - man city vs stoke city live stream - manchester city vs stoke city live stream - Norwich City vs Luton Town live stream - Luton Town vs Norwich City live stream - Macclesfield vs Wigan Athletic live stream - Wigan vs Macclesfield live stream - Blackburn vs Derby Live Stream - Derby County vs Blackburn Rovers live stream - Hull City vs Barnsley live stream - Barnsley vs Hull City live stream - Middlesboro vs Aldershot live stream - Aldershot vs Middlesboro live stream - Brighton vs Arsenal live stream - Arsenal vs Brighton live stream - Brighton & Hove Albion vs Arsenal live stream - Reading vs Sheffield United live stream - Sheffield vs Reading live stream - Huddersfield vs Leicester live stream - Leicester vs Huddersfield live stream - QPR vs MK Dons Live Stream - MK Dons vs Queens Park Rangers Live Stream - Bolton vs Everton live stream - Everton vs Bolton Wanderers live stream - Man Utd vs Fulham live stream - Fulham vs Man Utd live stream - Manchester United vs Fulham live stream - Brentford vs Chelsea live stream - Chelsea vs Brentford live stream - Leeds vs tottenham live stream - tottenham hotspur vs Leeds united live stream - Oldham vs Liverpool live stream - Liverpool vs Oldham Athletic live stream - ufc on fox 6 live stream - ufc on fox 6 live - ufc on fox 6 - UFC on Fox 6 Johnson vs Dodson Live Stream - UFC on Fox 6 Johnson vs Dodson Live - UFC Dodson vs Johnson Live Stream - Johnson vs Dodson Live Stream - Dodson vs Johnson Live Stream - Demetrious Johnson vs John Dodson live stream - ufc John Dodson vs Demetrious Johnson live stream

that you ignore or suppress negativity. It simply requires that some element of kindness, empathy or appreciation be added to the mix. Compassion is the form love takes when suffering occurs.

Re : String to number, serial port?

$
0
0
"I got an error"
What kind of error? We are not psychic...

Often, when dealing with the serial library, data is prefixed or postfixed with spaces.
Try:
int number = int(trim(string));

[minim?] Generate Audio Wave

$
0
0
Hello,
With my program, I can generate a wave with a lots of point (x,y) like this :

 
But I need generate an audio wave, with minim or other library.
How i can do this?
I need extend an ddf.minim.signals.Oscillator class? Or isn't possible?
Thx

Re : String to number, serial port?

$
0
0
The problem stays the same, I get a "0" as number (but it should be 224).
The error I get if I convert the string to a normal integer is "cannot convert int[] to int".

This is the whole code:


 import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

Serial myPort;

String waarde = "0";

int number = int(trim(waarde));

// this is the webpage containing the relevant data
String url = "http://iphone.bjair.info/m/beijing/mobile";
// this is the path in the resulting expression that leads to the data of interest
String path = "#number h1";
int refresh = 20; // sec
int walkingTime = 6; // min

void setup() {
  size(200, 200);
  background(0);
 
 
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[0], 9600);
 
  noStroke();
 
  smooth();
 
  frameRate(1/(float)refresh);
 
  draw();
}

void draw() {
 
 
  // the data extraction is done in the function getTimeUntilNextBus()
  Integer timeUntilBus = getTimeUntilNextBus();
 
  // the rest here is only to calculate the leaving time that is needed to
  // catch the bus
  if(timeUntilBus != null) {
    //int diff = timeUntilBus - walkingTime;
    println("Time until leave: "+timeUntilBus);
  }
    /*
   
}

Integer getTimeUntilNextBus() {
  // doc contains the result from the website request
  Document doc;
  // this is the actual request, including error handling, simply copy this
  try {
    doc = Jsoup.connect(url).get();
  } catch(IOException e) { // Connection error
    e.printStackTrace();
    doc = null;
  } catch(IllegalArgumentException e) {
    println("Bad URL!");
    doc = null;
  }
 
  if(doc != null) {
    // this is the command that selects the data from the result expression
    Element data = doc.select(path).first();
    waarde = data.text();
    println(waarde);     //here it gives the number in the string which is around 200.
    println(number);  //here it should give the same number as an integer.
 
    
    while(number > 100){
    myPort.write(1);
    
  }
 
   
    return 4;
   
  }

 




Re : String to number, serial port?

$
0
0
I don't understand. Where you show it, it should not show this error, and it is quite useless, being static (done once).
Try moving the line defining number between the two println().

Exporting to dxf or pdf

$
0
0
I am very new at this and can't seem to export my file to dxf or pdf. I know im supposed to import the pdf or dxf code at the beginning of the code but the rest of it has me stumped. I would really appreciate any help with this. 



  1. ArrayList history = new ArrayList();
  2. float distthresh = 60;

  3. void setup(){
  4.   size(900,600);
  5.   background(255);
  6.   stroke(0,50);
  7.   smooth();
  8. }


  9. void draw(){
  10.   
  11. }

  12. void mouseDragged(){

  13.   PVector d = new PVector(mouseX,mouseY,0);
  14.   history.add(0,d);
  15.   
  16.   for (int p=0; p<history.size(); p++){
  17.     PVector v = (PVector) history.get(p);
  18.     float joinchance = p/history.size() + d.dist(v)/distthresh;
  19.     if (joinchance < random(0.4))  line(d.x,d.y,v.x,v.y);
  20.   }
  21. }

  22. void keyPressed(){
  23.   if (key == ' ') {
  24.     background(255);
  25.     history.clear();
  26.   }
  27. }

Re : Exporting to dxf or pdf

Re : Exporting to dxf or pdf

$
0
0
I typed the first step in as import pdf or "or dxf" as the tutorials have shown. I dont understand where I should be placing the rest of the code.

I simply want to make a sketch and export it. I wish it was already built in to processing.

Thanks PhiLho. Ill check out the link and give it another shot. Iv been spending to much time on this and Im really just starting out on it. I get confused as to where in the code I should be pasting in the export commands. 

Re : Exporting to dxf or pdf

$
0
0
I actually spent allot of time on the link you listed.

I know Import processing goes at the beginning of the script.

  1. import processing. pdf.*;
  2. ArrayList history = new ArrayList();
  3. float distthresh = 60;

  4. void setup(){
  5.   size(900,600);
  6.   background(255);
  7.   stroke(0,50);
  8.   smooth();
  9. }


  10. void draw(){
  11.   
  12. }

  13. void mouseDragged(){

  14.   PVector d = new PVector(mouseX,mouseY,0);
  15.   history.add(0,d);
  16.   
  17.   for (int p=0; p<history.size(); p++){
  18.     PVector v = (PVector) history.get(p);
  19.     float joinchance = p/history.size() + d.dist(v)/distthresh;
  20.     if (joinchance < random(0.4))  line(d.x,d.y,v.x,v.y);
  21.   }
  22. }

  23. void keyPressed(){
  24.   if (key == ' ') {
  25.     background(255);
  26.     history.clear();
  27.   }
  28. }
Then I get errors when I type in the rest of the code below when I run the file. It does not export.
void setup() {
  size(400, 400, PDF, "filename.pdf");
}

void draw() {
  // Draw something good here
  line(0, 0, width/2, height);

  // Exit the program 
  println("Finished.");
  exit();
}

NyAR4psg problem

$
0
0
hi everybody, i have Recently download Processing 2.0b7 and some libraries and i'm trying to do something about augmented reality..when i "import jp.nyatla.nyar4psg.*;" and i declare "MultiMarker nya;" it tells me that "cannot find a class or type named MultiMarker"..i thougth that this class was already defined in NyAR4psg library..what should i do? thanks

Re : String to number, serial port?

Re : Exporting to dxf or pdf

$
0
0
You must not add a second setup() or draw(), you have to merge those given in the example with yours.
For example, replace your size() with the one given, just providing your dimensions.

Re : [minim?] Generate Audio Wave

$
0
0
Can I use an extended class of Oscillator like this :

  1. Class MyWave extends Oscillator
  2. {
  3. /* list of amplitudes point : every point is automatically  insert in this array when user create dot(x,y) */
  4. public float[] s = {0, 0.12f, 0.21f, 0.26f, 0.4f, 0.51f,0.68f, 0.89f, 1f, 0.88f, 0.66f , 0.39f , 0.14f , -0.09f , -0.36f , -0.52f , -0.68f ,
  5. -0.77f , -0.79f , -0.7f , -0.44f , -0.11f , 0.19f  , 0.39f  , 0.54f  , 0.62f  , 0.69f  , 0.74f  , 0.56f  , 0.15f  , 0   };
  6.  
  7.     public  MyWave (float frequency, float amplitude, float sampleRate)
  8.     {
  9.         super (frequency, amplitude, simpleRate);
  10.     }
  11.    
  12.     public void generate(float[] signal)
  13.     {
  14.         for (int i = 0; i < s.size() ; i++)
  15.         {
  16.             signal [ i ] = s [i];
  17.         }
  18.     }
  19.     //MONO
  20.     public void generate(float[] sigLeft, float [] sigRight)
  21.     {
  22.         generate(sigLeft);        generate(sigRight);
  23.     }
  24. }

Re : [minim?] Generate Audio Wave

$
0
0
Isn't possible to redefine generate() method

Blend video cam with background image

$
0
0
I must have missed something...


  1. import processing.opengl.*;
  2. import codeanticode.glgraphics.*;
  3. import codeanticode.gsvideo.*;
  4. GSCapture cam;
  5. GLTexture bottomLayer, topLayer, resultLayer;
  6. GLTextureFilter blendFilter;
  7. ScalarParam opacity;

  8. class ScalarParam {
  9.   float value;
  10.   float minValue;
  11.   float maxValue;
  12.   float step;
  13.   ScalarParam(float v,float mn, float mx, float s) {
  14.     value = v;
  15.     minValue = mn;
  16.     maxValue = mx;
  17.     step = s;
  18.   }
  19.   void Increment() {
  20.     value += step;
  21.     if (value > maxValue) value=maxValue;
  22.   }
  23.   void Decrement() {
  24.     value -= step;
  25.     if (value < minValue) value=minValue;
  26.   }
  27. }

  28. void setup()
  29. {
  30.   size(640, 480, GLConstants.GLGRAPHICS);
  31.   cam = new GSCapture(this, 640, 480);
  32.   blendFilter = new GLTextureFilter(this, "BlendDifference.xml");
  33.   opacity = new ScalarParam(1.0,0.0,1.0,0.01);
  34.   bottomLayer = new GLTexture(this, "background.jpg");
  35.   topLayer = new GLTexture(this);
  36.   cam.setPixelDest(topLayer);    
  37.   cam.start();
  38.   resultLayer = new GLTexture(this, topLayer.width,topLayer.height);
  39. }

  40. void draw()
  41. {
  42.     blendFilter.setParameterValue("Opacity", opacity.value);
  43.     blendFilter.apply(new GLTexture[] {bottomLayer, topLayer}, resultLayer);
  44.     resultLayer.render(0, 0);
  45.     //image(resultLayer, 0, 0);
  46. }

  47. void keyPressed()
  48. {
  49.   if (key == CODED) {
  50.     if (keyCode == UP) opacity.Increment();
  51.     else if (keyCode == DOWN) opacity.Decrement();
  52.   }
  53. }

  54. void captureEvent(GSCapture cam) {
  55.   cam.read();
  56. }

Re : No font in exported PDF

$
0
0
Thanks, but the key to the 'solution' to this apparent non-issue was your mentioning that the fonts are probably pre-rendered. That's an option I never encountered, frankly, but it is probably the best one possible, at least if it is done properly. Usually there are three options for fonts in a PDF:

  • Fonts Substitution
    Acrobat renders—on the fly—a “faux font” representation using typeface information included in the PDF.
  • Fonts Embedding
    All typefaces necessary to render a font are embedded in the file.
  • Fonts Subsetting
    Only the typeface characters necessary to render the file are embedded. Typefaces may have thousands of characters. Only embedding the actual characters used can reduce file size.
Interestingly enough, Adobe complains about the requirement of completely embedded fonts and adds:
There is no technical advantage to completely embedding fonts. There is nothing you can do with a PDF that has its fonts completely embedded that you cannot do with a subset file.
and:
Only older Type 1 and TrueType fonts can be completely embedded by Acrobat.

They go on to say that OpenType fonts are superior and that

Except for a few rare cases, Acrobat can only subset OpenType fonts.

I guess complete embedding would not be necessary, except in the case where someone might use the horrible Acrobat Pro text touch-up tool to alter some text. But why would a service provider do that? And yet I read at many online providers that complete embedding is highly recommended. Overkill for sure.

One more thing.
In an effort to solve a more serious problem--Transparency and resolution problems with exported PDF, I read, with some amusement, in the PGraphicsPDF source code, that it is currently using iText 2.1.7 (latest version is 5.3.5), apparently to reduce sketch loading time by a few seconds whenever the code was written , which instantiates an iText  PdfContentByte object and then uses a method, createGraphics, that was deprecated even back then, for text operations. Oddly enough, according to the documentation for this ancient version of iText, this method and other overloaded versions of it
Gets a Graphics2D to write on. The graphics are translated to PDF commands as shapes. No PDF fonts will appear.
So there you have it, straight from the horse’s mouth--yet a fourth PDF font option. Go figure. The Adobe people must still be reeling from this unexpected twist. LOL.

Sorry if I bored you but I like to be as thorough as possible. I’m hoping that this might provide some impetus toward updating the PDF library. Please?

 

 

 

 

 

Re : Blend video cam with background image

$
0
0
I have tried to add in draw function this line

  1. topLayer.putPixelsIntoTexture();

but it doesn't help...

Viewing all 1768 articles
Browse latest View live