O'Reilly Forums: Videobooth Effects Do Not Work - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Videobooth Effects Do Not Work downloaded code doesn't work

#1 User is offline   Seth Close 

  • New Member
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 10-February 12

Posted 10 February 2012 - 12:21 PM

The processFrame function has some issues with it. I even tried running the downloaded code directly, and it still does not work. Has no one else picked up on this?

On page 397, there is the processFrame function. I find that it fails when trying to retrieve the frame.data.length.

Also, note other errors:

"buffer.drawImage(video... , bufferCanvas.width, displayCanvas.height);"

This should use "bufferCanvas.height", as it is on the previous page.

"for (var i=0; i<length; i++)"

This should use "i+=4", since each loop goes through 4 pixels.

I looked around online and can't figure out why that length is not being calculated correctly.

Oh, also, loop doesn't work on the downloaded version either. I thought it was because of how we were not handling it in the endedHandler, but it wasn't.

This post has been edited by Seth Close: 10 February 2012 - 12:37 PM

0

#2 User is offline   Beth Robson 

  • Advanced Member
  • PipPipPipPipPipPip
  • Group: O'Reilly Employee
  • Posts: 230
  • Joined: 17-September 08
  • Gender:Female
  • Location:Seattle, WA
  • Interests:I am interested in computer science, the Web, social media and the internet, Mac development, and adult learning.

Posted 11 February 2012 - 03:32 PM

First, the displayCanvas and the bufferCanvas are the same height, so it should work (although you're right, it's an error in the book).

Next, you want to leave the loop as it is, that is, i++, not i+4. Because we're using i as a multiplier into each part of the array, if you try it out on i = 0, i = 1, i = 2, you'll see that it does the right thing.

Sounds like there might be an issue with the current version of Firefox with the frame.data.length, so try another browser.

Elisabeth
Elisabeth Robson
Co-founder, WickedlySmart.com
Author: Head First HTML5 Programming, Head First HTML and CSS, Head First Design Patterns
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users