processing

SimpleOpenNI Record and Replay User Tracking Data

倾然丶 夕夏残阳落幕 提交于 2019-12-04 13:33:48
问题 I am able to use SimpleOpenNI to successfully record and replay depth and rgb recordings (.oni files). I would also like to be able to track users from recorded files, in other words be able to easily extract sillhouettes of people from a depth image. This is easy to do with SimpleOpenNI when running connected to a sensor, by calling enableUser() in the setup() method, and then obtaining userMap() or userImage() during draw calls. The motivation for this is to be able to easily segment out a

How to run Processing applications from the terminal

放肆的年华 提交于 2019-12-04 11:22:53
I'm currently using Processing for a small project, however I'm not liking the text-editor that comes with it. I use vim to write all of my code. I've found where the .pde file are and I've been editing them from vim and then I'm reopening them and running them (it takes a lot to reload the script and running it). That's why I want a solution where I can compile everything from the terminal. On close inspection I've found the processing-java file that supposedly compiles and runs a sketch. However whatever arguments I supply it, it keeps on spitting the help page. This is an example on how I'm

how to calculate the dist() from mouseX, mouseY to a rectangle in Processing

被刻印的时光 ゝ 提交于 2019-12-04 08:16:00
If it was the dist to a point it would be dist(mouseX, mouseY, x, y) for point(x,y) but how can I calculate dist() from the mouse's current position to rectMode(CORNERS); rect(x1,y2,x2,y2); Thanks Something like this should do it: float distrect(float x, float y, float x1, float y1, float x2, float y2){ float dx1 = x - x1; float dx2 = x - x2; float dy1 = y - y1; float dy2 = y - y2; if (dx1*dx2 < 0) { // x is between x1 and x2 if (dy1*dy2 < 0) { // (x,y) is inside the rectangle return min(min(abs(dx1), abs(dx2)),min(abs(dy1),abs(dy2))); } return min(abs(dy1),abs(dy2)); } if (dy1*dy2 < 0) { // y

Using an if statement within loops? - Processing

旧时模样 提交于 2019-12-04 07:02:44
问题 Lets say I have to use an if statement within a for loop and the for loop fires at a certain condition and the if statement only fires when the for loop has reached a certain stage. For example, the condition is a counter that counts up when a certain thing happens such as a ball falling down the screen. circles are drawn one by one everytime the ball crosses the screen. When the circles in the first row have reached the end of the screen, the circles start appearing on the second row below

How to convert pixels to gray scale?

霸气de小男生 提交于 2019-12-04 04:24:39
Ok, I am using Processing which allows me to access pixels of any image as int[] . What I now want to do is to convert the image to gray-scale. Each pixel has a structure as shown below: ...........PIXEL............ [red | green | blue | alpha] <-8--><--8---><--8--><--8--> Now, what transformations do I need to apply to individual RGB values to make the image gray-scale ?? What I mean is, how much do I add / subtract to make the image gray-scale ? Update I found a few methods here: http://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/ For each pixel, the value for the

Playing multiple videos in processing

蓝咒 提交于 2019-12-04 02:32:16
问题 I am working with processing and would like to play multiple videos one after the other automatically. Below is my current code but when the first video finishes playing the next video does not automatically begin. hope you can help. import processing.video.*; Movie myMovie1, myMovie2, myMovie3, myMovie4, myMovie5, myMovie6; boolean playMovie1=true; boolean playMovie2=false; boolean playMovie3=false; boolean playMovie4=false; boolean playMovie5=false; boolean playMovie6=false; void setup(){

Transform from relative to world space in Processing

匆匆过客 提交于 2019-12-03 22:07:23
What is a good way of transforming a local relative point, into the world (screen) space in Processing? For example, take the Flocking example that comes with the Processing PDE. How would I implement a relativeToWorld method and a worldToRelative method in the Boid class. These methods would take into consideration, all the transforms done in the render method. I was thinking I would want to transform PVector objects, so the method signatures might look something like: PVector relativeToWorld(PVector relative) { // Take a relative PVector and return a world PVector. } PVector worldToRelative

How to export an image or PDF from a Processing Javascript mode sketch?

心不动则不痛 提交于 2019-12-03 21:51:38
Processing 2 'Java mode', previously known as 'standard mode', has some easy options to output graphics like saveFrame() or the PDF Export Library . Now, the web friendly 'Javascript mode' (based on the Processing.js project) allows one to host a sketch easily (by way of HTML canvas), but I can't find much about file output when using it. How can I make my 'Javascript mode' sketch save SVG or PDF? (Unfortunatly I don't know Javascript, so the answer might not assume knowledge of it) Adam Tindale The javascript mode of Processing utilizes HTML5 Canvas by default for rendering. You can use the

Image Processing - Otsu's method

最后都变了- 提交于 2019-12-03 21:37:49
Otsu's method 是一种图像自动阈值的方法,该方法返回一个将图像分为“前景”和“背景”两类的数值,该数值使得上述两类的类内方差最小,即类间方差最大。 图1 原图像 图2 使用 Otsu's method 进行二值化后的图像 算法 \[ \sigma _{w}^{2}(t)=\omega _{0}(t)\sigma _{0}^{2}(t)+\omega _{1}(t)\sigma _{1}^{2}(t) \] 其中, \(t\) 是将图像分为“前景”和“背景”两类的阈值, \(\omega _{0}\) 和 \(\omega _{1}\) 分别是这两个类的加权数,而 \(\sigma _{0}^{2}\) 和 \(\sigma _{1}^{2}\) 分别是这两个类的方差。 图3 算法可视化动图 ## 参考 Wikipedia - Otsu's method The Lab Book Pages - Otsu Thresholding 来源: https://www.cnblogs.com/zdfffg/p/11809719.html

How to read oni file in Processing 2?

徘徊边缘 提交于 2019-12-03 21:02:05
I have a Kinect program in Processing 2 that I would like to test or simulate by passing it saved skeletons from an .oni file rather than taking input from the Kinect. Is it possible to do this, i.e. to get Processing 2 instead of using the Kinect it should read values from the .oni file and produce an output? I recommend using the SimpleOpenNI library: import SimpleOpenNI.*; SimpleOpenNI ni; void setup(){ size(640,480); ni = new SimpleOpenNI(this); if(SimpleOpenNI.deviceCount() == 0) ni.openFileRecording("/path/to/yourRecording.oni"); ni.enableDepth(); } void draw(){ ni.update(); image(ni