Here we need load two libraries the processing video library, and the JRubyArt art video_event library. The video_event library sole purpose is to allow you to use the java reflection method captureEvent those processing boys are over keen on reflection to my liking. The preferred way call the libraries is as a comma separated list of symbols but Strings also work. Note that we also need to include_package '' or use the fully qualified name for Capture:-

load_library :video, :video_event
include_package ''
attr_reader :cam, :my_shader

def setup
  sketch_title 'Black White Capture'
  @my_shader = load_shader(data_path('bwfrag.glsl'))
  start_capture(width, height)

def start_capture(w, h)
  @cam =, w, h)

def draw
  image(cam, 0, 0)
  return if mouse_pressed?

def captureEvent(c)

def settings
  size(640, 480, P2D)

Here is the shader filter bwfrag.glsl that lives in the sketch data folder

#ifdef GL_ES
precision mediump float;
precision mediump int;


uniform sampler2D texture;

varying vec4 vertColor;
varying vec4 vertTexCoord;

const vec4 lumcoeff = vec4(0.299, 0.587, 0.114, 0);

void main() {
  vec4 col = texture2D(texture,;
  float lum = dot(col, lumcoeff);
  if (0.5 < lum) {
    gl_FragColor = vertColor;
  } else {
    gl_FragColor = vec4(0, 0, 0, 1);