Tag: python

  • Download online course videos from Stanford Center for Professional Development

    Stanford Center for Professional Development

    It is particularly difficult to watch online videos on SCPD using a ‘mystanfordconnection’ account when you want to watch them at a faster speed, or when you want to watch them offline.

    To address these issues, I have written a Python tool that lets you download all the videos from the Stanford courses that you’re enrolled in, while they are still available to you. All the videos can be downloaded in parallel.

    Get download-scpd-videos. The instructions are for Mac OS X. For Linux or Windows, simply install the dependencies (mechanize, BeautifulSoup and mimms) using your package manager of choice, packaged binaries or building them from source.

    Note: Only for educational purposes. Use with explicit permission from Stanford Connection for Professional Development and for personal and non-commercial purposes only. Use this script with good judgment, common sense, discretion, and assume full responsibility for misuse. I accept NO responsibility for your use of this tool.

  • pyblobs with OpenCV 2.1 on Ubuntu 11.10

    pyblobs is a Python interface for cvBlobsLib. To use it with OpenCV 2.1 on Ubuntu 11.10 follow these steps.

    Prerequisites

    The following dependencies are required to use pyblobs library:

    sudo apt-get install swig
    sudo apt-get install libcv-dev
    sudo apt-get install python2.7-dev
    sudo apt-get install python-opencv

    If you are using Python 2.6, then use sudo apt-get install python2.6-dev instead.

    Getting the pyblobs library

    Use svn to grab the source code

    cd /path/to/Downloads/
    svn checkout http://pyblobs.googlecode.com/svn/trunk/ pyblobs-read-only

    Patching the files

    The code from the trunk as of now uses Python 2.5 (python2.5-dev) and not the best way to link shared objects in the make_swig_shadow.sh file. There is another issue with building the pyblobs library to be used with OpenCV 2.1 in the file BlobExtraction.cpp

    Hence, I have created two patch files for the aforementioned files:

    Download these to the same directory as the downloaded library (pyblobs-read-only) and then run the following commands in the terminal:

    cd /path/to/Downloads/pyblobs-read-only/
    patch make_swig_shadow.sh make_swig_shadow.patch
    patch BlobExtraction.cpp BlobExtraction.patch

    If you are using Python 2.6, then after patching edit make_swig_shadow.sh and replace any occurennces of python2.7 with python2.6 .

    Installation

    To install

    make
    ./make_swig_shadow.sh

    To check your install, go to your Python shell and try the following imports:

    >>> from blobs.BlobResult import CBlobResult
    >>> from blobs.Blob import CBlob

    If all goes well, you shouldn’t see any errors. Now you can work with pyblobs and OpenCV2.1 on Ubuntu 11.10!

    That said, to get the example file demo.py working, you might need to modify it a little to use objects and methods from the newer OpenCV Python API. For example, in my programs I replace

    from opencv import cv
    from opencv import highgui

    with import cv2.cv as cv to use the new API as cv.MethodName() instead of cv.cvMethodName() or highgui.cvMethodName(). Makes life a lot easier!