Download Jar. Uses 2596K of libraries. Click here for Pure Java version (4190L/29K).
!7 lib 1008985 // webcam lib 1008987 // bridj lib 1004016 // slf4j api import com.github.sarxos.webcam.Webcam; /** * @author Bartosz Firyn (SarXos) */ p { time "list webcams" { L<Webcam> webcams = new L(Webcam.getWebcams()); } // NOTE! /* * Yes, I know we could do this in one loop, but I wanted to prove here * that it's possible to have many native webcams open in the same time. * I tested this example with 4 webcams simultaneously connected to the * USB bus - 1 x PC embedded device, and 3 x UVC devices connected to * the USB concentration hub, which was connected to the USB 2.0 port. * It's working like a charm. */ // USB BANDWIDTH! /* * As you probably know the USB has limited bandwidth and therefore it * may not be possible to transfer images from as many cameras as you * would like to wish. This example works when I'm using QQVGA (176x144) * but fails with the error message when I want to fetch VGA (640x480). */ // open all at once (this is the most time-consuming operation, all // others are executed instantly) for i, Webcam webcam over webcams: { try { System.out.format("Opening %s\n", webcam.getName()); time "Opening webcam" { webcam.open(); } } catch e { print("Can't open webcam " + webcam.getName() + " - " + silentException(e)); webcams.remove(i--); }} new L<Pair<S, BufferedImage>> images; // capture picture from all of them for (int i = 0; i < webcams.size(); i++) pcall { Webcam webcam = webcams.get(i); S name = webcam.getName(); System.out.format("Capturing %s\n", name); time "Capturing image" { images.add(pair(name, webcam.getImage())); } } // close all time "Closing webcams" { for (Webcam webcam : webcams) { System.out.format("Closing %s\n", webcam.getName()); webcam.close(); } } for (Pair<S, BufferedImage> p : images) showImage(p.a, p.b); }
Began life as a copy of #1008989
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008996 |
Snippet name: | Take screenshot from all web cams & display [WORKS] |
Eternal ID of this version: | #1008996/10 |
Text MD5: | f0a9a655fe171244e87154c92f92b937 |
Transpilation MD5: | f8e82b5d70db6ba4afb80c912e0f5ccc |
Author: | stefan |
Category: | javax / desktop / camera |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-06-28 15:46:12 |
Source code size: | 2022 bytes / 70 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 703 / 1362 |
Version history: | 9 change(s) |
Referenced in: | [show references] |