I need some help with aligning the image from a video capture onto the screen correctly. I'm not sure if this has anything to do with using P3D or not as this is my first time trying it out. I have tried changing all the variables I can think of and I can't get the field captured in my camera to fill the field in my program? The image is always to the bottom right corner. I started from an example that had an image in each corner and I commented out all except for the bottom right corner. Now I cannot figure out how to change it so the image fills the screen. I'm sure it is something really simple but I can't see what it is that I'm missing. I changed the integer for transform and was able to move the image around but I can't seem to make it larger. I changed the initial w and h but then the program didn't display any image. If anyone could take a quick look I would appreciate it very much. I want the image picked up in the camera to match the size/location of the image in the program window...just that! In the long run I want the detected blobs to draw a line from their position to a chosen point which seems to be working but it just isn't centered correctly.
thanks very much in advance if you can help !!!
import hypermedia.video.*;
import java.awt.*;//another library with blob
OpenCV opencv;
int w = 320;
int h = 240;
int threshold = 40;
boolean find = true;
void setup() {
size( 600, 600, P3D );//size of program image//P3D is for 3d shape
//perspective(); I don't know if I need this
opencv = new OpenCV (this);
opencv.capture (w,h);
}
void draw() {
background(255);
opencv.read(); //read latest image from camera, save in memory
//image (opencv.image(), 10, 10); //draw RGB image
//image(opencv.image(OpenCV.GRAY), 20+w, 10); //draw grey image
//image (opencv.image(OpenCV.MEMORY), 10, 20+h); //draw get image in memory
opencv.absDiff();//
opencv.threshold(threshold);//
// image (opencv.image(OpenCV.GRAY), 20+w, 20+h);//draw the absoulute diff image
Blob[] blobs = opencv.blobs(100, w*h/3, 200, true);//minarea/maxarea/max#/holes?
noFill();
pushMatrix();// i don't know what this is
translate(20+w,20+h); //detect the blobs in the image
for( int i=0; i<blobs.length; i++) {//for all the blobs
// Rectangle bounding = blobs[i].rectangle;
// noFill();
//rect( bounding.x, bounding.y, bounding.width, bounding.height);//draw the box around blobs
float area = blobs[i].area;
float circumfrence = blobs[i].length;
Point centroid = blobs[i].centroid;
Point[]points = blobs[i].points;
stroke(0,0,100,50);//color of line to chosen point and transparency
if (points.length>0) {
beginShape();
for(int j=0; j<points.length; j++) {
vertex(points[j].x, points[j].y);// vertices of blobs
vertex (160,0);//position of chosen point
}
endShape(CLOSE);
}
}
popMatrix(); // i don't know what this is
}
1