I have a CSV file with a very basic setup. It's a 4 column, 3 row setup. Like this:
A, 1, 2, 3
B, 4, 5, 6
C 7, 8, 9
I want to simply expand it to 6 columns, then write it out as a CSV again. I don't care what the values are at this point for the expanded cells, I'm just curious why everything is coming out as null
// the following adds functionality to che-wei wang's CSV import sketch // lines.length is the number of rows, wheras csvWidth is the column count
String lines[] = loadStrings("db.csv"); String [][] csv; int csvWidth=0;
//calculate max width of csv file for (int i=0; i < lines.length; i++) { String [] chars=split(lines[i], ','); if (chars.length>csvWidth) { csvWidth=chars.length + 2; // here we expand by 2 columns } }
//create csv array based on # of rows and columns in csv file csv = new String [lines.length][csvWidth];
//parse values into 2d array for (int i=0; i < lines.length; i++) { String [] temp = new String [lines.length]; temp= split(lines[i], ','); for (int j=0; j < temp.length; j++) { csv[i][j]=temp[j]; } }
csv[2][4] = "test";
// now save // collapse to a single dimension array String[] linesOut = new String[csvWidth * lines.length]; for (int i = 0; i < lines.length; i++) { for (int z = 0; z < csvWidth; z++) { linesOut[i] = csv[i][z]; println(linesOut[i]); } } println(linesOut); saveStrings("out.csv", linesOut);
//test println(lines.length);
When I println(linesOut) I get [0] null [1] null .. and so on, but if I println(linesOut[0]) I get "A"
Goes without saying that the saved file is also null null null null...
Here's the deal. I have a CSV file with 5 columns of data. I want to add a 6th and 7th column of data to each one after running some stuff in Processing to generate those numbers, then save it.
I'm opening up a binary file, converting to 1's and 0's, then outputting as a text file. Problem is, it gives me a line break after each byte, bummer! Any way around this?
// Open a file and read its binary data byte b[] = loadBytes("whatever.dmg");
String[] lines = new String[b.length]; for (int i = 0; i < b.length; i++) { lines[i] = binary(b[i]); }
saveStrings("lines.txt", lines); exit(); // Stop the program
I'd love it if I could then superimpose this on a map... hmm
EDIT: Now with
more code!
// get request for ip info, save to string String[] info = loadStrings("http://freegeoip.net/csv");
// let's break up that string into useful stuff eh? String[] list = split(info[0], ',');
// Here is the formatting for list: // 0: IP address // 1: Country abbreviation // 2: Country // 3: Region abbreviation // 4: Region // 5: City // 6: Zip // 7: Latitude // 8: Longitude // 9: No idea //10: Area Code
// To get this on a Google Map or something, I probably just need 7 and 8.
println(list);
Ok so here's a question: What's a way I could go about super imposing this onto a map? What I'd like to be able to do is draw a line from my location to a friend, for example, in Europe. This could either be with a simple image that I could calibrate to be set up for decent coord matching, or maybe I could interact with a Google Map.
I'm teaching a couple Processing courses and am supposed to give a demonstration at the student-faculty get together. I'm curious if any of you have ideas about sketches that are particularly interesting to look at right off the bat. I'm especially interested in fun interaction and live video processing (they are mostly filmmakers).
When I try to run the sendImage example from the lib on the latest release of Processing 2:
Syphon library for Processing Beta2-r7
lights() is not available with this renderer.
rotateX() can only be used with a renderer that supports 3D, such as P3D or OPENGL.
rotateY() can only be used with a renderer that supports 3D, such as P3D or OPENGL.
box() is not available with this renderer.
Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: tried to access method processing.opengl.PGraphicsOpenGL.getTexture(Lprocessing/core/PImage;)Lprocessing/opengl/Texture; from class codeanticode.syphon.SyphonServer
at codeanticode.syphon.SyphonServer.sendImage(Unknown Source)
at SendFrames.draw(SendFrames.java:42)
at processing.core.PApplet.handleDraw(PApplet.java:2270)
at processing.opengl.PGL$PGLListener.display(PGL.java:2643)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:576)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:561)
at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1024)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:899)
at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
at javax.media.opengl.Threading.invoke(Threading.java:193)
at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:537)
at javax.media.opengl.awt.GLCanvas.update(GLCanvas.java:719)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:267)
at sun.awt.RepaintArea.paint(RepaintArea.java:233)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:263)
at java.awt.Component.dispatchEventImpl(Component.java:4820)
at java.awt.Component.dispatchEvent(Component.java:4572)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:710)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:669)
at java.awt.EventQueue$2.run(EventQueue.java:667)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:683)
at java.awt.EventQueue$3.run(EventQueue.java:681)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:680)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Already called beginDraw()
java.lang.RuntimeException: java.lang.IllegalAccessError: tried to access method processing.opengl.PGraphicsOpenGL.getTexture(Lprocessing/core/PImage;)Lprocessing/opengl/Texture; from class codeanticode.syphon.SyphonServer
at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:100)
at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205)
at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
at javax.media.opengl.Threading.invoke(Threading.java:191)
at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
at processing.opengl.PGL.requestDraw(PGL.java:1155)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1602)
at processing.core.PApplet.run(PApplet.java:2141)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalAccessError: tried to access method processing.opengl.PGraphicsOpenGL.getTexture(Lprocessing/core/PImage;)Lprocessing/opengl/Texture; from class codeanticode.syphon.SyphonServer
at codeanticode.syphon.SyphonServer.sendImage(Unknown Source)
at SendFrames.draw(SendFrames.java:42)
at processing.core.PApplet.handleDraw(PApplet.java:2270)
at processing.opengl.PGL$PGLListener.display(PGL.java:2643)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:576)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:561)
at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1024)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:899)
at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:708)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:669)
at java.awt.EventQueue$2.run(EventQueue.java:667)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:678)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
It works fine if I remove server.sendImage(canvas) from the code. Any thoughts?
video = new Capture(this, width, height); video.start();
backgroundImg = new PImage(width, height); movementImg = new PImage(width, height); // Initialises the PImage that holds the movement image
background(0);
}
void draw() { // get dat first frame if ya need it if (video.available() && first_frame == true) { video.read(); backgroundImg = video; first_frame = false; }
image(backgroundImg, 0, 0 ); // Draws the camera image to the screen
even if I make zero modifications, by virtue of opening and saving as text, it produces a corrupt Jpg. Doing this with a standard text editor works, so it's gotta be possible with relative ease.
I'd like to have two windows, which would run on two monitors. The big monitor (projected) would be a nice clean full screen render surface, the other would be to input text that is to be displayed on my big screen. What's the best way to go about this?
Doing a public projection and I'm curious if it's possible to create a drip effect from and SVG. Would it be easier to just do an arbitrary drip effect under/on top of the SVG than to extract some vector data and do it that way? Are there libraries available for this by chance?
So I basically have a system set up that's reading serial data, temperature and humidity, which looks like "65.25 99.1" coming in. I want to transform that to
"Temperature: 65.25 F <br>
Humidity: 99.1 %'
<br> is a new line in HTML, btw. I've tried a few things.. it doesn't seem to let me access each word in the array separately. What do I do?
http://www.pattenstudio.com/projects/sensetable/ This project is very interesting in that it doesn't use CV to keep track of the "pucks" but radio transmission of some kind. What kind of sensors would one need to start developing something similar? Any opinions on the pros and cons of CV vs this kind of setup?
Thx
Hello,
I'm wondering if there is a sort (or something) function that will compare a given value to all values in a matrix.
What I am trying to do:
I have a matrix of lines that make up the volume of a cube in 3d space. The lines are generated randomly, so I have a class StringLine that has X and Z values, and Y determines what portion of the string will be "lit up." So now I want to add a ball to this environment, in a sort of pong match, so it has float values to determine its location, but the strings are placed randomly, so I just want to find the closest one and light it up.
So if the cube is 1 x 1 x 1, and the ball is at .2 on X and .5 on Z (half way into the cube, .2 from the left) but the closest string is actually at .22 .48 or something, I want that string to get the center of the ball, and so forth. What is the best way of going about this? Does my explanation make sense?
Thanks.
So essentially what I am trying to do is let's say you have an ellipse in the center of the screen, and it's value/radius is 100. I want to visualize data in such a way that you can input a value into this ellipse, let's say you select a value of 20. I want that value to "fill" part of the ellipse, as if it were water accumulating at the bottom of the circle. So I can think of two ways that this might be accomplished.. one is by using arcs and the other using textures. I would like to be able to add multiple values to this ellipse, each represented by a different color.
So this is a very simple sketch, but when you use the mouse to rotate the circle it doesn't seem to rotate exactly on the Y axis. Run the sketch and you'll see what I mean.
so the numbers stored in pixels[] are colors, I get that, but they are such weird numbers. What's up with that? Anyway to convert this to a more readable format other than bit shifting?
hey all,
so openCV has those really nifty functions built into the API like absDiff or whatever it is, and I'm wondering if there is a Kinect library that does the same?
All the frame subtraction I've come across is for RGB but really all I need is greyscale. I have a few questions:
is it possible to invoke the loadPixels() on just an image, or does it capture the entire window? once I have my pixels[] array, can I convert that back into a PImage?
and in general, what is the fastest/easiest way to do frame sub on a PImage or with Kinect?
Is there anyway to generate a midi sound from within processing? Like if I wanted to make a virtual keyboard, for example, in which you press the keys and the sound comes out.
Thanks!