-
Notifications
You must be signed in to change notification settings - Fork 5
/
GSCapture.java
48 lines (36 loc) · 1.09 KB
/
GSCapture.java
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
package org.genericsystem.cv.application;
import org.genericsystem.cv.Img;
import org.genericsystem.cv.PdfToPngConverter;
import org.opencv.core.Size;
interface GSCapture {
public static final Size HD = new Size(1280, 720);
public static final Size VGA = new Size(640, 360);
SuperFrameImg read();
void release();
Size getResize();
public static class GSPhotoCapture implements GSCapture {
private final SuperFrameImg superFrame;
public GSPhotoCapture(String url, double f) {
Img img;
if (url.endsWith(".pdf"))
img = PdfToPngConverter.imgFromPdf(url, 0);
else
img = new Img(url);
double coeff = Math.min(VGA.width / img.width(), VGA.height / img.height());
img = img.resize(new Size(coeff * img.width(), coeff * img.height()));
superFrame = new SuperFrameImg(img.getSrc(), new double[] { img.width() / 2, img.height() / 2 }, f);
}
@Override
public SuperFrameImg read() {
return superFrame;
}
@Override
public void release() {
superFrame.getFrame().getSrc().release();
}
@Override
public Size getResize() {
return superFrame.size();
}
}
}