From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Student Projects

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Piano Project

LabVIEW Student DesignCompetition

- SUBMISSION TEMPLATE -

Virtual Piano Project  1.2

Contact Information:


University: Università degli Studi di Salerno (Italy)

Team Member(s): Luigi D'Acunto, Lluis Bolivar, Mariano Ribas, Rafael Vidal

Faculty Advisors: Prof. Antonio Pietrosanto, Dr. Alfredo Paolillo

Email Address: pipizanzibar@hotmail.com

Project Information:

Title: Virtual Piano Project 1.2


Description:

This Software creates a piano keyboard using a projector, detects if somebody plays a key and plays the note as it was a real piano. It's composed by three essential parts:

1.     Projector Calibration

2.     Camera Calibration   

3.     Finger tracking

Products:


LabView 2009 SP1

Vision 9.0


The Challenge:

When you start reading this article you may ask yourself : “ what is a Virtual Piano?” A virtual piano doesn’t really exist,  because it’s made up of a projector, and you can play it with your fingers or with a stick.

Virtual Piano project is not only a funny game, but the beginning of a road that leads to a new kind of technology. In fact, in a not very distant future, we can imagine that every interface peripheral as a keyboard or a mouse, may be replaced by a projected one,  much more portable, quicker and easier to use.

In the musical area, with this kind of technology, everyone should be able to play a keyboard or a drum everywhere without carrying heavy instruments.

The Solution:

Our solution requires a projector, a camera and a pc with LabView and it can be divided in three esential parts:

1.     Projector Calibration

2.     Camera Calibration  

3.     Finger tracking

So now we are going to explane all the steps we made to reach the final result that can be watched on the linked video.

Test Conditions:

  • -          Hardware:

    • Camera: colour  camera kit CC6 (DFK31F03)
    • Projector: 3M MPro150 Pocket Projector
    • Computer

  • -          Software:
    • LabView 2009 SP1
    • Vision 9.0
    • NI-IMAQdx 3.7
  • -          Dimensions:
    • The height between the projector and the platform of projection is 48cm.
    • The height between the camera and the platform of projection is 41cm.
    • The horizontal distance between projector and the platform is 37cm.
    • The horizontal distance between camera and the platform is 37 cm.
    • The distance between projector and camera is 75 cm.

These dimensions can be modified, but then is necessary to redo the calibration of both projector and camera


image001.jpg

                                                                                                         Figure 1: Camera & Projector system

Calibration:


image002.jpg

                                                                                                  Figure 2: Block diagram of the calibration of  both projector and camera

You may wish to avoid the calibration by putting  the projector orthogonally to the plane of the piano, but this solution is not possible, because the hand of the user would be totally between the light and the piano and so it would cover the projection.

So we angled the projector more or less of 45 degrees and then we used a “vi” to calibrate it correctly with a homography.

image006.jpg

                                                                                         Figure 3: H matrix definition

So it is possible to make up a relationship between m (pixel coordinates) and M (absolute coordinates) by using the H matrix.

One way is to calculate the A matrix shown below, using at least four points of calibration of which we have to know, or should be able to calculate, the absolute  and the pixel coordinates.

We decided to use 8 targets of calibration (8 crosses) of which we know the centroid coordinates.

                                                                           image_004.JPG

                                                                Figure 4: Projector point of view

The homography just makes up the A matrix, as shown in the figure below:



image007.jpg

                                                                                Figure 5: Labview code that generates the H matrix and calculate the error of re-projection

Then it’s possible to obtain the H matrix by using the SVD (single value decomposition), that calculates:

image008.jpg

Now it’s possible to demonstrate that, the H matrix lays in the last column of V matrix. So, once reshaped the last column of V matrix, we have obtained the H matrix for the projector.

Once it’s verified that the re-projection error is smaller than 1% it’s possible to project the piano keyboard, otherwise it’s necessary to check the absolute and pixel coordinates. The shift (of 1920 pixel) is a parameter accessible to the user and it depends on the screen resolution.

image009.jpg

                                                                      Figure 6: Labview code that generates and projects the keyboard using extended desktops

We did not put the black keys because this is just a demonstration of LabView possibilities and not the final version of the software.


Camera Calibration:

Camera calibration is not completely necessary but it’s very helpful in the detection of the position of the finger, so we decided to make it by projecting circular-shaped black targets and by detecting the position of the centroids with the count-object function.  In this way we obtain the pixel coordinates of the centroids; so,  because of the fact we have got absolute coordinates of the centroids, that are the same used for the projector, it is easily possible to obtain the H matrix of the Camera with the homography. The H matrix will be used in finger tracking.

image_010.JPG

                                                                                             Figure 7: Camera Point of view

Finger Tracking:

This is the most important VI of the project because it detects the position of the finger and plays a sinusoidal tone at the real frequency of the note. In a while loop, breakable by the user, the camera RGB frames are continually acquired (but we just use a grayscale U8 image for the detection).

image011.png

                                                                                                                         Figure 8: Acquisition of frame

For each frame a pre-filtering sub-vi is made that, using the H matrix acquired in camera calibration, resizes the frame’s dimensions in order to reduce the computationally coast of the algorithm and paints every pixel that lays out of the keyboard in black. This pre-elaboration of the image lasts not more than 10 ms, so it’s quick and very helpful, since it cuts every unwanted detail off.

image012.png

                                                                                                              Figure 9: Action of the prefilter

Next of the pre-filtering, the frame of the nth acquisition is compared (with an absolute difference) to the first frame acquired by the camera, that will be used as a mask for every following frame,  and with a threshold, whose range can be controlled by the user, it’s possible to obtain a binary black and white image.

Working  in this way the noise between the first and the nth frame (that can be imagined as a small pixel value variation) is fully cut off. 

The threshold is set by default in order to change every pixel of grey value greater than 60 into white and every pixel with grey level smaller than 60 into black.

So now, before we put the finger on the piano, because of the small variations between the frame 0 and the nth frame, the image viewed should be totally black.

When something as a finger or a tick enters the keyboard, the comparison and the following threshold make it totally white. Now by using a Count-Object.vi  function, all the bright objects in the image bigger than a minimum area are identified. 

This means two things: you can detect more than one object at the same time, so it’s possible to play with more than one finger , and that the shadow of your finger would be identified as if it were a finger! image013.png

                                                                                                   Figure 10:  The finger (obj 0) and its shadow (obj 1)

image014.png

                                                                           Figure 11: Labview code that finds the finger

Anyway, due to the relative positions of camera and projector we chose ,the shadow of the finger results always at the right of the finger.

So, because it was not in our interest to play more than one note per frame, we preferred  to consider just the first of the objects detected by the Count Object.vi  function.

This choice implies that it is not possible  to play the keyboard using more than one finger per time, but the bigger advantage is that the shadow of the finger, that during the transitions from a note to another is detected just like a finger, does not influence the played note.

In order to detect the note we use the centroid pixel-coordinates of the object found and we compare them, by using the H matrix, with the absolute-coordinate of the projected keyboard.

This is an extremely strong solution because it can solve  “danger” situations in which the finger  appears to be playing more than one note from the point of view of the camera.

image015.jpg

                                                                                          Figure 12: Labview code that decides if a centroid of an object is part of the piano

So in every iteration of the loop in which a note is detected, a sound made of a number of samples is played and can be chosen by the user. The default is 8000 samples.

Choosing a bigger number makes the sound much cleaner, but slows down the performances of the algorithm introducing a delay between two different sounds.

The sounds played are pure sinusoidal tones generated at the real frequency of the notes according to the twelve-tone equal temperament.

image016.jpg

                                                                                                           Figure 13 : Block Diagram of the Finger Tracking

Final considerations:

The image analysis lasts about ten milliseconds with the pc used to test the software.

This is an important detail because algorithms that analyze every pixel of the image are not good for this kind of problem: the frame acquisition made by the camera results too slow. The finger tracking algorithm, instead, makes possible to acquire more than ten frames per second!

We called it finger tracking because of its continuous research of the centroid of the finger.

Finger tracking is a versatile and strong solution: because of the fact that calculates the centroid coordinates of the object that appears on the keyboard it is possible to play piano with every kind of object, or to allow only fingers to play.

The limits of this kind of solution are that the pressure of the digit is not detectable and that it doesn’t work good in very bright environments.

The main advantages are the speed of execution and the possibility to easily adapt the algorithm to whatever function.

In future it is possible to imagine an application of this experimental project maybe integrating a projector in a mobile phone and giving the user the possibility to play piano everywhere, or to have a keyboard or a mouse to remote control their mobile phone in a totally portable way.

Immagine_nuova.PNG

                                                                                                                                          Figure 14: Frontal Panel

****

In the file project.zip there are two folders: Calibrazione_proiettore and Acqusizione_tastiera.

The Calibrazione_proiettore_folder contains all the "vi" and subvi necessary for the projector calibration.

The Acquisizione_tastiera_ed_elaborazione_folder contains some txt files necessary for the projection of the keyboard and testing operation, some SUBvi and the file main.vi.

Main.vi contains all that is necessary to correctly calibrate the camera, to find the finger and find the note. So it is the most important vi of the project.

Powered by:

Luigi D’Acunto     (Università degli studi di Salerno)

LLuis Bolivar        (Universitat politecnica de Catalunya, Spain, Erasmus @ Università degli studi di Salerno, Italy)

Mariano Ribas     (Universitat politecnica de Catalunya, Spain, Erasmus @ Università degli studi di Salerno, Italy)

Rafael Vidal         (Universitat politecnica de Catalunya, Spain, Erasmus @ Università degli studi di Salerno, Italy)

Comments
LPS
NI Employee (retired)
on

Hello there,

Thank you so much for your project submission into the NI LabVIEW Student Design Competition. It's great to see your enthusiasm for NI LabVIEW! Make sure you share your project URL(https://decibel.ni.com/content/docs/DOC-16527) with your peers and faculty so you can collect votes for your project and win. Collecting the most "likes" gives you the opportunity to win cash prizes for your project submission. If you or your friends have any questions about how to go about "voting" for your project, tell them to read this brief document (https://decibel.ni.com/content/docs/DOC-16409).

I'm curious to know, what's your favorite part about using LabVIEW and how did you hear about the competition? Great work!!

Good Luck, Liz in Austin, TX.

mimmonapoli9
Member
Member
on

f. yeah

pipizanzibar
Member
Member
on

Hi Liz, thanks for your appreciation

I knew about this competition from my faculty advisor..the prof A.Paolillo! What i like most about LabVIEW is that makes simple things that seem to be difficult or impossible

HydRa
Member
Member
on

awesome!

Pasks
Member
Member
on

great!

giamapa
Member
Member
on

very good

sg27
Member
Member
on

fantastic!!!

AdBC
Member
Member
on

lo voglio usàààà

paoloskiera
Member
Member
on

...............sooooooo coooooooll!!!!!!! WONDERFULL!

opera
Member
Member
on

fatto bè!

opescopesc
Member
Member
on

davvero un gran bel progetto !!!

Affonzo
Member
Member
on

Un progetto eccezionale veramente ! Quello che mi piace di più è quel gruppo di giovani (che è possibile ammirare nel  video) che si esibisce con un brano inedito ! 

brrrr
Member
Member
on

Super!!!!!

dar0x
Member
Member
on

Bello davvero, usate qualche funzione per l'EROSION/DILATION ?    

asdasd123
Member
Member
on

Bel lavoro!

Luca_Gallo
NI Employee (retired)
on

davvero bello. great job chicos

Luca Gallo
Sales Engineer
Fabio_Signorini
NI Employee (retired)
on

and the winner is....great job!!!

pipizanzibar
Member
Member
on

No..usiamo una threshold..è più che sufficiente!

pipizanzibar
Member
Member
on

thanks for your appreciation

Chuck_81
Active Participant
Active Participant
on

Good job!!! !

Fabio M.
NI
Principal Engineer
RobyI
Member
Member
on

Amazing! Have you already written a case study for this application? Cong.

Gimmy
Member
Member
on

very good luì

vacca
Member
Member
on

it's incredible!!!

Lucietta
Member
Member
on

giuseppecaruson
Member
Member
on

..

hanyang19861017@163.com
Member
Member
on

come on .you are innovative ,i am harry from Hangzhou City ,Zhejiang Province in China ,thank for your innovative design

dieguitones
Member
Member
on

binocolo tridimensionale a livelli proprio massicci. complimenti vivissimi e in bocca al bue

Renato_Zanovello
Member
Member
on

Congratulations ! Good Job !

Luuuuuuuuuuudo
Member
Member
on

=))))))))

moghy
Member
Member
on

Angelo92
Member
Member
on

Very Good!

ade92
Member
Member
on

wow I really like it

impresive

ade92
Member
Member
on

wow love it

ade92
Member
Member
on

really good job

Ludovico1123
Member
Member
on

I can't believe it.... Awesomes!!!

pipizanzibar
Member
Member
on

Hi, thank you so much for your appreciation!! we haven't done a case study about this project but I'd be very happy to keep working on it!

carlone
Member
Member
on

bei capelli

catetere
Member
Member
on

sono un felice puzzante

bigna_72
NI Employee (retired)
on

Amazing!

Yuritlov
Member
Member
on

mr T

alibertone
Member
Member
on

alla faccia del cane e che proggeto bellillo propio

BromuroRoncalli
Member
Member
on

I like it, but it seems to be perfectible

vergine
Member
Member
on

bell bell verament bell

PochoLoco777
Member
Member
on

ahahahah luììì si u solit scuppiat !

tolomeo
Member
Member
on

very nice, reaaaaaaaallyyyyyyyy nice.
I think I love you ❤️

Luc1
Member
Member
on

unbelievable

aeroplano
Member
Member
on

OBLADì

OdoacreinTechni
Member
Member
on

ernè

carciofo
Member
Member
on

ecceziounale

caniello
Member
Member
on

looool

Contributors