Assignment
For
Mid-term Exam
Prepared by:
Rafia Waris
FA19-BCSE-79
Submitted to:
Miss Maryam Kausar
Dated: 26/04/2021
ADAPTER DESIGN PATTERN
Adapter is a structural design pattern that allows objects with incompatible interfaces
to collaborate. Adapter pattern work as a bridge between two incompatible interfaces. This
pattern involves the single class which is responsible to join functionalities of independent and
incompatible interfaces. An adapter can be used when the wrapper must respect a particular
interface and must support polymorphic behavior. This is a special object that converts the
interface of one object so that another object can understand it. Adapters are used when we
have a class (Client) expecting some type of object and we have an object (Adaptee) offering
the same features but exposing a different interface.
So in this system of virtual mirror which is made up from a computer monitor and webcam, we
will use Adapter design pattern because virtual mirror will act as an (adapter) between client
webcam(target) interface and items (adaptee) interface. The Adapter pattern create a middle-
layer class that serves as a translator between a client (captured image) and weird interface (of
items). Adapter class converts the (incompatible) interface of a class (items) into another
interface (target) which clients require.
ADAPTER PATTERN STRUCTURE:
The adapter implements the interface of one object and wraps the other one which can be
shown in below pattern diagram
1. The Webcam is a class that contains the existing business logic of the program. In virtual
mirror system it contains the captured image of targeted client.
2. The Webcam Interface describes a protocol that other classes must follow to be able to
collaborate with the webcam data.
3. The item interface is some useful class. The webcam class can’t use this class directly
because it has an incompatible interface. In virtual mirror system it will be item class to which
user cannot access directly without user image.
4. The virtual mirror is a class that’s able to work with both the webcam and the items interface:
it implements the webcam interface, while wrapping the service object. In this system virtual
mirror receives calls from the webcam (client) via the adapter interface and translates them
into calls to the wrapped service object in a format it can understand.
5. The webcam (image) doesn’t get coupled to the concrete virtual mirror class as long as it
works with the adapter via the webcam interface.
SEQUENCE DIAGRAM:
There are three main classes in system that are
Client (Webcam)
Adapter (Virtual Mirror)
Adaptee (Items interface)
Webcam and items are incompatible interfaces because webcam (Client) cannot make call
directly to items (Adaptee). So we need virtual mirror (Adapter) in between the webcam and
items interface.
First of all, webcam (client) will send captured image as a request to virtual mirror
system.
Virtual mirror (adapter) will receive the captured image(request) and it will convert the
image(request) into scanned image which will be understand by item interface
(adaptee).
Virtual mirror (adapter) will make call to item interface (adaptee) by sending masked
image after being tracking (specific request) to item interface.
The item interface(adaptee) will receive the tracked image (request) and it will process
the masked image (request), the it will send back the processed image by superimposed
the masked image with image of item (Response) to the system.
As virtual mirror (Adapter) will receive the image with item (response) and then it will
convert the image (response) into some other format which client can understand.
By this way two incompatible interfaces webcam and items will work together with the help of
Virtual mirror system.
CLASS DIAGRAM:
An object Virtual Mirror delegates to an Item interface object
Webcam (client) can only see the (target interface) which captures the input user video.
Then webcam will call the virtual mirror and virtual mirror will implement the Target
interface and provide implementation of services () method.
Virtual mirror is composed with items interface which means virtual mirror system has
reference to the items interface object and virtual mirror will do conversions.
Finally, all requests get delegated to the adaptee and virtual mirror will make call to item
interface.
FAÇADE DESIGN PATTERN
Façade provide a unified interface to a set of interfaces in a subsystem. Facade defines a
higher-level interface that makes the subsystem easier to use. It Wrap a complicated subsystem
with a simpler interface.
So in this system of virtual mirror all the back end system is very complex and It is an VR-based
virtual fitting solution with a real-time try-on solution. There are many functionalities working at
the back end but at the front end we have a so unified form of the system as a simple interface.
For example, the screen of webcam can behave like a regular mirror, but it will also enhance the
reflection by showing video feeds from different angles. We combine Camera Fragment API for
building modular applications with Texture View (API to display a content stream, along with
Camera Device. The Chromecast dongle is plugged into the HDMI port and powered by a
separate USB cable.
Now the monitor works as if it was a mirror, i.e. the monitor renders the real view seen by the
smartphone camera. By recording several seconds of mirroring and setting the camera to use a
delay, the person can turn around and then be able to view themselves.
Special software can use the video from a webcam to assist or enhance a user's control of
application. Video features, including faces, shapes, models and colors can be observed and
tracked to produce a corresponding form of control.
An image processing module that includes linear and non-linear image filtering, geometrical
image transformations (resize, affine and perspective warping, generic table-based remapping),
color space conversion, histograms, and so on.
But to reduce all the above complexity we will use façade pattern so that we are able to see the
simplified higher level interface for the ease of the user and are performing many actions at the
backend of the system. So all the functions of webcam, tracking, selecting the product and then
user scanning are represented in the unified interface but we as a user are unable to see the
functions that are performed behind the screen to implement these functionalities of the system.
FACADE PATTERN STRUCTURE:
The Façade Wrap a complicated subsystem with a simpler interface and below is the Uml
pattern structure of façade.
In order to interact all the complex things, we use the single facade pattern. Facade does the
complex wiring. It invokes methods on a bunch of other classes so that it can interact with those
objects of different classes.
According to a virtual mirror system, façade provides a single design pattern through
which we can interact with user consisting lots of different classes like tracking image,
camera manipulation, slide show different items, accessories, different products
according to the size and color, confirmation and shows how it looks on the user.
As all the classes and functionalities are working behind the system but façade design
pattern is providing a simplified interface to the client using which the client can access
the system very easily.
BLOCK DIAGRAM
It will determine the system to be illustrated, defines the components, inputs, and outputs as
basic components are web camera, mirror, interface provided and different items will be
selected and it will manage model, style and size of the item.
In this system firstly camera track the user, camera can move left /right and zoom in/out
Then client can select any outfit of his/choice, they can easily manage to change the
size, color of that dress
They can confirm the receipt and virtual mirror will place directly placed on the particular
body part.
This way the client can try out different items and buy the items that suit him/her.
CLASS DIAGRAM
These all are classes but it is linked with a façade pattern which is providing a single interface to
remove the complexity.
Then user can easily view all items and can easily select and change according to his
needs in a unified interface
Then virtual camera will convert the image.
Camera will detect the user image
In this way person will able to selects an item from the shopping list.
The item will be directly placed on the particular body part. This way the person can try
out different items
COMMAND DESIGN PATTERN
Command pattern encapsulates a request as an object, thereby letting us parameterize other
objects with different requests, queue or log requests, and support undoable operations and it
encapsulate a request under an object as a command and pass it to invoker object. Invoker
object looks for the appropriate object which can handle this command and pass the command
to the corresponding object and that object executes the command.
So in this virtual system a request of selecting a product (outfit) will encapsulate as an object
and it will pass it to the invoker class which will asks the command to carry out the request and
is called request handler and the system will act as a receiver which will receive the command
to execute. And if we want to undo or redo our actions we can also do with the help of command
design pattern.
COMMAND PATTERN STRUCTURE:
As command pattern encapsulates a request as an object, thereby letting us parameterize other
objects with different requests, queue or log requests, and support undoable operations and it
encapsulate a request under an object as a command and pass it to invoker object. So here in
this class diagram we have different classes of item model and item colour, size according to
the fitting. So here the command of selecting an item will be pass to the invoker as a request
and then the request handler. The entire request will be extended to a single interface and then
the system will act as a receiver which will receive the command to execute. (function. +execute
()).
And if we want to undo or redo in selection of our item we can also do that easily with the help
of command design pattern. So in the above virtual mirror system with the help of command
deign pattern our request /command will be executed.
USECASE DIAGRAM
Each Actor that will be able to interact with functions performed by the Virtual mirror system, it
gives us a clear picture about the interaction of Various actors and their functionality. This use
case diagram shows that when a user enters in the view of the camera, the camera will
manipulate its movement. Also the system can track the image of the user. Then different
options will be displayed from where the user can select and view the desired product and then
that particular dress will be directly placed on the particular body part. In this way this UML
diagram helps us to understand the interaction of the functionalities of user and the system.
PACKAGE DIAGRAM
Above package diagram consists of six main packages that comprise of classes based upon
their functionalities and common functions with which they are associated.
The user image tracking Package contains the functions which are used to manipulate
the camera movement either zooms in/out or move right/left.
Manage items Package contains those classes whose purpose is to server for user to
change any style, color or add or delete any accessories if needed.
Get figure type package contains the Classes that facilitate the user to modify the outfit
size according to his/her choice.
Then it is connected to the package that virtually displays and confirms the receipt.
Afterward user wants to change the mirroring then he /she will able to do that also.