Jump to content

Highlighting differences between consecutive video frames in Phaser


Recommended Posts

I would like to highlight differences from one video frame to the next using Phaser's built in video streaming library. So functionally, as a person moves their body, the changes from one frame to the next will be highlighted and all of the unchanging image parts will become black. The important code snippet currently looks like:

function create() {
 video = game.add.video();
 video.onAccess.add(camAllowed, this);

function camAllowed() {
 bmd = game.add.bitmapData(video.width, video.height);
 bmd.addToWorld(game.world.centerX, game.world.centerY, 0.5, 0.5);
 game.time.events.loop(50, takeSnapshot, this);};

function takeSnapshot() {
 video.grab(false,1,'difference');//params clear true or false, alpha, blend mode

The code almost works, but causes flashing video even for the parts of the scene that do not change from moment to moment. I played around with different globalCompositeOperation operations, many of which were trippy, not none which had the intended effect of making a completely black image except for where there was something different from the preceding to current frame.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...