Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

51
LINES

< > BotCompany Repo | #1019033 // WebCam, VGA Size [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 2617K of libraries. Click here for Pure Java version (14744L/105K).

1  
!7
2  
3  
sclass LiveWebCam > DynSCP {
4  
  transient WebcamPanel panel;
5  
  int fpsLimit = -1;
6  
  
7  
  void enhanceFrame(Container f) {
8  
    internalFramePopupMenuItem(f/JInternalFrame, "Set FPS...", r {
9  
      final JTextField tf = jtextfield(str(fpsLimit));
10  
      showFormTitled("Set FPS Limit",
11  
        "FPS Limit (-1 for no limit, 0 for no updates):", tf,
12  
        rThread { setFPSLimit(parseInt(gtt(tf))) });
13  
    });
14  
  }
15  
16  
  JComponent visualize2() {
17  
    ret jcenteredbutton("Start", rThread startIt);
18  
  }
19  
  
20  
  void startIt {
21  
    selectWebCam(voidfunc(Webcam cam) {
22  
      cam.setViewSize(WebcamResolution.VGA.getSize());
23  
      final WebcamPanel panel = new WebcamPanel(cam, false);
24  
      LiveWebCam.this.panel = panel;
25  
      bindToComponent(panel, null, r { panel.stop() });
26  
      updateFPSLimitInPanel();
27  
      setComponent(panel);
28  
      dm_packFrame();
29  
    });
30  
  }
31  
  
32  
  BufferedImage getImage() {
33  
    ret imageFromWebcamPanel(panel);
34  
  }
35  
  
36  
  void setFPSLimit(int limit) {
37  
    setField(fpsLimit := limit);
38  
    updateFPSLimitInPanel();
39  
  }
40  
  
41  
  void updateFPSLimitInPanel {
42  
    setModuleName((fpsLimit >= 0 ? fpsLimit + " FPS - " : "") + "Live WebCam");
43  
    if (panel == null) ret;
44  
    panel.stop();
45  
    if (fpsLimit == 0) ret; // TODO - want to keep last image there anyway
46  
    panel.setFPSDisplayed(fpsLimit < 0);
47  
    if (fpsLimit > 0) panel.setFPSLimit(fpsLimit);
48  
    panel.setFPSLimited(fpsLimit > 0);
49  
    panel.start();
50  
  }
51  
}

Author comment

Began life as a copy of #1016673

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019033
Snippet name: WebCam, VGA Size [Dyn Module]
Eternal ID of this version: #1019033/3
Text MD5: 4aa2e2b8a36546dd3879c5ff066ec6ad
Transpilation MD5: daa2894c1e223a074c3536ae1ce063ee
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: 2018-10-21 16:05:28
Source code size: 1469 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 329 / 473
Version history: 2 change(s)
Referenced in: [show references]