Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all 2896 articles
Browse latest View live

Multiple QR Code

$
0
0

Hello I am a student of Interaction design and use by a few months Processing. I want to design a code which allows to a camera (such as that of the computer) to identify various QR code. Each QR code is connected to a single content (video, photos, augmented reality, etc.). I started from the code written by Tom Igoe and Daniel Shiffman and I wonder if someone can help me complete the code by giving the opportunity to the camera to read various QR Code. Thank you. This is the code:

/*
QRcode reader
 Generate images from a QRcode generator such as
 http://qrcode.kaywa.com/ and put them in this sketch's
 data folder.
 Press spacebar to read from the camera, generate an image,
 and scan for barcodes.  Press f to read from a file and scan.
 Press s for camera settings.
 Created 9 June 2007
 by Tom Igoe / Daniel Shiffman
 */


import processing.video.*;
import qrcodeprocessing.*;

Capture video;                                 // instance of the video capture library
String statusMsg = "Waiting for an image";     // a string to return messages:

// Decoder object from prdecoder library
Decoder decoder;

void setup() {
  size(400, 320);
  video = new Capture(this, 320, 240);
  video.start();

  // Create a decoder object
  decoder = new Decoder(this);
}

// When the decoder object finishes
// this method will be invoked.
void decoderEvent(Decoder decoder) {
  statusMsg = decoder.getDecodedString();
}

void captureEvent(Capture video) {
  video.read();
}

void draw() {
  background(0);

  // Display video
  image(video, 0, 0);
  // Display status
  text(statusMsg, 10, height-4);

  // If we are currently decoding
  if (decoder.decoding()) {
    // Display the image being decoded
    PImage show = decoder.getImage();
    image(show, 0, 0, show.width/4, show.height/4);
    statusMsg = "Decoding image";
    for (int i = 0; i < (frameCount/2) % 10; i++) statusMsg += ".";
  }
}

void keyReleased() {
  // Depending on which key is hit, do different things:
  switch (key) {
  case ' ':
    // Spacebar takes a picture and tests it:
    // copy it to the PImage savedFrame:
    PImage savedFrame = createImage(video.width, video.height, RGB);
    savedFrame.copy(video, 0, 0, video.width, video.height, 0, 0, video.width, video.height);
    savedFrame.updatePixels();
    // Decode savedFrame
    decoder.decodeImage(savedFrame);
    break;
  case 'f':    // f runs a test on a file
    PImage preservedFrame = loadImage("qrcode.png");
    // Decode file
    decoder.decodeImage(preservedFrame);
    break;
  }
}

how use the OpenCV with Processing?

$
0
0

its always shows "the package hypermedia does not exist" . i did all methods found in internet, but dont have any result processing 3.1 and openCV 3.0 versions

How to make Photos/Videos unshareable

$
0
0

Hello all,

my question is, if there is a way of making an image or a video unshareable? So for example if you have a video on a website and someone wants to share it on Facebook. Is it possible to alter the shared video? For example: You have a 10 minute short film and when you share the film, you automatically share a 30 second teaser of it instead. Or instead of sharing a picture, you only share a pixelated image.

This should also work when you download the film and want to share it. So that it is basically digitally watermarked?

I hope I've explained my intention well enough.

This doesn't have to be done in Processing, it's more of a general question how you could go about it.

Thank you!

The Console library prints out my window's movement

$
0
0

I installed the Console library from P3's lib manager. Try opening up one of the examples and drag the window around. At least on windows, it's printing out every move, like so:

...
__MOVE__ 2836 483
__MOVE__ 2833 492
__MOVE__ 2831 498
__MOVE__ 2828 501
__MOVE__ 2827 503
__MOVE__ 2825 504
__MOVE__ 2825 505
__MOVE__ 2824 506
...

Is there any way around this? I tried looking at the sourcecode but couldn't really find anything there. I'm guessing some other process is printing it out? Weird how it doesn't show up in the standard processing console though.

It's not a huge problem, but I'm building a control interface where the console prints out important info, so having it erase everything every time I drag the window around is a huge pain.

How to find the solution (transitions)

$
0
0

I've download and modify this program, I have a problem when I run this sketch, Processing says to me "impossible to / by zero" but I've charged a list. why the list as zero ?

This is my code :

import com.bric.image.transition.Transition;
import com.bric.image.transition.ScribbleTransition2D;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

Transition t;
ArrayList<String> images = new ArrayList<String>(); // list of images to load
PImage[] img;
int currentImage = 0;
int nextImage;
BufferedImage[] buf;
BufferedImage out;
Graphics2D g2;
int frames = 100; // number of frames per transition

void setup(String path) {
  File folder = new File(path);
  File[] listOfFiles = folder.listFiles();

  for (File file : listOfFiles) {
    if (file.isFile() && (file.getName().contains(".jpg") || file.getName().contains(".png"))) {
      images.add(file.getName());
    }
  }

  size(600, 300);
  // create pimage array
  img = new PImage[images.size()];
  // create buffered image array
  buf = new BufferedImage[images.size()];
    for (int h = 0 ; h < images.size() ; h++) {
      img[h] = loadImage(images.get(h));
      buf[h] = (BufferedImage)img[h].getNative();
    }
  t = new ScribbleTransition2D(true);
  // all the images should be the same size
  out = new BufferedImage(img[0].width, img[0].height, BufferedImage.TYPE_INT_ARGB);
  g2 = out.createGraphics();
}

void draw() {

    if ((frameCount % frames) == 0) {
    // bump images
    currentImage = nextImage;
    }
  nextImage = (currentImage + 1) % images.size();
  // draw transition into graphic
  t.paint(g2, buf[currentImage], buf[nextImage], (frameCount % frames) / (float)frames);
  // copy graphic to screen
  image(new PImage(out), 0, 0);
}

Please I want help ! :)

For Cypress or other controller

$
0
0

Hi

I am new to processing ,and want to make teapot type project in processing using cypress or other controller ,so for this do i need any library? as for aurdino tea pot example i had work its working fine

Please let me know on this ,how to proceed

Regards Habib

HTTP Post JSON statement

$
0
0

Hi there,

I am relatively new to Processing. What I am trying to do is get processing to send a formated JSON statement to an LRS (Learner registry store). I am using the http.requests library and trying to do a post request.

I thought it would be easy to send the statement like sending it in the body of a normal http post.

import http.requests.*;

PostRequest post = new PostRequest("http:" + "//openlabyrinth.ca/grassblade-lrs/xAPI/statements");
post.addUser("14-******", "****245*******");
post.addHeader("X-Experience-API-Version", "1.0.0");
post.addData("name", "rune");
post.send();
println("Reponse Content: " + post.getContent());
println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));

Then it returns:
Reponse Content: Error: Invalid or empty statement
Reponse Content-Length Header: 33

the formated statement I am trying to send is

{
    "actor": {
        "mbox": "mailto:test@test.ca",
        "objectType": "Agent"
    },
    "verb": {
        "id": "http:// adlnet.gov/expapi/verbs/imported",
        "display": {
            "en-US": "imported"
        }
    },
    "object": {
        "id": "http:// adlnet.gov/expapi/activities/example",
        "definition": {
            "name": {
                "en-US": "Example Activity"
            },
            "description": {
                "en-US": "Example activity description"
            },
            "type": "http:// adlnet.gov/expapi/activities/cmi.interaction",
            "interactionType": "other",
            "extensions": "BMI:76, IBI:657,GSR:1800"
        },
        "objectType": "Activity"
    }
}

Any help would be amazing.

Thanks for your time

Twiiter String Elements Removal

$
0
0

Hi everybody,

I'm trying to write a sketch using Twitter API. I want to retrive tweets with a specific hashtag so I can use them. Unfortunately, I keep getting stuff like http related words in the middle of it.

Is there a practical way to prevent this or to remove them from the array?

This is the code I am using. These are all functions that are being called somewhere else.

Thank you so much

Best

    void makeobject(){


      //Make the twitter object and prepare the query
      twitterInstance = new TwitterFactory(cb.build()).getInstance();
      queryForTwitter = new Query("#summerparty");
      queryForTwitter.count(50);

    }

void createtquery() {


  //Try making the query request.
  try {
    QueryResult result = twitterInstance.search(queryForTwitter);
    tweets = (ArrayList) result.getTweets();
  } //END of try()
  catch (TwitterException te) {
    println("Couldn't connect: " + te);
  } //END Twitter Exception
} //END of void


void twitterdraw() {


  for (int i = 0; i < tweets.size (); i++) {
      Status t = (Status) tweets.get(i);
      String user = t.getUser().getName();
      String msg = t.getText();
      // Date d = t.getCreatedAt();
      println(msg);
      //text(msg, 150, 150);



 //Break the tweet into words
      String[] input = msg.split("#");
      for (int j = 0; j < input.length; j++) {
        //Put each word into the words ArrayList
        words.add(input[j]);
      }  //END of for()


  } //END of for()


  //Draw a word from the list
  int i = (int(random(0, words.size())) % words.size());
  String  word = words.get(i);

  //Put it on the stage
  text(word, 350, 110);


}

How can I make a video's playing contingent on keyPressed?

$
0
0

Hello everyone, I'm a super newbie to processing, so I apologize in advance for any communication blips we might have. I'll try to explain what I'm trying to do as clearly as possible.

I want to make it so that the frame rate of the movie is determined by the user pressing the spacebar. So, essentially, one has to press the spacebar rapidly and without stopping in order to make the movie "go".

Is this possible, maybe with a combination of keyPressed, frameRate, maybe an if/else?

Thank you!

Twitter Ticker

$
0
0

Trying to make a twitter ticker device with Processing 3.

So far, I've found a few disparate source codes, but need any assistance to make work. My Twitter4J library is imported. Would like to achieve something like this: http://cs.brynmawr.edu/gxk2013/examples/text/Ticker/ but streaming from a twitter account. Is this possible with Processing?

SDrop in fullscreen mode

$
0
0

Is there any special trick that is required to make SDrop work in a fullscreen sketch?

My current code works perfectly as long as I start the sketch with size(x,y). When I start it with fullScreen() the drop events to not fire any more.

somwhere I read the following tipp: Instead of using drop = new SDrop(this); one should use drop = new SDrop((Component)this.surface.getNative(), this);

But this resolves in an error about the constructor being undefined.

Does anyone have a solution for this?

Motion detection on Movie

$
0
0

Hello Processing community,

I want to compare frames from a Movie — I found this discussion, can I substitute the Capture with Movie?

Which is the best way to do this?

G4P Knob Class - Can know display floats instead of ints?

$
0
0

I am looking in to G4P IGraph_Designer example. All the knobs display int values. Is it possible to display floats instead (a fractional component, not just "X.0")? I did not see a method to do this.

Problem with the if condition

$
0
0

Hello guys, I'm currently making a Memory game. I'm having a problem when I want to go to the next screen (I'm having the main screen, with mouse click I go to the next creen and so on....) everything is fine until I go to a specific screen, click how many cards I want to have and it directly jumps to the game. But there's another screen between them so the problem is that it skips a screen. Here's the code for the buttons screen which skips the next screen

 if (isPointOnButton3==true)
{
  cardCount=1;
  state=4;
} else if (isPointOnButton4==true)
{
  cardCount=2;
  state=4;
} else if (isPointOnButton5==true)
{
  cardCount=3;
  state=4;

} else if (isPointOnButton6==true)
{
  cardCount=4;
  state=4;
}
}
}

And here's the skipped screen

void ZmenRub()
{
if (state==4)  //zvolení počtu dvojic
{

fill(0);
background(204);
textFont(myFont2);
text("Zvolte rub karet", 335, 260);
volbaK = loadImage("00cards.png");
volbaK2 = loadImage("001cards.png");
volbaK3 = loadImage("002cards.png");
volbaK4 = loadImage("003cards.png");
volbaK5 = loadImage("004cards.png");
volbaK6 = loadImage("005cards.png");
image(volbaK, 190, 365, 100, 150);
image(volbaK2, 290, 365, 100, 150);
image(volbaK3, 390, 365, 100, 150);
image(volbaK4, 490, 365, 100, 150);
image(volbaK5, 590, 365, 100, 150);
image(volbaK6, 690, 365, 100, 150);






if (isPointOnButton7==true)
{


  gcardback = loadImage("00cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
} else if (isPointOnButton8==true)
{


  gcardback = loadImage("001cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
} else if (isPointOnButton9==true)
{


  gcardback = loadImage("002cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
} else if (isPointOnButton10==true)
{

  gcardback = loadImage("003cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
} else if (isPointOnButton11==true)
{

  gcardback = loadImage("004cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
} else if (isPointOnButton12==true)
{

  gcardback = loadImage("005cards.png");
  InicializaceKaret();
  file.stop();
  file = new SoundFile(this, "menu.mp3");
  file.play();

  state=5;
}
}
}

I don't know why it skips the screen, the if condition is not wrong. Thanks in advance for your help and tips

is MIDI functional? how to get started?

$
0
0

Hello all, I recently found processing and would love to do my research on composing with it. I cannot get theMIDIbus to work, is it abandoned? I am finding references to another library that does not seem to be available any more.

any help much appreciated. :) thank you all. Aristides


Please help me before the 09/05/16 !

$
0
0

hey i have some problem with this program. When i want to jump it's make a strange thing. Can you help me with this ?

`Camera worldCamera; int appuye=0; int reappuye=0; int montee=0; int Yp=0; int Pg=0; int Yb=210; int xb=20; int deplacementB=1; void setup(){ size(400,400); worldCamera = new Camera(); ellipse(xb,Yb,10,10);

}

void draw(){ background(255); /PImage background = loadImage("bg_campagne.jpg"); image(background,-xb,-50);/ translate(-worldCamera.pos.x, -worldCamera.pos.y); worldCamera.draw(); fill(255,0,0); MAP(); Redessiner_Tout();

//déplacement de la balle if (appuye==1){ if(reappuye==0){ reappuye=1; montee=1; Yp=0; }else{ if(montee==1 && reappuye==1 && Yp==0){ Pg=Pg+1; Yb=Yb-(Pg/Pg); }else{ if(Pg==50){ montee=0; Pg=0; appuye=0; }else{ if(Yp!=0){ Yb=Yp; reappuye=0; }else{ Yb=Yb-1; }}}}} //fin déplacement }

void MAP (){ plateforme(0,200,50,10); plateforme(80,160,50,10); plateforme(160,120,50,10); plateforme(240,80,50,10); plateforme(280,120,50,10); plateforme(320,160,100,10); plateforme(440,120,50,10); plateforme(520,80,50,10); plateforme(600,80,100,10); plateforme(720,80,100,10); plateforme(840,120,50,10); plateforme(880,160,100,10); plateforme(1000,320,200,10); plateforme(1200,280,50,10); plateforme(1280,240,50,10); plateforme(1360,200,50,10); plateforme(1440,160,100,10); plateforme(1560,160,50,10); plateforme(1640,160,50,10); plateforme(1720,160,50,10); plateforme(1760,200,50,10); plateforme(1800,240,50,10); plateforme(1840,280,100,10); plateforme(1960,240,50,10); plateforme(2040,200,50,10); plateforme(2120,160,50,10); plateforme(2200,120,200,10); plateforme(2360,80,50,10);

} void plateforme(int x,int y,int h,int l){ rectangle(x,y,h,l); physique(x,y,h,l); }

void rectangle(int x,int y,int h,int l){ rect(x,y,h,l); }

int physique(int x,int y,int h,int l){ Yp=y-10; return Yp; }

class Camera { PVector pos; Camera() { pos = new PVector(0,0); }

void draw() { xb=xb+2; pos.x = xb-20; } } void Redessiner_Tout() {

fill(255); ellipse(xb,Yb,15,15); fill(255);
} void keyPressed(){//SAUT if (key ==' '){ appuye = 1;}}

` PS: sorry for my bad english i'm french ;)

Resolution Video in Processing

$
0
0

Hello :) I have a question. What what resolution supports the processing of the video? Does Processing support HD 1080p and 720p?

outOfMemoryError unsolved

$
0
0

When increasing the number of objects from a class I get always the error: outOfMemory but all memory settings are far behind the allocated memory: In Processing I increased maximum of memory: 3793 mb (I do not work with images or video just a bit of data visualization.)

Using the functions of the FAQ for this kind of error I get the following values . The amount of memory allocated so far (usually the -Xms setting): 64487424 (bytes).

Free memory out of the amount allocated (value above minus used): 52834856 (bytes).

The maximum amount of memory that can eventually be consumed by this application. This is the value set by the Preferences dialog box to increase the memory settings for an application: 3536322560 (bytes).

system: win7 64bit, Java Build 1.8.0_91-b14 (64bit)

a screenshot from console: 2016-05-15_outOfmemory

Multichannel audio?

$
0
0

Hi all

I prototyped an a/v project using sample playback in stereo and now comes the time to spatialise the sound (3 channels, possibly concurrent playback). I thought this would be a bread-and-butter exercise but it seems either I'm missing something or it's not off the shelf?!

I'm running Processing 3 on OS X 10.10.5

I've reviewed Minim & Beads and not found an obvious example. I read this forum post where the solution seemed to be to run multiple stereo sound cards!

I've hacked around based upon this Minim example but I can't get any audio device to tell me it has more Lines available (Audio 8 DJ, Soundflower)

Line.Info allLines [] = mixer.getTargetLineInfo(); println(mixer.getMixerInfo()); println("MSP allLines: "+allLines.length);

Audio 8 DJ, version Unknown Version MSP allLines: 1 MSP open lines: 0 MSP lines: -1 MSP: com.sun.media.sound.DirectAudioDevice$DirectTDL@34339880

I started poking around in Java Sound directly based on this SO post and this gist but same deal, although I have verified I have a "Direct Audio Device" Mixer.

Minim states "Using setOutputMixer you can also create AudioOutputs that send sound to specific output channels of a sound card." but that method is deprecated and I can't figure out how to use it regardless!

I've read the Java Sound docs but can't see anything obvious telling me one way or the other if this is possible.

So..

Anyone out there running multichannel audio (from a single sound card) via Processing (or plain Java)? If so, please tell me what I'm missing!

Cheers

New - multiple animations inside void draw()

$
0
0

Hello processing community.

My name is jules, design student, and I'm working on a code to translate live video from the webcam into sounds.

I'm taking out one pixel every 24 pixels that is then displayed bigger (and round) and is picked to be translated into a sine wave. I want this one selected pixel to appear bigger(let's say twice the scale), and then decrease its size slowly until it gets the same size as all the other squares. I'm doing this in order to display clearly where the sound is coming from/ highlight this part of the image for the moment it's played. The problem I face here is that the animation of the change of scale would take place while the normal loop of the draw is still running. And I don't know how to deal with that.

Thanks for reading

import processing.video.*;
import ddf.minim.*;
import ddf.minim.ugens.*;

Minim minim;
AudioOutput out;

Oscil      wave;

Capture cam;
int pointillize = 30;
int Lx[] = {1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300};
int Ly[] = {1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220};
int i  = 0;


void setup() {
  size(1200, 1200);

  cam = new Capture(this, 320, 240, 30);
  cam.start();
  background(0);
  rectMode(CENTER);
  smooth();

   // initialize the minim and out objects
  minim = new Minim(this);
  out   = minim.getLineOut();

  wave = new Oscil( 440, 0.6f, Waves.SINE );

  wave.patch( out );
}

void draw() {

    cam.read();

   int x = Lx[ (int) random(Lx.length) ];
  int y = Ly[ (int) random(Ly.length) ];
  int loc = x + y*cam.width;

  // Look up the RGB color in the source image
  loadPixels();
  float r = red(cam.pixels[loc]);
  float g = green(cam.pixels[loc]);
  float b = blue(cam.pixels[loc]);
  noStroke();

  // Draw an ellipse at that location with that color
   i = i + 1;
   fill(r,g,b,255);

  if (i == 24){

        ellipse(((x+150)*2),((y+150)*2),pointillize+20,pointillize+20);
        i = 0;

      //getting the wavelengh = lwave
      color c = color(r,g,b);
      float lwave = ((hue(c))*400/360)+380;

      //getting the related frequency= swave
      //octave 350_718Hz
      float swave = 300000000/lwave*1000000000/1099511627776L;


      //play sound of it
      wave.setFrequency( swave );


  } else {

      rect(((x+150)*2),((y+150)*2),pointillize,pointillize);
  }


  // bpm
  delay(5);
}

Also, another question : The code runs quite slow, I putted the delay at (1) but still, I would like to have it faster. Does anyone knows why ?

Viewing all 2896 articles
Browse latest View live