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

32
LINES

< > BotCompany Repo | #1021153 // Grab Occasional WebCam Images [dev.]

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

Uses 2724K of libraries. Click here for Pure Java version (11178L/82K).

1  
!7
2  
3  
module OccasionalWebCam > DynSCP {
4  
  transient ImageSurface imageSurface;
5  
  transient Webcam cam;
6  
7  
  JComponent visualize2() {
8  
    ret jcenteredbutton("Start", rThread startIt);
9  
  }
10  
  
11  
  void startIt {
12  
    selectWebCam_withPreferred(vf<Webcam> selectCam);
13  
  }
14  
  
15  
  void selectCam(Webcam _cam) enter {
16  
    cleanMeUp();
17  
    cam = _cam;
18  
    print("Cam opened: " + cam.open()); // blocking mode (no background thread)
19  
    setComponent(jscroll_center(imageSurface = doubleBufferedImageSurface_noAlpha()));
20  
    awtCalcEvery(imageSurface, 0.0, 1.0, r {
21  
      time "Get image from webcam" {
22  
        BufferedImage img = cam.getImage();
23  
      }
24  
      imageSurface.setImage(img);
25  
    });
26  
  }
27  
  
28  
  void cleanMeUp {
29  
    if (cam != null) cam.close();
30  
    cam = null;
31  
  }
32  
}

Author comment

Began life as a copy of #1016673

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021153
Snippet name: Grab Occasional WebCam Images [dev.]
Eternal ID of this version: #1021153/9
Text MD5: 9adb7b330ead81eb0e75ffde9c852389
Transpilation MD5: efc613e9bd63a6dfff3d3ff9f31748c9
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: 2019-01-28 01:44:52
Source code size: 793 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 263 / 504
Version history: 8 change(s)
Referenced in: [show references]