size(480, 120);
size(480, 120);
point(240, 60);
size(480, 120);
line(20, 50, 420, 110);
size(480, 120);
triangle(90, 50, 30, 5, 6, 70);
Hello.. Kami A.R.T dan Kami Adalah Realitas Tanpa Batas.
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
Kami Adalah Sebuah Tim Augmented Reality yang bergerak untuk mengembangkan AR di Indonesia. Blog ini dibuat untuk kita, saling berbagi, bertanya, dan berdiskusi tentang AR. Semoga Bermanfaat
size(480, 120);
size(480, 120);
point(240, 60);
size(480, 120);
line(20, 50, 420, 110);
size(480, 120);
triangle(90, 50, 30, 5, 6, 70);
import JMyron.*;
JMyron theMov;
int[][] globArray;
void setup() {
size(640, 480);
theMov = new JMyron();
theMov.start(width, height);
theMov.findGlobs(1);
theMov.trackColor(255, 255, 255, 255);
stroke(255, 0, 0); // red outline
}
void draw() {
theMov.update();
int[] currFrame = theMov.image();
// draw each pixel to the screen
loadPixels();
for (int i = 0; i < width*height; i++) {
pixels[i] = currFrame[i];
}
updatePixels();
// draw the glob bounding boxes
globArray = theMov.globBoxes();
for(int i = 0; i < globArray.length; i++) {
int[] boxArray = globArray[i];
// set the fill colour to the average of all colours in the bounding box
int currColor = theMov.average(
boxArray[0],
boxArray[1],
boxArray[0] + boxArray[2],
boxArray[1] + boxArray[3]);
fill(red(currColor), green(currColor), blue(currColor));
rect(boxArray[0], boxArray[1], boxArray[2], boxArray[3]);
}
}
public void stop() {
theMov.stop();
super.stop();
}
import JMyron.*;
JMyron theMov;
void setup() {
size(320, 240);
theMov = new JMyron();
theMov.start(width, height);
theMov.findGlobs(0);
}
void draw() {
theMov.update();
int[] currFrame = theMov.image();
// draw each pixel to the screen
loadPixels();
for (int i = 0; i < width*height; i++) {
pixels[i] = currFrame[i];
}
updatePixels();
}
public void stop() {
theMov.stop();
super.stop();
}import JMyron.*;
int NUM_SQUARES = 20;
JMyron theMov;
int sampleWidth, sampleHeight;
int numSamplePixels;
void setup() {
size(320, 240);
theMov = new JMyron();
theMov.start(width, height);
theMov.findGlobs(0);
sampleWidth = width/NUM_SQUARES;
sampleHeight = height/NUM_SQUARES;
numSamplePixels = sampleWidth*sampleHeight;
}
void draw() {
theMov.update();
int[] currFrame = theMov.image();
// go through all the cells
for (int y=0; y < height; y += sampleHeight) {
for (int x=0; x < width; x += sampleWidth) {
// reset the averages
float r = 0;
float g = 0;
float b = 0;
// go through all the pixels in the current cell
for (int yIndex = 0; yIndex < sampleHeight; yIndex++) {
for (int xIndex = 0; xIndex < sampleWidth; xIndex++) {
// add each pixel in the current cell's RGB values to the total
// we have to multiply the y values by the width since we are
// using a one-dimensional array
r += red(currFrame[x+y*width+xIndex+yIndex*width]);
g += green(currFrame[x+y*width+xIndex+yIndex*width]);
b += blue(currFrame[x+y*width+xIndex+yIndex*width]);
}
}
r /= numSamplePixels;
g /= numSamplePixels;
b /= numSamplePixels;
fill(r, g, b);
rect(x, y, sampleWidth, sampleHeight);
}
}
}
public void stop() {
theMov.stop();
super.stop();
}
import hypermedia.video.*; // Imports the OpenCV library
OpenCV opencv; // Creates a new OpenCV object
PImage movementImg; // Creates a new PImage to hold the movement image
int poppedBubbles; // Creates a variable to hold the total number of popped bubbles
ArrayList bubbles; // Creates an ArrayList to hold the Bubble objects
PImage bubblePNG; // Creates a PImage that will hold the image of the bubble
PFont font; // Creates a new font object
void setup()
{
size ( 640, 480 ); // Window size of 640 x 480
opencv = new OpenCV( this ); // Initialises the OpenCV library
opencv.capture( 640, 480 ); // Sets the capture size to 640 x 480
movementImg = new PImage( 640, 480 ); // Initialises the PImage that holds the movement image
poppedBubbles = 0;
bubbles = new ArrayList(); // Initialises the ArrayList
bubblePNG = loadImage("bubble.png"); // Load the bubble image into memory
font = loadFont("Serif-48.vlw"); // Load the font file into memory
textFont(font, 32);
}
void draw()
{
bubbles.add(new Bubble( (int)random( 0, width - 40), -bubblePNG.height, bubblePNG.width, bubblePNG.height)); // Adds a new bubble to the array with a random x position
opencv.read(); // Captures a frame from the camera
opencv.flip(OpenCV.FLIP_HORIZONTAL); // Flips the image horizontally
image( opencv.image(), 0, 0 ); // Draws the camera image to the screen
opencv.absDiff(); // Creates a difference image
opencv.convert(OpenCV.GRAY); // Converts to greyscale
opencv.blur(OpenCV.BLUR, 3); // Blur to remove camera noise
opencv.threshold(20); // Thresholds to convert to black and white
movementImg = opencv.image(); // Puts the OpenCV buffer into an image object
for ( int i = 0; i < bubbles.size(); i++ ){ // For every bubble in the bubbles array
Bubble _bubble = (Bubble) bubbles.get(i); // Copies the current bubble into a temporary object
if(_bubble.update() == 1){ // If the bubble's update function returns '1'
bubbles.remove(i); // then remove the bubble from the array
_bubble = null; // and make the temporary bubble object null
i--; // since we've removed a bubble from the array, we need to subtract 1 from i, or we'll skip the next bubble
}else{ // If the bubble's update function doesn't return '1'
bubbles.set(i, _bubble); // Copys the updated temporary bubble object back into the array
_bubble = null; // Makes the temporary bubble object null.
}
}
opencv.remember(OpenCV.SOURCE, OpenCV.FLIP_HORIZONTAL); // Remembers the camera image so we can generate a difference image next frame. Since we've
// flipped the image earlier, we need to flip it here too.
text("Bubbles popped: " + poppedBubbles, 20, 40); // Displays some text showing how many bubbles have been popped
}
class Bubble
{
int bubbleX, bubbleY, bubbleWidth, bubbleHeight; // Some variables to hold information about the bubble
Bubble ( int bX, int bY, int bW, int bH ) // The class constructor- sets the values when a new bubble object is made
{
bubbleX = bX;
bubbleY = bY;
bubbleWidth = bW;
bubbleHeight = bH;
}
int update() // The Bubble update function
{
int movementAmount; // Create and set a variable to hold the amount of white pixels detected in the area where the bubble is
movementAmount = 0;
for( int y = bubbleY; y < (bubbleY + (bubbleHeight-1)); y++ ){ // For loop that cycles through all of the pixels in the area the bubble occupies
for( int x = bubbleX; x < (bubbleX + (bubbleWidth-1)); x++ ){
if ( x < width && x > 0 && y < height && y > 0 ){ // If the current pixel is within the screen bondaries
if (brightness(movementImg.pixels[x + (y * width)]) > 127) // and if the brightness is above 127 (in this case, if it is white)
{
movementAmount++; // Add 1 to the movementAmount variable.
}
}
}
}
if (movementAmount > 5) // If more than 5 pixels of movement are detected in the bubble area
{
poppedBubbles++; // Add 1 to the variable that holds the number of popped bubbles
return 1; // Return 1 so that the bubble object is destroyed
}else{ // If less than 5 pixels of movement are detected,
bubbleY += 10; // increase the y position of the bubble so that it falls down
if (bubbleY > height) // If the bubble has dropped off of the bottom of the screen
{ return 1; } // Return '1' so that the bubble object is destroyed
image(bubblePNG, bubbleX, bubbleY); // Draws the bubble to the screen
return 0; // Returns '0' so that the bubble isn't destroyed
}
}
}