You are on page 1of 5

Digital Signal Processing.

Final project: Video blurring


background
Mosqueda,A.
Villoria,P.
Sosa,D.

Abstract—The document below presents the implementation of a II. PYTHON


video blurring in real time software using python language and
the Raspberry pi microcontroller with a USB webcam. We will Python is an interpreted, interactive, object-oriented
use the algorithms studied and analyzed previously in the digital programming. It incorporates modules, exceptions, dynamic
signal processing course. typing, very high level dynamic data types, and classes. It
supports multiple programming paradigms beyond object-
I. RASPBERRY PI oriented programming, such as procedural and functional
Raspberry Pi is a device; a fully functional computer in a low- programming. Python combines remarkable power with
cost package. The Pi is known as a single-board computer. very clear syntax. It has interfaces to many system calls and
Various models have been released since the original Model B, libraries, as well as to various window systems, and is
each bringing either improved specifications or features extensible in C or C++. It is also usable as an extension
specific to a particular use. language for applications that need a programmable
interface. Finally, Python is portable: it runs on many Unix
variants including Linux and macOS, and on Windows.

Figure 1. RaspberryPi model 4 B

The Raspberry Pi Model B have the following connectors: Figure 3. Python logo

• 2 USB 3.0 ports III. DIGITAL FILTERS


• 2 USB 2.0 ports Any medium that passes through the signal can be considered
a filter. We do not think of something as a filter if the signal
is not modified.

A digital filter is a filter that operates on digital signals. It's an


operation math that takes a sequence of numbers (the input
signal) and the modifies producing another sequence of
numbers (the output signal) with the objective of highlighting
or attenuating certain characteristics.

It can exist as a formula on paper, a loop in a program of


computer, as an integrated circuit on a chip.

Figure 2. RaspberryPi tech specifications The most common filters are those that separate two signals,
either two audios or that eliminate noise from a signal, such
as the background of an image, the background sound of an translating the algorithm from Matlab to Python language,
audio, the transparency of an image, etc. using the open CV library available for Python.

There are several types of digital filters as well as different a) Matlab algorithms
classifications of these:
For the first algorithm, we wanted to detected the edges with a
According to the part of the spectrum on which they act: Laplacian kernel, then find the coordinates of the edges a
• High pass filters. person or object in the image Fig. 4, meanwhile use the anissof
• Low pass filters. function (we changed the parameter for niter) to blur the
• Band pass filters. background and the last step was to cut the person/object from
• Band removed. the first imagen and mount it on the image with the background
• Multiband. blurred. This algorithm work fine when we work with a single
• Everything happens. image, however things get complicated working with real time
video, that’s why we needed to thing in a new way of doing the
• Resonator.
blurring.
• Oscillator.
• Comb filter.
• Notch filter or notch filter.
• According to your order:
o first order
o second order
• According to your response to unit input:
• FIR (Finite Impulse Response)
• IIR (Infinite Impulse Response)
• TIIR (Truncated Infinite Impulse Response)
• According to the structure with which it is
implemented:
o Laticce
Figure 4. Left, original image. On the right the original image with the
o Several in cascade laplacian kernel aplied
o Several in parallel Open cv
In the second experiment we made a question. What is and
OpenCV-Python is a library of Python bindings designed to image in Matlab? It is a matrix, so if what if we took two
solve computer vision problems. OpenCV-Python makes use pictures A and B with the same background but B has a person
of Numpy, which is a highly optimized library for numerical in it. Is there any way we can make a mathematical operation
operations with a MATLAB-style syntax. All the OpenCV between A and B to get the person from image B modify image
array structures are converted to and from Numpy arrays. This A and the add both results, well this is what we did for the
also makes it easier to integrate with other libraries that use second algorithm and the experiment in Matlab.
Numpy such as SciPy and Matplotlib.
The first part we toke and reference image called A.
IV. MATERIALS
Raspberry Pi
USB webcam
Laptop
Monitor

V. SOFTWARE
Python
Open CV for Python
Matlab

VI. METODOLOGY
The making of the blurring program is divided in two phases. Figure 5. Refernce image (background)
The first one is making experiments in Matlab to get an
algorithm to blur the background of a video. The second is Now we take the image but with a new object/person in it we
called the image B.
Figure 6. The book simulates the person.

Now, if we subtract B from A (B-A) the only remain values


are the ones from the book (which is the part where the value
of the matrix are different) called C then we modify the image
A with the anisoff function to blur it called D, finally we add C
and D and obtain the image with the object and a blurred
background.

Figure 8. Code for the blurring background program in matlab.

b) Python

In python the only challenge was translate the Matlab code, but
the first dificulty was the time for doing the operation; a
solution was to use the Open CV library with hel us to
overcome and finally run the code from python in the
Raspberry. The code is shown in Fig.9

Figure 7. Resulto of the add of C and D.

The code is shown in Fig.8.


VII. RESULTS
The results for the matlab code are shown in Fig. 10.

Figure 10. Video with blurred background Matlab.

The results for the python running in the Raspberry Pi code in


Fig. 11.

Figure 11. Video with blurred background python.

The algorith present a problem in both lenguajes and it’s the


necessity of a static background, if we move the background the
program makes a weird operation with both images.

Figure 9. Code for the blurring background in python.

Figure 12. In Fig 12 we can see the problem with this algoritm

VIII. CONCLUSION
Mosqueda Camacho Alan: In this project we implemented
everything we learnt during the semester. And designed an
algorithm that blurrs the background. We manipulated the
images of the video as matrices and implements basic matrix
operations. The most difficult part was to figure out the right
method to blur the background. We tried using convolution lack of a camera but despite that I made the code that was used
with a Laplacian Kernel, but It takes a lot of time. In the end in matlab so I took the first steps to develop the python
we used an easier algorithm. program, from then on in the background by distorting the
positioning it generates problems that we decided to solve by
Sosa Cabrera Diego: In this project we write a code with all the leaving the background static.
knowledge we acquired during the course. We needed to think
how to attack the problem from different perspectives, this can IX. REFERENCES
be seen in how we change all the idea because another way it
[1] Y. Yorozu, M. Hirano, K. Oka, and Y. Tagawa, “Electron spectroscopy
would’ve been really difficult to work. Using open cv really studies on magneto-optical media and plastic substrate interface,” IEEE
help us to improve the python code and make work more Transl. J. Magn. Japan, vol. 2, pp. 740–741, August 1987 [Digests 9th
efficiently than matlab code, however there are some errors Annual Conf. Magnetics Japan, p. 301, 1982].
that can be fixed in futures versions.
[2] V.K Ingle & J.G. Proakis (1996) “Digital signal Processing” V. 4
[Online]. [Accessed: 30-Ago-2020].
Villoria Quiñones Pablo Alberto: In this final semester project,
points that were seen throughout the course were taken into
[3] “The official Raspberry Pi beginner's guide” [Online]. [Accessed: 17-
account, so I consider it a good project that helps us understand Ago-2020].
signal processing, from what we learned in the course I can
mention that what I have seen In the matter of signals it is now
[4] Docs.opencv.org. 2020. Opencv: Smoothing Images. [online] Available
clearer and more applicable so the knowledge that I take with at: <https://docs.opencv.org/master/d4/d13/tutorial_py_filtering.html>
me is valuable, as for the project, the difficulty I had was the [Accessed 15 September 2020].

You might also like