A13-OLinuXino-WIFI running SCRATCH + OPEN-CV demonstration


Now when we know how to interface new blocks in Scratch IDE with python and having OpenCV library up and running on OLinuXino it was matter of time to make the new project.

There is already nice project written in Scratch with eyes tracking your mouse pointer: http://scratch.mit.edu/projects/Doody/269924

Also we show you OpenCV object tracking http://www.youtube.com/watch?v=CigGvt3DXIw

Now we decided to combine both in single project:

1. Install scratchpy

# git clone git://github.com/pilliq/scratchpy.git
# cd scratchpy

    !!!IMPORTANT: Make sure that you date is set:
# date -s "3 APR 2013"
# python setup.py install

2. Install OpenCV

# apt-get install libopencv-dev python-opencv

3. Install Scratch

# apt-get install scratch

4. Open Scratch and open the demo project Eyes.sb

5. A message should appear that remote sensor connection is enabled.

If doesn’t click on “Sensing”, right click on sensor value and click “Enable remote sensor connection”.

6. Open terminal and start the tracking program

# python track.py

7. This will track yellow ball and the eyes will look at this direction

8. If you want to use some other object with different color use config.py.

Start the config:

# python config.py
Move the sliders until only the desired color is white and everything else is black.

Open track.py and edit the following line:
 cv.Scalar(0, 100, 255),
 cv.Scalar(40, 255, 256),

Write your values, for example:

 cv.Scalar(110, 98, 100),
 cv.Scalar(131, 255, 256),

Then just start the file:

# python track.py

If you wonder what does line 77 k = cv.WaitKey(70) this is delay as OpenCV track the object very fast and send coordinates faster than Scratchpy + Scratch can handle which leads to buffer overflow, with this delay the object tracking is artifically delaed to may Scratch have time to update the animation properly.

Here is video of this project: http://www.youtube.com/watch?v=Pyidx-zOsm4

Note that the camera is put on the top of the monitor and displays mirrored object i.e. when you move the heart right the animation moves the eyes to the right but on the camera you see mirrored image 🙂

And the GitHub sources are HERE

Next OpenCV project – Face tracking is in progress, stay tuned 🙂

2 Comments (+add yours?)

  1. Ralph
    Apr 05, 2013 @ 11:48:26

    If installing scratchpy is step 1, I think you need a step 0. I just bought one of these boards. I am looking for information first on how to set it up to run Linux. If that article is already written, I’d suggest you point to it as step 0. For, as I look at my board, the first thing is not to run git. I have to have an OS first.


  2. OLIMEX Ltd
    Apr 05, 2013 @ 12:03:26

    if you have ordered the board with SD card with linux you should skip step 0 😉
    otherwise go to Olimex.com WIKI and download the official SD card image and write to SD card


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: