-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
JpegExample.java
48 lines (34 loc) · 1.3 KB
/
JpegExample.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 com.github.sarxos.webcam.ds.ipcam;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamPanel;
public class JpegExample {
public static void main(String[] args) throws MalformedURLException {
// Dasding is a radio in Germany. They have few network cameras
// available to be viewed online. Here in this example we are creating
// IP camera device working in PULL mode to request static JPEG images.
JFrame f = new JFrame("Dasding Studio Live IP Cameras");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new GridLayout(0, 3, 1, 1));
List<WebcamPanel> panels = new ArrayList<WebcamPanel>();
for (Webcam webcam : Webcam.getWebcams()) {
WebcamPanel panel = new WebcamPanel(webcam, new Dimension(256, 144), false);
panel.setFillArea(true);
panel.setFPS(0.2); // 0.2 FPS = 1 frame per 5 seconds
panel.setBorder(BorderFactory.createEmptyBorder());
f.add(panel);
panels.add(panel);
}
f.pack();
f.setVisible(true);
for (WebcamPanel panel : panels) {
panel.start();
}
}
}