SlideShare a Scribd company logo
1 of 6
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

Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1Ldb valecoricerca_indolfi_brevetti_1
Ldb valecoricerca_indolfi_brevetti_1laboratoridalbasso
 
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
 
Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)Rapporto ambientale (Valutazione ambientale strategica)
Rapporto ambientale (Valutazione ambientale strategica)Comune di Pordenone
 
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 virtualeAlessandro Florio
 
Ldb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adamLdb valecoricerca_denunzio_adam
Ldb valecoricerca_denunzio_adamlaboratoridalbasso
 
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 PDTARegioneLazio
 
PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01PRGC Pordenone, tavola scenario 01
PRGC Pordenone, tavola scenario 01Comune 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_neuropatologialaboratoridalbasso
 
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_3laboratoridalbasso
 

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.pptxSouravAhmed12
 
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 ProjectSurya Chandra
 
Canon PowerShot SX110 IS
Canon PowerShot SX110 ISCanon PowerShot SX110 IS
Canon PowerShot SX110 ISciuly
 
Pssx110 Is Cug En
Pssx110 Is Cug EnPssx110 Is Cug En
Pssx110 Is Cug Enciuly
 
5 ray casting computer graphics
5 ray casting computer graphics5 ray casting computer graphics
5 ray casting computer graphicscairo 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 effectsJamel 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 CAMERANational Cheng Kung University
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiMao Wu
 
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 scenesIJCSEA 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 VIDEOIAEME 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 cricketAneesh Tg
 
Fundamentals of matchmoving
Fundamentals of matchmovingFundamentals of matchmoving
Fundamentals of matchmovingDipjoy Routh
 
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 ManualPheo8x
 

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
 
Canon PowerShot SX110 IS
Canon PowerShot SX110 ISCanon PowerShot SX110 IS
Canon PowerShot SX110 IS
 
Pssx110 Is Cug En
Pssx110 Is Cug EnPssx110 Is Cug En
Pssx110 Is Cug En
 
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

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

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