Instructables

Invisible Piano (Keyboard Anywhere, a Kinect Piano)

Featured
Picture of Invisible Piano (Keyboard Anywhere, a Kinect Piano)
Screenshot-6.png
Screenshot-8.png
After writing my previous instructable, I was asked about installing some slightly different software to use with the Kinect. Since I'd already done it, I figured it wouldn't take to long to retrace my steps and write the instructable. After much frustration, I figured out a really easy process to get everything installed and talking.

This instructable with walk you though getting a virtual keyboard working with the current release (11.04) of Ubuntu.

There are other ways of doing this (which I've done in the past), but trying to reaccomplish the task, I found many shortcuts to what I did in the command line previously.

If you have any questions on the command line or getting around in Ubuntu, please see my previous instructable. In this instructable I will assume you have a basic knowledge of the system and how it works. Like my last instructable terminal commands will be given starting with $. Do not copy the $ when transposing.

Also, don't transpose anything to terminal between [ ], it's there for reference.
 
Remove these adsRemove these ads by Signing Up
promach1 year ago
Hi everyone, I have installed everything except the extra .deb file because I do not know how to deal with libexpat dependency which I have fulfilled in my Ubuntu 12.04. I have this problem :

terminal output: transform loaded from file

AND 

a blank untitled window output

May I know why ?
StumpChunkman (author)  promach1 year ago
I've very sorry. All the software in this instructable is a year and a half old, and most of it has been updated since I posted this. Since I haven't kept up on new Kinect software since I wrote this up, I'm not sure how everything interacts with all of the new software.

Please ensure you're following the OpenKinect's read me/install files and that you're installing all of the dependencies. Other then that advice, I'm not going to be any help.
Esra_Juma1 year ago
I have used Instructable website to get an idea to my project which was very useful to us.
My project is Invisible Piano Keyboard anywhere
I downloaded all the software needed as well as the hardware, but I have the following error whenever I tried to run it:

Could you help us please
Thank you in advance

Error: Invalid index [0]
Error: Can't open device. 1.) is it plugged in ? 2.) Read The README
Tracback (most recent call last ):
File "keyboard_anywhere.py" , line 286, in animate depth,
timestamp = freenect.sync_get_depth()
TypeError: 'NoneType' object is not iterable
could not claim interface on motor: -6
StumpChunkman (author)  Esra_Juma1 year ago
I'm sorry, I haven't used the application in long enough that I couldn't say what might be wrong. It kind of sounds like you're missing a dependency though. Make sure you install all of the required items first.
tdinsmoor2 years ago
I really appreciate you posting this here, it's quite an amazing feat.
Just wanted to let you know, the install for python-dev did not work for me.
This was on a brand-new install, so it might be broken for everybody. It gave me the following error message on 12.04 Precise:

The following packages have unmet dependencies:
python-dev : Depends: python2.7-dev (>= 2.7.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Now, I've tried to get the packages they depend on, (python-dev -> python2.7-dev -> libexpat1-dev [ Depends: libexpat1 (= 2.0.1-7.2ubuntu1.1) but 2.1.0-1ubuntu1 is to be installed {I have no idea why this is happening}] -> libexpat1 [which I have already]) and looked all around to try to fix this (especially the "broken packages" part, and tried a reinstall of all my packages after purging), maybe python 2.7.3 is no longer supported on 12.04 (as newest python is 3), but I have little idea. The strange thing is, I got it working before, but I ignored all the warnings and proceeded with the next step anyway. After trying to install GTK3+ (I wanted to try compiling some source code for a 3d-modeling program), my Ubuntu install broke for whatever reason (wouldn't even get to login screen), and I don't want to go through that again.

I'm an Ubuntu noob (trying, though). Could ya help a brother out? Please email me at tdinsmoor13@gmail.com if you or anybody is having the same problem and found a solution, or the possibility of a solution.

Thanks, again.
StumpChunkman (author)  tdinsmoor2 years ago
If you open Terminal, and type "python" into the prompt, you'll see which version of python you have installed on your system. You can use Ctrl-D after you figure out to backtrack out of the python interface back to the Terminal prompt. I'm running an updated (as of today) Ubuntu 12.04 system. My system has Python 2.7.3 installed on it. While Python 3 is out, it doesn't always work with everything, so it's not being rolled out in mass just yet. If you've upgraded to Python 3, you should try reverting, that could be the cause of your problem.

You should also check out the Ubuntu Install over at OpenKinect, it looks like libfreenect causes some issues with 12.04. I think you just need to follow the Official Packages install instructions for that portion.

Once you get that installed, make sure you follow the directions on the Python Wrappers Read Me. The directions there are going to be far more current then the code in my instructable. It looks like the only super requirements right now are getting cython, python-dev, and python-numpy. So install those before you try to compile.

If it doesn't work with following their instructions, then something in 12.04 may have mucked things up. You could try installing everything on an older build of Ubuntu as that might fix it. I know it worked on 11.04, but if it's not Ubuntu's fault, and something was changed in the OpenKinect code with dependancies, then I'm not sure what the problem might be.

I'm not sure if this helped at all, but best of luck. Is your only goal to get the Kinect display working, or do you need this specific app to run?
I've got it to work, just long story short, it was giving me trouble with python-dev, saying that I needed dependencies that I already had installed (on the manual install that you instructed)

The only reason why I posted here is that I was worried that this led up to my Ubuntu install breaking, because I used manual install then, but ignored the error (being the super-noob I was at the time). After I got it workIng (the keyboard-anywhere) I tried installing GTK3+ so I could try to compile the source code for a 3D model capturing program that needed it.
I was just worried that the error I ignored before led up to my system failure, but that seems unlikely.

Just trying to rule out possibilities, because I don't know what exactly caused it, so that I don't do it again when I try again. (I don't expect help from here, seeing as how this isn't the place. Thank you for your quick response, and the instructabke!
StumpChunkman (author)  tdinsmoor2 years ago
Not a problem. I'm glad to hear everything is working! Here's hoping you have no more system issues.
I... Take it back that I got it working. I spoke before I thought.
I'll dump it, maybe you can make some sense of it.

====Trying to setup python..

dinsmoor@Dinsmoor-MU:~/libfreenect/wrappers/python$ sudo python setup.py installrunning install
running build
running build_ext
skipping 'freenect.c' Cython extension (up-to-date)
building 'freenect' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c freenect.c -o build/temp.linux-x86_64-2.7/freenect.o -fPIC -I ../../include/ -I /usr/include/libusb-1.0/ -I /usr/local/include/libusb-1.0 -I /usr/local/include -I ../c_sync/ -I /usr/lib/python2.7/dist-packages/numpy/core/include
freenect.c:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

====So, I make sure I have all my python packages...
====Now, this is when python-dev refuses to install:


dinsmoor@Dinsmoor-MU:~/libfreenect/wrappers/python$ sudo apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
python-dev : Depends: python2.7-dev (>= 2.7.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

===And then I try to get python2.7-dev (but python reports that i's already 2.7.3):


dinsmoor@Dinsmoor-MU:~/libfreenect/wrappers/python$ sudo apt-get install python2.7-dev
[sudo] password for dinsmoor:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
python2.7-dev : Depends: libexpat1-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then I try to get libexpat1-dev...

dinsmoor@Dinsmoor-MU:~/libfreenect/wrappers/python$ sudo apt-get install libexpat1-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libexpat1-dev : Depends: libexpat1 (= 2.0.1-7.2ubuntu1.1) but 2.1.0-1ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

====This one says it needs libexpat1, but it gives me a funky thing about it not ====being the right Ubuntu? I'm not sure how to interpret this. Anyway, I try for ====libexpat1..


dinsmoor@Dinsmoor-MU:~/libfreenect/wrappers/python$ sudo apt-get install libexpat1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libexpat1 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

====So, it's something to do with my system?
If you could help me out man, I'd be so grateful. I'll post anything you need me to have it spit out. I'm just at a loss, since I got it working once, doing the exact same thing. (minus the system failure)
StumpChunkman (author)  tdinsmoor2 years ago
No, Sir... Giving me same result.
I scoured Google for hours looking for a solution, and I've found and tried that solution (and again now, just to double-check for you)
I've tried everything that comes to mind.
Everything on others' minds.
Doesn't make sense to me.

Got any more magic up your sleeve?
Or should I ask the Ubuntu community?

Also, thanks for the quick reply.
StumpChunkman (author)  tdinsmoor2 years ago
I'm not sure what to suggest. I think you've reached the limits of my knowledge. The Ubuntu community knows a ton though and will probably be able to help you out. Sorry I couldn't be more useful.
It took me a few days, but I've found the solution. You need to get the libexpat1-dev package for Ubuntu 12.10 Quantal.

For amd64 systems: https://launchpad.net/ubuntu/quantal/amd64/libexpat1-dev/2.1.0-1ubuntu1

Just had to know what to look for.
Hey, thanks for trying to help me, but here's a solution for some people. You may need to modify your instructions for python wrapper, some of my students were having the same problem, even with a fresh Ubuntu 12.04 install.

Instruction addition:
**
If you are having dependency issues with libexpat1-dev (on Ubuntu 12.04), you'll need to download and install a separate .deb package to fix it.
For AMD64 systems:
http://launchpadlibrarian.net/118383909/libexpat1-dev_2.1.0-1ubuntu1_amd64.deb
For i386 systems:
http://launchpadlibrarian.net/118383396/libexpat1-dev_2.1.0-1ubuntu1_i386.deb

Ubuntu software center may give you an error at first, but ignore this and proceed to install python2.7-dev and python-dev with:
$ sudo apt-get install python-dev python2.7-dev

The packages should now install correctly, and you may proceed to install the wrapper.
**
StumpChunkman (author)  tdinsmoor2 years ago
Also, if you have student just trying to learn about the Kinect, how it works and getting into the mechanics of it, I found Processing and this library incredibly useful. They're easy to install, and worked straight away for me.
Thank you for the links and also the recognition!
I'll look at the links, and see how they like it.
This exercise was more of a "figure it out, fool" type of experiment, a chance for them to do it themselves.
You're welcome and thank you!
StumpChunkman (author)  tdinsmoor1 year ago
Also, if you haven't seen this before, you should check it out.
StumpChunkman (author)  tdinsmoor2 years ago
That's awesome! Thanks so much for letting me know what the fix was! I've edited this step to reflect your suggestion. Please let me know if you find anything else. It's really hard to keep software instructions up to date when you no longer work with the software, so I really appreciate the update!
preluderd2 years ago
I am getting an error when I run 'sudo python keyboard_anywhere.py'

Traceback (most recent call last):
File "keyboard_anywhere.py", line 21, in
import PyQGLViewer
RuntimeError: the PyQt4.QtCore module is version 1 but the PyQGLViewer module requires version -1

I have followed the instructions to a T.
StumpChunkman (author)  preluderd2 years ago
That sucks. I'm really sorry to hear that.

Sadly I haven't installed this in quite a while, but I know that they've come out with updated versions of everything I've listed here. Are you sure you're downloaded the versions that I recommend?

I'm not sure that I can help you without reinstalling the applications from scratch again, which isn't on my list of things to do.

It seems like it's looking for the right thing, but with the wrong digit. I'm really not sure what's going on though.

Best of luck.
strandhoull3 years ago
Hey,
would it be possible to put the layer on stairs, so when going up the stairs (or down) you´ll be able to play the piano? i´m thinking of combining kinect with these Stockholm stairs in my school.

Stockholm stairs: http://www.youtube.com/watch?v=2lXh2n0aPyw

StumpChunkman (author)  strandhoull2 years ago
That would be possible, but difficult. When people were between the camera and the note, it would block the note. It'd be better to use pressure sensors for that, and you can make those for pretty cheap depending on what you need.
jdevriendt2 years ago
Merci beaucoup !!!
thx for this awesome project
locofocos3 years ago
Thank you!!! It's good to see someone finally sorted through all the problems with dependencies and such. I would hate to see such an amazing think like a kinect piano go to waste because the open source community can't get their tools to work together, and you've made sure that won't happen. Awesome.