Skip to content

Commit 1b847f1

Browse files
author
monkstone
committed
rename movies to video and include capture
1 parent 4cefdf7 commit 1b847f1

File tree

9 files changed

+34
-0
lines changed

9 files changed

+34
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load_library :video
2+
3+
include_package 'processing.video'
4+
5+
attr_reader :cam
6+
7+
def setup
8+
size(960, 544)
9+
cameras = Capture.list
10+
fail 'There are no cameras available for capture.' if (cameras.length == 0)
11+
p 'Matching cameras available:'
12+
size_pattern = Regexp.new(format('%dx%d', width, height))
13+
select = cameras.grep size_pattern # filter available cameras
14+
select.map { |cam| p cam }
15+
fail 'There are no matching cameras.' if (select.length == 0)
16+
start_capture(select[0])
17+
end
18+
19+
def start_capture(cam_string)
20+
# The camera can be initialized directly using an
21+
# element from the array returned by list:
22+
@cam = Capture.new(self, cam_string)
23+
p format('Using camera %s', cam_string)
24+
cam.start
25+
end
26+
27+
def draw
28+
return unless (cam.available == true)
29+
cam.read
30+
image(cam, 0, 0)
31+
# The following does the same, and is faster when just drawing the image
32+
# without any additional resizing, transformations, or tint.
33+
# set(0, 0, cam)
34+
end

0 commit comments

Comments
 (0)