-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageGrabber.java
More file actions
50 lines (41 loc) · 1.3 KB
/
Copy pathImageGrabber.java
File metadata and controls
50 lines (41 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Created by Linus Karsai (312070209) on 27/05/2014.
*/
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import static org.bytedeco.javacpp.opencv_core.cvFlip;
import static org.bytedeco.javacpp.opencv_highgui.cvSaveImage;
public class ImageGrabber implements Runnable {
private PhotoBooth photoBooth;
opencv_core.IplImage image;
public ImageGrabber(PhotoBooth pa) {
photoBooth = pa;
}
@Override
/**
* Grabs images from web-cam
*/
public void run() {
FrameGrabber grabber = new OpenCVFrameGrabber(0);
float scaler = (float)1;
grabber.setImageWidth((int) (640 * scaler));
grabber.setImageHeight((int) (480 * scaler));
int i = 0;
try {
grabber.start();
opencv_core.IplImage img;
while (true) {
img = grabber.grab();
if (img != null) {
cvFlip(img, img, 1);
//cvSaveImage((i++) + "-capture.jpg", img);
//forward image to hook
photoBooth.imageGrabberHook(img.getBufferedImage());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}