     out: 'out'
     forwardGroups: true
     async: true
-  , (payload, groups, out, callback) ->
+  , (canvas, groups, out, callback) ->
     if not c.params.cascade
       cascade = path.join __dirname, '../cascades/face.sqlite3'
     else
       cascade = c.params.cascade
-    compute payload, cascade, (err, val) ->
+    writeCanvasTempFile canvas, (err, tmpFile) ->
       return callback err if err
-      out.send val
-      do callback
+      runScdDetect tmpFile, cascade, (err, val) ->
+        return callback err if err
+        out.send val
+        do callback
+
   c

# @runtime noflo-nodejs
# @name SCDDetect

compute = (canvas, cascade, callback) ->
  ctx = canvas.getContext '2d'
  imageData = ctx.getImageData 0, 0, canvas.width, canvas.height
  data = imageData.data
  tmpFile = new temporary.File

  rs = canvas.pngStream()

    ws.once 'close', ->
      fs.fsync fd, ->
        try
          callback null, tmpFile
        catch error
          callback error
          tmpFile.unlink()
  rs.pipe ws

runScdDetect = (tmpFile, cascade, callback) ->
  bin = path.join __dirname, '../build/Release/scddetect'
  exec "#{bin} #{tmpFile.path} #{cascade}", (err, stdout, stderr) ->
    if err
