Uses 3730K of libraries. Click here for Pure Java version (13877L/72K).
1 | !7 |
2 | |
3 | cm LiveWebCam > DynSCP { |
4 | transient WebcamPanel panel; |
5 | int fpsLimit = -1; |
6 | bool autoStart; |
7 | switchable bool alwaysOnTop; // TODO: alwaysOnTop without restart |
8 | |
9 | enhanceFrame { |
10 | minimalFrameSize(f/JInternalFrame, 320, 240); |
11 | internalFramePopupMenuItem(f, "Save to AI Album", |
12 | rThread { dm_saveToAIAlbum(getImage()) }); |
13 | internalFramePopupMenuItem(f, "Set FPS...", r { |
14 | final JTextField tf = jtextfield(str(fpsLimit)); |
15 | showFormTitled("Set FPS Limit", |
16 | "FPS Limit (-1 for no limit, 0 for no updates):", tf, |
17 | rThread { setFPSLimit(parseInt(gtt(tf))) }); |
18 | }); |
19 | dm_boolFieldMenuItem(f, 'autoStart); |
20 | internalFramePopupMenuItem(f, "Natural size", r dm_packFrame); |
21 | if (alwaysOnTop) dm_alwaysOnTop(f); |
22 | } |
23 | |
24 | JComponent visualize2() { |
25 | ret jcenteredbutton("Start", rThread startIt); |
26 | } |
27 | |
28 | afterVisualize { if (autoStart) startIt(); } |
29 | |
30 | void startIt { |
31 | selectWebCam(vf<Webcam> selectCam); |
32 | } |
33 | |
34 | void startPreferredOrSelect { |
35 | selectWebCam_withPreferred(vf<Webcam> selectCam); |
36 | } |
37 | |
38 | void selectCam(Webcam cam) enter { |
39 | final WebcamPanel panel = new WebcamPanel(cam, false); |
40 | LiveWebCam.this.panel = panel; |
41 | bindToComponent(panel, null, r { panel.stop() }); |
42 | updateFPSLimitInPanel(); |
43 | setComponent(panel); |
44 | //dm_packFrame(); |
45 | } |
46 | |
47 | void stopIt { |
48 | if (panel == null) ret; |
49 | panel.stop(); |
50 | } |
51 | |
52 | BufferedImage getImage() { |
53 | ret imageFromWebcamPanel(panel); |
54 | } |
55 | |
56 | void setFPSLimit(int limit) { |
57 | setField(fpsLimit := limit); |
58 | updateFPSLimitInPanel(); |
59 | } |
60 | |
61 | void updateFPSLimitInPanel { |
62 | setModuleName((fpsLimit >= 0 ? fpsLimit + " FPS - " : "") + "Live WebCam"); |
63 | if (panel == null) ret; |
64 | panel.stop(); |
65 | if (fpsLimit == 0) ret; // TODO - want to keep last image there anyway |
66 | panel.setFPSDisplayed(fpsLimit < 0); |
67 | if (fpsLimit > 0) panel.setFPSLimit(fpsLimit); |
68 | panel.setFPSLimited(fpsLimit > 0); |
69 | panel.start(); |
70 | } |
71 | |
72 | bool isWebCamLive() { |
73 | ret panel != null && fpsLimit != 0; |
74 | } |
75 | } |
Began life as a copy of #1016673
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034165 |
Snippet name: | Live WebCam [using sarxos-webcam 0.3.10] |
Eternal ID of this version: | #1034165/1 |
Text MD5: | f6d133dde037ac05f31b14c4b57bc12d |
Transpilation MD5: | c6c7217e078533a2c1c9712dac7648f8 |
Author: | stefan |
Category: | javax / desktop / camera |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-25 16:43:50 |
Source code size: | 2097 bytes / 75 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 105 / 159 |
Referenced in: | [show references] |