Hi everyone!
Let me start saying that I’m a complete beginner, so I hope this is the right place to ask this question, but I’m (obviously) having some troubles with the code I’m trying to make work…
What I’m trying to accomplish is the following: Detect a QR code via webcam and send its message to Resolume Arena via osc using processing.
I managed to make the base process work using BoofCV and oscP5, embeding the osc message inside the QR and sending the message processing reads to Resolume.
My problem now is that this runs in a loop though, so Resolume keeps receiving the same message over and over, therefore the clip keeps being started, resulting in it being stuck at the beginning (as if someone was furiously pressing the “start clip” button).
I have the same problem if I just use oscP5 to send a simple message pressing a key on my keyboard. If I keep pressing the key, it just keeps sending the message instead of holding it like a piano key.
Ideally, I would have the code detect the QR and hold that message until that QR isn’t detected on the screen anymore…
I know this has probably a simple solution that I can’t see since I’m a complete beginner, but I was wondering if anyone could spare me some kindness and help me out with this
I’ll attach the code I wrote so far, hoping I don’t embarass myself with too many mistakes:
import oscP5.*;
import netP5.*;
import processing.video.*;
import boofcv.processing.*;
import java.util.*;
import georegression.struct.shapes.Polygon2D_F64;
import georegression.struct.point.Point2D_F64;
import boofcv.alg.fiducial.qrcode.QrCode;
OscP5 oscP5;
NetAddress myRemoteLocation;
Capture cam;
SimpleQrCode detector;
void setup() {
initializeCamera(640, 480);
surface.setSize(cam.width, cam.height);
detector = Boof.detectQR();
oscP5 = new OscP5(this,12000);
myRemoteLocation = new NetAddress("127.0.0.1",7000);
}
void draw() {
if (cam.available() == true) {
cam.read();
List<QrCode> found = detector.detect(cam);
image(cam, 0, 0);
noFill();
strokeWeight(5);
stroke(255, 0, 0);
for( QrCode qr : found ) {
OscMessage myMessage = new OscMessage(""+qr.message);
myMessage.add(1);
oscP5.send(myMessage, myRemoteLocation);
beginShape();
for( int i = 0; i < qr.bounds.size(); i++ ) {
Point2D_F64 p = qr.bounds.get(i);
vertex( (int)p.x, (int)p.y );
}
Point2D_F64 p = qr.bounds.get(0);
vertex( (int)p.x, (int)p.y );
endShape();
}
}
}
void initializeCamera( int desiredWidth, int desiredHeight ) {
String[] cameras = Capture.list();
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
cam = new Capture(this, desiredWidth, desiredHeight);
cam.start();
}
}
The message in the QR is “/composition/layers/3/clips/1/connect” which allows for resolume to start the clip with the value 1.