ipython-books / cookbook-code

[DEPRECATED] See the new edition:

Home Page:http://ipython-books.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with recipe 3.7

rossant opened this issue · comments

Posted by Anand Muglikar.

I used the ipython notebook shown below which uses your code as a base:

http://nbviewer.ipython.org/github/ipython-books/cookbook-code/blob/master/notebooks/chapter03_notebook/07_webcam_py3.ipynb

On running the code, webcam opens but no video is seen on Iceweasel browser (firefox based). On Chrome, webcam just starts and immediately shuts. I'm a newbie in Python and do not know javascript. Please guide.

Thanks in advance! :)

Which version of Python and IPython do you have? Any error messages? You can find error messages by pressing F12; this will open the Developer tools (at least on Chrome).

Thanks for the reply Cyrille! :)

anand@anandeb:$ python --version
Python 2.7.6 :: Anaconda 1.9.2 (64-bit)
anand@anandeb:
$ ipython --version
2.0.0

What exactly to look for in the developer tools?
I want to do something like this using your code, because that code of jsfeat is quite complex for me. Is it possible?

http://inspirit.github.io/jsfeat/sample_haar_face.html

Yes that's doable! Instead of applying an image filter Python-side, you can detect the face with something like OpenCV.

In the developer tools, look for potential errors in the "JavaScript console". Here is the doc for Chrome.

Hi there,

I'm also trying to use recipe 3.7. In fact, I'm unable to get it to run. When I execute the last cell from the notebook that should display the constructed widget, nothing happens.

From the discussion above, I figured out that I needed to check the JS console, which I did. It turns out that the execution of the last cell throws a couple of errors. After battling a little bit more I found what seems to be the root cause for me:

Class CameraView not found in registry

So I figured that the code in the cell defining the CameraView is not working properly defining the CameraView. I tried to copy paste the code from the cell that defines CameraView directly into my JS console and got yet another error message:

TypeError: WidgetManager.register_widget_view is not a function

Could you please tell me what you think about this? I'd love to use your example and build upon it. Thanks!

Are you using IPython 3.0? If so, that's expected. The widget interface has changed between 2.0 and 3.0 and I haven't had the time to upgrade the examples yet (it's on my list)... You'll find more information at http://ipython.org/ipython-doc/3/whatsnew/version3_widget_migration.html

Yes, that's exactly the case. In fact, I initially didn't use IPython 3.0 but then the notebook was not readable: it complained that the nbformat used was not the right one... So downgrading again to IPython 2.x and converting to an acceptable nbformat should do the job? Thanks for your quick reply!

Yeah I had to convert to the latest nbformat because the notebooks wouldn't work with IPython 3.0... but then the widgets are broken! Fortunately I think you should be able to open the notebooks if you install the very latest version of IPython 2.x: in principle they've backported the latest nbformat to the IPython 2.x branch. Let me know if it works (or not).

I downgraded and now it works in Firefox, but not Safari. Thanks!

The JS code says something about being able to set it to play / pause. Should there be a button for this, or not really?

I think there should be Play/Pause buttons in Google Chrome, not sure about Firefox.