We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › JMyron hijack function crashes my sketch
Page Index Toggle Pages: 1
JMyron hijack function crashes my sketch (Read 504 times)
JMyron hijack function crashes my sketch
Dec 3rd, 2008, 11:01pm
 
Hey all.  I'm working with JMyron to do some blob detection and whatnot, and it all works ok with the webcam, however I'm using a video to test with rather than work straight off the webcam.

When I test the hijack feature it runs the sketch then promptly crashes.  Nothing happens other than OS X's "this application has unexpectedly quit" message box.  Hopefully I'm doing something wrong thats causing this.

Here's my code:
Code:

import JMyron.*;
import processing.video.*;

JMyron Myron;//a camera object
Movie _mov;
PImage _movStill;
boolean _showCam = true;
boolean _drawLines = false;

void setup(){
size(640,480);
_mov = new Movie(this, "testmov1.mov");
_mov.loop();
_mov.speed(1);

Myron = new JMyron();//make a new instance of the object
Myron.start(width,height);//start a capture at 320x240

Myron.minDensity(50);
Myron.trackColor(0,0,0,150); //the color to track, and the tolerance.

println("Myron " + Myron.version());
noFill();
}

void draw(){
background(0);
Myron.hijack(640, 480, _mov.pixels);

Myron.update();//update the camera view
int[] img = Myron.image(); //get the normal image of the camera

//draw what the camera sees
if (_showCam == true) {
loadPixels();
for(int i=0;i<width*height;i++){ //loop through all the pixels
pixels[i] = img[i]; //draw each pixel to the screen
}
updatePixels();
}

// outlines!
/*
stroke(0,150,0);
int[][][] list = Myron.globEdgePoints(30);//get the outlines
for(int i=0;i<list.length;i++){
beginShape();
if(list[i]!=null){
for(int ii=0;ii<list[i].length;ii++){
vertex(list[i][ii][0],list[i][ii][1]);
}
vertex(list[i][0][0],list[i][0][1]);
}

endShape();
}
*/

// connect!
if (_drawLines) {
int[][] centers = Myron.globCenters();

//println("***\n***\n***");

stroke(150,0,0);
strokeWeight(centers.length/2);
strokeJoin(ROUND);
strokeCap(ROUND);
beginShape();

for (int i = 0; i < centers.length-1; i++) {

if (centers[i] != null) {
vertex(centers[i][0],centers[i][1]);

//println(i + ": " + centers[i]);
}
}
endShape();
}

}

void mousePressed(){
color cp = pixels[mouseY*width+mouseX];
int cpR = int(red(cp));
int cpB = int(blue(cp));
int cpG = int(green(cp));
println(red(cp) + ", " + green(cp) + ", " + blue(cp));

Myron.trackColor(cpR,cpB,cpG,100);
}

void keyPressed() {
if (keyCode == UP) {
_showCam = !_showCam;
}
if (keyCode == LEFT) {
_drawLines = !_drawLines;
}
}

void movieEvent(Movie m) {
m.read();
}
public void stop(){
Myron.stop();//stop the object
super.stop();
}



Again it works fine with the webcam and the movie runs fine in processing on it's own.

Thanks for all your help!
Page Index Toggle Pages: 1