SlideShare a Scribd company logo
The Virtual Projector
Alessandro Florio - 161704
University of Trento
Department of Information Engineering and Computer Science
Master of Science in Computer Science
Abstract. In this report we are going to explain how a movie is virtually
projected into an image, or into another video, replacing a white screen,
in order to reproduce an augmented reality scenario. In the case it is
projected on a video, the corners of the ”screen” are tracked through
each frame to update the area onto which the movie will be shown.
Table of Contents
1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Screen corners initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Image mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Video mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Projecting the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1 Introduction
The program can project a movie both on a still image which contains a screen,
and on a video in which the screen moves due to rotations and translations
of the camera. The code has been implemented in a way that, after compiling
the source, if the generated executable is called without arguments1
it runs by
default the video mode. If instead it is executed with an argument2
, whatever
this may be, it runs the image mode.
This has to be kept in mind when running the executable file with the ”-r”
option which saves the execution to a video file called output.avi: in fact, adding
this option toggles the execution mode for the rule described above (see also the
relative footnotes)!
In the following sections we are going to describe in detail how the algorithm has
been implemented, always explaining the differences and similarities between the
image and video mode.
2 Screen corners initialization
The procedure of initializing the screen corners follows two different approaches
in the image and video modes: for the first one it is manual, so that it can be
easier to change the image with the screen on which the movie is projected,
while for the second one it is automatic, but in order to be so it needs to do
some image cleaning which was studied for the provided video and which may
not adapt to all situations.
1
or with an even number of arguments
2
or with an odd number of arguments
2.1 Image mode
As mentioned above, in the image mode users can select the four points of the
image which represent the screens corners. This is done by clicking with the left
mouse button at the right position. In case of mistake, pressing ’c’ will clear
all the inserted points. When the four points have been correctly marked, by
pressing ’s’ the projection starts.
2.2 Video mode
Differently from the image mode, in the video mode the four corners are identified
automatically as the four best features to track3
in the first video frame. To do
so, the screen was constructed as a white area with a black solid border in
order to increase the contrast on the extremities. The frame is then converted to
the grayscale color space, and subsequently binary thresholded to simplify the
identification between screen, border and the rest of the environment. Since the
border is quite thick, each corner would be identified twice: the binary image is
therefore substituted by its skeleton. Then, the identification of the corners is
immediate; when this last operation is completed, the projection can start.
3
see [1]
3 Projecting the movie
Projecting the movie as in an augmented reality scenario is just a matter of
warping every frame of the movie using a perspective transformation in order
to fit in the actual screen position. While the perspective transformation in the
image mode has to be computed only at the beginning - since the screen does
not move, and so its corners do not change - in the video mode, where the screen
position changes from frame to frame, the corners have to be tracked and the
projection has to be recomputed every time. Tracking is performed through the
OpenCV function calcOpticalFlowPyrLK which calculates an optical flow for a
sparse feature set using the iterative Lucas-Kanade method with pyramids4
.
The warped image is computed using the OpenCV function
getPerspectiveTransform which, given in input the four absolute corners of the
movie and the four corresponding corners of the screen5
calculates the 3 × 3
matrix M of a perspective transform such that:

tixi
tiyi
ti

 = M ·


xi
yi
1

 where
(xi, yi) is the ith
corner of the movie
(xi, yi) is the ith
corner of the screen
for i = 0...3
We recall that the matrix has to be computed only once in the image mode,
but has to be recalculated at every frame, after identifying the new positions of
the screen’s corners through the optical flow computation, in the video mode.
The projection matrix M is used for every frame of the movie in the OpenCV
function warpPerspective which creates a new image from the source movie frame
where dst(x, y) = src
M11x + M12y + M13
M31x + M32y + M33
,
M21x + M22y + M23
M31x + M32y + M33
.
The warped movie frame is then copied on the screen, removing all the black
pixels left from the transformation which lie outside its border.
4
see [2]
5
corners both of the movie and of the screen were ordered clockwise starting from the
top-left one
4 Conclusion
We have implemented a virtual projector which suits an augmented reality sce-
nario and which is very stable and generates a fluid and realistic video. The
program can also save the execution to a video file6
, so the output can be used
for other applications.
To sum up, we present here a pseudo-code of the algorithm, which recaps in
short the main parts of the implementation:
// media definition
Mat frame
if IMAGE MODE then
frame ← screenImage
else if VIDEO MODE then
frame ← video.at(0)
end
// corners’ initialization
Point[] corners
if IMAGE MODE then
corners ← frame.getFourPointsFromUser()
else if VIDEO MODE then
frame.convert(gray)
frame.threshold(binary)
frame.opening()
frame.thin()
corners ← goodFeaturesToTrack(frame, 4)
end
int w ← movie.cols - 1
int h ← movie.rows - 1
Point[] movieCorners ← {(0,0), (w,0), (w,h), (0,h)}
Mat projectionMatrix
if IMAGE MODE then
// order the cornes as movieCorners, so they can be correcly mapped
corners.orderClockwiseFromTopLeft()
projectionMatrix ← getPerspectiveTransform(corners, movieCorners)
end
// continues on next page...
6
as described in the second paragraph of the Introduction
// play the movie
forall movieFrame do
if VIDEO MODE then
/* compute the corner’s actual position based on the optical flow
* between the previous and the current frame, and the previous
* corners’ positions */
corners ← calcOpticalFlowPyrLK(prevFrame, frame, corners)
// order the cornes as movieCorners, so they can be correcly mapped
corners.orderClockwiseFromTopLeft()
// re-compute the projection matrix for this frame
projectionMatrix ← getPerspectiveTransform(corners, movieCorners)
end
Mat projection ← warpPerspective(movieFrame, projectionMatrix)
projection.copyNonZeroPixelsTo(frame)
show(frame)
end
References
1. Jianbo Shi and Carlo Tomasi, ”Good features to track”
2. Jean-Yves Bouguet, ”Pyramidal Implementation of the Lucas Kanade Feature
Tracker Description of the algorithm”
3. http : //docs.opencv.org/modules/video/doc/motion analysis and object tracking.html
4. http : //docs.opencv.org/modules/imgproc/doc/geometric transformations.html

More Related Content

Viewers also liked

Bari smart city mediterranea
Bari smart city mediterranea Bari smart city mediterranea
Bari smart city mediterranea
Pasquale Capezzuto
 
Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1
laboratoridalbasso
 
Città ed energia - Energy Web Feltre
Città ed energia - Energy Web FeltreCittà ed energia - Energy Web Feltre
Città ed energia - Energy Web Feltrecondotta
 
Tersigni_Ance_24052011
Tersigni_Ance_24052011Tersigni_Ance_24052011
Tersigni_Ance_24052011Rèdais
 
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...Comune di Reggio nell'Emilia
 
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
AREA Science Park
 
Presentazione Asita 2012
Presentazione Asita 2012Presentazione Asita 2012
Presentazione Asita 2012
Mediterranea IGEA Srl
 
Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)Comune di Pordenone
 
Smart meeting brescia
Smart meeting bresciaSmart meeting brescia
Smart meeting brescia
Pasquale Capezzuto
 
Rappresentazione di modelli urbani CityGML su un globo virtuale
Rappresentazione di modelli urbani CityGML su un globo virtualeRappresentazione di modelli urbani CityGML su un globo virtuale
Rappresentazione di modelli urbani CityGML su un globo virtuale
Alessandro Florio
 
Presentazione scuola media_sant_angelo_nuovo
Presentazione scuola media_sant_angelo_nuovoPresentazione scuola media_sant_angelo_nuovo
Presentazione scuola media_sant_angelo_nuovo
Sentinelle dell'Energia - SELENE
 
Ldb neetneedeu panetta 08
Ldb neetneedeu panetta 08 Ldb neetneedeu panetta 08
Ldb neetneedeu panetta 08
laboratoridalbasso
 
Ldb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adamLdb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adam
laboratoridalbasso
 
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTAWorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
RegioneLazio
 
PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01
Comune di Pordenone
 
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
infoprogetto
 
Ldb valecoricerca_quattrini_neuropatologia
Ldb valecoricerca_quattrini_neuropatologiaLdb valecoricerca_quattrini_neuropatologia
Ldb valecoricerca_quattrini_neuropatologia
laboratoridalbasso
 
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...Comune di Reggio nell'Emilia
 
Lironi. Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
Lironi.  Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...Lironi.  Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
Lironi. Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
Sergio Lironi
 
Ldb valecoricerca_indolfi_brevetti_3
Ldb valecoricerca_indolfi_brevetti_3Ldb valecoricerca_indolfi_brevetti_3
Ldb valecoricerca_indolfi_brevetti_3
laboratoridalbasso
 

Viewers also liked (20)

Bari smart city mediterranea
Bari smart city mediterranea Bari smart city mediterranea
Bari smart city mediterranea
 
Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1
 
Città ed energia - Energy Web Feltre
Città ed energia - Energy Web FeltreCittà ed energia - Energy Web Feltre
Città ed energia - Energy Web Feltre
 
Tersigni_Ance_24052011
Tersigni_Ance_24052011Tersigni_Ance_24052011
Tersigni_Ance_24052011
 
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...
Quartiere Mirabello_Programma di rigenerazione urbana del Comune di Reggio Em...
 
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
Contratti di rendimento energetico per gli enti pubblici: ricostruzione dei c...
 
Presentazione Asita 2012
Presentazione Asita 2012Presentazione Asita 2012
Presentazione Asita 2012
 
Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)
 
Smart meeting brescia
Smart meeting bresciaSmart meeting brescia
Smart meeting brescia
 
Rappresentazione di modelli urbani CityGML su un globo virtuale
Rappresentazione di modelli urbani CityGML su un globo virtualeRappresentazione di modelli urbani CityGML su un globo virtuale
Rappresentazione di modelli urbani CityGML su un globo virtuale
 
Presentazione scuola media_sant_angelo_nuovo
Presentazione scuola media_sant_angelo_nuovoPresentazione scuola media_sant_angelo_nuovo
Presentazione scuola media_sant_angelo_nuovo
 
Ldb neetneedeu panetta 08
Ldb neetneedeu panetta 08 Ldb neetneedeu panetta 08
Ldb neetneedeu panetta 08
 
Ldb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adamLdb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adam
 
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTAWorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
WorkShop 2 - Sapienza Università di Roma - Dipartimento PDTA
 
PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01
 
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
Progettare e costruire strutture energeticamente sufficienti - Alessandro Bal...
 
Ldb valecoricerca_quattrini_neuropatologia
Ldb valecoricerca_quattrini_neuropatologiaLdb valecoricerca_quattrini_neuropatologia
Ldb valecoricerca_quattrini_neuropatologia
 
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...
Area Reggiane - Programmi di Rigenerazione Urbana del Comune di Reggio Emilia...
 
Lironi. Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
Lironi.  Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...Lironi.  Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
Lironi. Rigenerazione Urbana Sostenibile ed Eco-quartieri : Università Padov...
 
Ldb valecoricerca_indolfi_brevetti_3
Ldb valecoricerca_indolfi_brevetti_3Ldb valecoricerca_indolfi_brevetti_3
Ldb valecoricerca_indolfi_brevetti_3
 

Similar to Virtual projector

Stereo Magnification Learning view synthesis using multiplane images.pptx
Stereo Magnification Learning view synthesis using multiplane images.pptxStereo Magnification Learning view synthesis using multiplane images.pptx
Stereo Magnification Learning view synthesis using multiplane images.pptx
SouravAhmed12
 
Augmented Reality Video Playlist - Computer Vision Project
Augmented Reality Video Playlist - Computer Vision ProjectAugmented Reality Video Playlist - Computer Vision Project
Augmented Reality Video Playlist - Computer Vision Project
Surya Chandra
 
1604.08848v1
1604.08848v11604.08848v1
1604.08848v1
Markus Höll
 
Lens Profile Creator
Lens Profile CreatorLens Profile Creator
Lens Profile Creator
massimiliano sticca
 
Pssx110 Is Cug En
Pssx110 Is Cug EnPssx110 Is Cug En
Pssx110 Is Cug En
ciuly
 
Canon PowerShot SX110 IS
Canon PowerShot SX110 ISCanon PowerShot SX110 IS
Canon PowerShot SX110 IS
ciuly
 
5 ray casting computer graphics
5 ray casting computer graphics5 ray casting computer graphics
5 ray casting computer graphics
cairo university
 
Jamel gantt a brief detail about camera effects
Jamel  gantt  a brief detail about camera effectsJamel  gantt  a brief detail about camera effects
Jamel gantt a brief detail about camera effects
Jamel Gantt
 
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERATHE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
National Cheng Kung University
 
Animation
AnimationAnimation
Animation
Vasu Mathi
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipei
Mao Wu
 
Animation
AnimationAnimation
Animation
Vasu Mathi
 
Animation
AnimationAnimation
Animation
Vasu Mathi
 
Recognition and tracking moving objects using moving camera in complex scenes
Recognition and tracking moving objects using moving camera in complex scenesRecognition and tracking moving objects using moving camera in complex scenes
Recognition and tracking moving objects using moving camera in complex scenes
IJCSEA Journal
 
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEOMETHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
IAEME Publication
 
A-Eye: Automating the role of third umpire in the game of cricket
A-Eye: Automating the role of third umpire in the game of cricketA-Eye: Automating the role of third umpire in the game of cricket
A-Eye: Automating the role of third umpire in the game of cricket
Aneesh Tg
 
Fundamentals of matchmoving
Fundamentals of matchmovingFundamentals of matchmoving
Fundamentals of matchmoving
Dipjoy Routh
 
Video to Video Translation CGAN
Video to Video Translation CGANVideo to Video Translation CGAN
Video to Video Translation CGAN
Alessandro Calmanovici
 
V Ray For Sketch Up 2007 Manual
V Ray For Sketch Up 2007 ManualV Ray For Sketch Up 2007 Manual
V Ray For Sketch Up 2007 Manual
Pheo8x
 
3D Workshop
3D Workshop3D Workshop
3D Workshop
James Uren
 

Similar to Virtual projector (20)

Stereo Magnification Learning view synthesis using multiplane images.pptx
Stereo Magnification Learning view synthesis using multiplane images.pptxStereo Magnification Learning view synthesis using multiplane images.pptx
Stereo Magnification Learning view synthesis using multiplane images.pptx
 
Augmented Reality Video Playlist - Computer Vision Project
Augmented Reality Video Playlist - Computer Vision ProjectAugmented Reality Video Playlist - Computer Vision Project
Augmented Reality Video Playlist - Computer Vision Project
 
1604.08848v1
1604.08848v11604.08848v1
1604.08848v1
 
Lens Profile Creator
Lens Profile CreatorLens Profile Creator
Lens Profile Creator
 
Pssx110 Is Cug En
Pssx110 Is Cug EnPssx110 Is Cug En
Pssx110 Is Cug En
 
Canon PowerShot SX110 IS
Canon PowerShot SX110 ISCanon PowerShot SX110 IS
Canon PowerShot SX110 IS
 
5 ray casting computer graphics
5 ray casting computer graphics5 ray casting computer graphics
5 ray casting computer graphics
 
Jamel gantt a brief detail about camera effects
Jamel  gantt  a brief detail about camera effectsJamel  gantt  a brief detail about camera effects
Jamel gantt a brief detail about camera effects
 
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERATHE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
THE 3D MODELLING USING FRAME CAMERAS AND PANORAMIC CAMERA
 
Animation
AnimationAnimation
Animation
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipei
 
Animation
AnimationAnimation
Animation
 
Animation
AnimationAnimation
Animation
 
Recognition and tracking moving objects using moving camera in complex scenes
Recognition and tracking moving objects using moving camera in complex scenesRecognition and tracking moving objects using moving camera in complex scenes
Recognition and tracking moving objects using moving camera in complex scenes
 
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEOMETHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
METHODS AND ALGORITHMS FOR STITCHING 360-DEGREE VIDEO
 
A-Eye: Automating the role of third umpire in the game of cricket
A-Eye: Automating the role of third umpire in the game of cricketA-Eye: Automating the role of third umpire in the game of cricket
A-Eye: Automating the role of third umpire in the game of cricket
 
Fundamentals of matchmoving
Fundamentals of matchmovingFundamentals of matchmoving
Fundamentals of matchmoving
 
Video to Video Translation CGAN
Video to Video Translation CGANVideo to Video Translation CGAN
Video to Video Translation CGAN
 
V Ray For Sketch Up 2007 Manual
V Ray For Sketch Up 2007 ManualV Ray For Sketch Up 2007 Manual
V Ray For Sketch Up 2007 Manual
 
3D Workshop
3D Workshop3D Workshop
3D Workshop
 

Recently uploaded

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 

Recently uploaded (20)

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 

Virtual projector

  • 1. The Virtual Projector Alessandro Florio - 161704 University of Trento Department of Information Engineering and Computer Science Master of Science in Computer Science Abstract. In this report we are going to explain how a movie is virtually projected into an image, or into another video, replacing a white screen, in order to reproduce an augmented reality scenario. In the case it is projected on a video, the corners of the ”screen” are tracked through each frame to update the area onto which the movie will be shown.
  • 2. Table of Contents 1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Screen corners initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.1 Image mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Video mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Projecting the movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1 Introduction The program can project a movie both on a still image which contains a screen, and on a video in which the screen moves due to rotations and translations of the camera. The code has been implemented in a way that, after compiling the source, if the generated executable is called without arguments1 it runs by default the video mode. If instead it is executed with an argument2 , whatever this may be, it runs the image mode. This has to be kept in mind when running the executable file with the ”-r” option which saves the execution to a video file called output.avi: in fact, adding this option toggles the execution mode for the rule described above (see also the relative footnotes)! In the following sections we are going to describe in detail how the algorithm has been implemented, always explaining the differences and similarities between the image and video mode. 2 Screen corners initialization The procedure of initializing the screen corners follows two different approaches in the image and video modes: for the first one it is manual, so that it can be easier to change the image with the screen on which the movie is projected, while for the second one it is automatic, but in order to be so it needs to do some image cleaning which was studied for the provided video and which may not adapt to all situations. 1 or with an even number of arguments 2 or with an odd number of arguments
  • 3. 2.1 Image mode As mentioned above, in the image mode users can select the four points of the image which represent the screens corners. This is done by clicking with the left mouse button at the right position. In case of mistake, pressing ’c’ will clear all the inserted points. When the four points have been correctly marked, by pressing ’s’ the projection starts. 2.2 Video mode Differently from the image mode, in the video mode the four corners are identified automatically as the four best features to track3 in the first video frame. To do so, the screen was constructed as a white area with a black solid border in order to increase the contrast on the extremities. The frame is then converted to the grayscale color space, and subsequently binary thresholded to simplify the identification between screen, border and the rest of the environment. Since the border is quite thick, each corner would be identified twice: the binary image is therefore substituted by its skeleton. Then, the identification of the corners is immediate; when this last operation is completed, the projection can start. 3 see [1]
  • 4. 3 Projecting the movie Projecting the movie as in an augmented reality scenario is just a matter of warping every frame of the movie using a perspective transformation in order to fit in the actual screen position. While the perspective transformation in the image mode has to be computed only at the beginning - since the screen does not move, and so its corners do not change - in the video mode, where the screen position changes from frame to frame, the corners have to be tracked and the projection has to be recomputed every time. Tracking is performed through the OpenCV function calcOpticalFlowPyrLK which calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids4 . The warped image is computed using the OpenCV function getPerspectiveTransform which, given in input the four absolute corners of the movie and the four corresponding corners of the screen5 calculates the 3 × 3 matrix M of a perspective transform such that:  tixi tiyi ti   = M ·   xi yi 1   where (xi, yi) is the ith corner of the movie (xi, yi) is the ith corner of the screen for i = 0...3 We recall that the matrix has to be computed only once in the image mode, but has to be recalculated at every frame, after identifying the new positions of the screen’s corners through the optical flow computation, in the video mode. The projection matrix M is used for every frame of the movie in the OpenCV function warpPerspective which creates a new image from the source movie frame where dst(x, y) = src M11x + M12y + M13 M31x + M32y + M33 , M21x + M22y + M23 M31x + M32y + M33 . The warped movie frame is then copied on the screen, removing all the black pixels left from the transformation which lie outside its border. 4 see [2] 5 corners both of the movie and of the screen were ordered clockwise starting from the top-left one
  • 5. 4 Conclusion We have implemented a virtual projector which suits an augmented reality sce- nario and which is very stable and generates a fluid and realistic video. The program can also save the execution to a video file6 , so the output can be used for other applications. To sum up, we present here a pseudo-code of the algorithm, which recaps in short the main parts of the implementation: // media definition Mat frame if IMAGE MODE then frame ← screenImage else if VIDEO MODE then frame ← video.at(0) end // corners’ initialization Point[] corners if IMAGE MODE then corners ← frame.getFourPointsFromUser() else if VIDEO MODE then frame.convert(gray) frame.threshold(binary) frame.opening() frame.thin() corners ← goodFeaturesToTrack(frame, 4) end int w ← movie.cols - 1 int h ← movie.rows - 1 Point[] movieCorners ← {(0,0), (w,0), (w,h), (0,h)} Mat projectionMatrix if IMAGE MODE then // order the cornes as movieCorners, so they can be correcly mapped corners.orderClockwiseFromTopLeft() projectionMatrix ← getPerspectiveTransform(corners, movieCorners) end // continues on next page... 6 as described in the second paragraph of the Introduction
  • 6. // play the movie forall movieFrame do if VIDEO MODE then /* compute the corner’s actual position based on the optical flow * between the previous and the current frame, and the previous * corners’ positions */ corners ← calcOpticalFlowPyrLK(prevFrame, frame, corners) // order the cornes as movieCorners, so they can be correcly mapped corners.orderClockwiseFromTopLeft() // re-compute the projection matrix for this frame projectionMatrix ← getPerspectiveTransform(corners, movieCorners) end Mat projection ← warpPerspective(movieFrame, projectionMatrix) projection.copyNonZeroPixelsTo(frame) show(frame) end References 1. Jianbo Shi and Carlo Tomasi, ”Good features to track” 2. Jean-Yves Bouguet, ”Pyramidal Implementation of the Lucas Kanade Feature Tracker Description of the algorithm” 3. http : //docs.opencv.org/modules/video/doc/motion analysis and object tracking.html 4. http : //docs.opencv.org/modules/imgproc/doc/geometric transformations.html