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).

!7

sclass LiveWebCam > DynSCP {
  transient WebcamPanel panel;
  int fpsLimit = -1;
  
  void enhanceFrame(Container f) {
    internalFramePopupMenuItem(f/JInternalFrame, "Set FPS...", r {
      final JTextField tf = jtextfield(str(fpsLimit));
      showFormTitled("Set FPS Limit",
        "FPS Limit (-1 for no limit, 0 for no updates):", tf,
        rThread { setFPSLimit(parseInt(gtt(tf))) });
    });
  }

  JComponent visualize2() {
    ret jcenteredbutton("Start", rThread startIt);
  }
  
  void startIt {
    selectWebCam(voidfunc(Webcam cam) {
      cam.setViewSize(WebcamResolution.VGA.getSize());
      final WebcamPanel panel = new WebcamPanel(cam, false);
      LiveWebCam.this.panel = panel;
      bindToComponent(panel, null, r { panel.stop() });
      updateFPSLimitInPanel();
      setComponent(panel);
      dm_packFrame();
    });
  }
  
  BufferedImage getImage() {
    ret imageFromWebcamPanel(panel);
  }
  
  void setFPSLimit(int limit) {
    setField(fpsLimit := limit);
    updateFPSLimitInPanel();
  }
  
  void updateFPSLimitInPanel {
    setModuleName((fpsLimit >= 0 ? fpsLimit + " FPS - " : "") + "Live WebCam");
    if (panel == null) ret;
    panel.stop();
    if (fpsLimit == 0) ret; // TODO - want to keep last image there anyway
    panel.setFPSDisplayed(fpsLimit < 0);
    if (fpsLimit > 0) panel.setFPSLimit(fpsLimit);
    panel.setFPSLimited(fpsLimit > 0);
    panel.start();
  }
}

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: 324 / 468
Version history: 2 change(s)
Referenced in: [show references]