-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathDualNativeAndMjpegWebcamExample.java
57 lines (45 loc) · 1.63 KB
/
DualNativeAndMjpegWebcamExample.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
49
50
51
52
53
54
55
56
57
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.net.MalformedURLException;
import javax.swing.JFrame;
import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamCompositeDriver;
import com.github.sarxos.webcam.WebcamPanel;
import com.github.sarxos.webcam.ds.buildin.WebcamDefaultDriver;
import com.github.sarxos.webcam.ds.ipcam.IpCamDevice;
import com.github.sarxos.webcam.ds.ipcam.IpCamDeviceRegistry;
import com.github.sarxos.webcam.ds.ipcam.IpCamDriver;
import com.github.sarxos.webcam.ds.ipcam.IpCamMode;
/**
* Example of how to use internal webcam together with external IP cameras.
*
* @author Bartosz Firyn (SarXos)
*/
public class DualNativeAndMjpegWebcamExample {
/**
* Customized webcam driver.
*/
public static class MyCompositeDriver extends WebcamCompositeDriver {
public MyCompositeDriver() {
add(new WebcamDefaultDriver());
add(new IpCamDriver());
}
}
// register custom composite driver
static {
Webcam.setDriver(new MyCompositeDriver());
}
public static void main(String[] args) throws MalformedURLException {
// register IP camera device
IpCamDeviceRegistry.register(new IpCamDevice("Lignano Beach", "http://88.37.116.138/mjpg/video.mjpg", IpCamMode.PUSH));
JFrame window = new JFrame("Live Views From Lignano Beach (Italy)");
window.setLayout(new FlowLayout());
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for (Webcam webcam : Webcam.getWebcams()) {
webcam.setViewSize(new Dimension(352, 288));
window.add(new WebcamPanel(webcam));
}
window.pack();
window.setVisible(true);
}
}