0% found this document useful (0 votes)
13 views89 pages

Save Content

Uploaded by

salemwhd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views89 pages

Save Content

Uploaded by

salemwhd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 89

Ministry Of Higher Education

Modern Academy

For Computer Science and

Management Technology

In Maadi

Smart Vision
Submitted to
Modern Academy
Computer Science and Management Technology in Maadi
Computer Science Department

Prepared by
Mohamed Ibrahem Mohamed Abdel Fattah
Mohamed Ebrahem Youssef Hassan Ammar
Mohamed Ebrahem Mohamed Ebrahem El-sayed
Mahmoud Mohamed Ahmed Awad
Michael Atef Shafiq Abdo
Kiroles Mohsen Rady Gaid
Supervised by
Dr. Nora Niazy
Eng. Ahmed
Hany

Academic Year :2022/2023


Team Members
Description ID Name
Mobile Application 120000274 ‫محمد ابراهيم محمد عبدالفتاح‬
(Team Leader)
Mobile Application 120000431 ‫محمد ابراهيم يوسف حسن‬

Embadded System 120000381 ‫محمد ابراهيم محمد ابراهيم‬

Embadded System 120000143 ‫مايكل عاطف شفيق عبده‬

Artificial Intelligence 120000088 ‫محمود محمد احمد عوض‬

Artificial Intelligence 120000324 ‫كيرلس محسن راضي جيد‬

1
Acknowledgment
First and the most important thing, thanks to “god” the most merciful for
providing us with Knowledge, creativity, and willpower strength to produce
this project. It has been a great opportunity to gain lots of experience in real
life projects, followed by the knowledge of how to design and analyze real
projects. We also gratefully thank our "Modern Academy" in general and
Dr. “Nora Niazy” and Eng. “Ahmed Hany” for their supporting and
guiding us during the project duration.

Of course, many individuals helped us start this project, but we especially


want to thank the head and employees of the Department of Computer
Science, notably Prof. Dr. “Mahmoud Gad-Allah” for the honor of working
under his supervision and for his wise advice on how to achieve greater
success and support and guidance during our academic years.

Finally, we must mention that everyone who has helped us produce this
project, beginning with those working in our academy to everybody outside,
deserves to be appreciated.

2
Abstract
Save Content is a dynamic social media application engineered to facilitate
seamless multimedia content sharing and foster meaningful interactions among
users. At its core, the system boasts a robust architecture supported by a Flask
backend, ensuring scalability, reliability, and efficient data management. The
platform empowers users to engage with each other through various interactive
features. Users can effortlessly upload images and text, express appreciation
through likes, and engage in conversations via comments. Additionally, the
system enables users to connect with others by sending follow requests,
nurturing a vibrant and interconnected community.
Each user is provided with a comprehensive profile that serves as a personalized
hub for their activity within the app. This profile showcases essential
information such as the user's name, bio, and a chronological display of their
posts, offering a convenient and immersive user experience.

Save Content also facilitates effortless content sharing, allowing users to


amplify the reach of captivating posts within their network. Whether it's sharing
a thought-provoking article or a stunning photograph, users can seamlessly
distribute content, fostering engagement and virality.
To maintain content diversity and prevent redundancy, Save Content integrates
an advanced Natural Language Processing (NLP) model. This model rigorously
analyzes the similarity between text-based posts, automatically rejecting
submissions that exceed a predefined similarity threshold of 30%. Users are
promptly notified of rejected posts, ensuring transparency and content quality.
Complementing the text similarity check, the system incorporates robust image
analysis capabilities. This ensures a comprehensive approach to content
moderation, enhancing the platform's integrity and fostering user trust.
In conclusion, Save Content redefines social media engagement by offering a
feature-rich platform that prioritizes user interaction, content diversity, and
community building. With its robust3architecture, and advanced features.
Table of index
Contents
1. Chapter One......................................................................................................8
1.1 Introduction...................................................................................................9
1.2 Background...................................................................................................9
1.3 Motivation...................................................................................................10
1.4 Problem Definition......................................................................................10
1.5 Why Smart Vision System?........................................................................11
1.6 Objectives....................................................................................................11
1.7 Expected Outcome......................................................................................11
2. Chapter Two....................................................................................................12
2.1 Related Works.............................................................................................13
2.2 Comparative Studies...................................................................................13
2.3 Scope of the Problem..................................................................................13
2.4 Challenges...................................................................................................14
2.4.1 sensory augmentation.........................................................................14
2.4.2 technology Limitations.......................................................................14
2.4.3 Understanding user needs..................................................................14
3. Chapter Three..................................................................................................15
3.1 Requirements & Analysis............................................................................16
3.1.1 Functional Requirement.....................................................................16
3.1.2 Non-Functional Requirement.............................................................16
3.1.3 Hardware requirements......................................................................17
3.1.4 Software requirements.......................................................................17
3.2 UML Diagrams...........................................................................................18
3.2.1 Use Case Diagram.............................................................................18
3.2.2 Sequence diagram..............................................................................19
4
3.2.3 Activity diagram................................................................................20
3.2.4 ERD...................................................................................................21
3.2.5 Class Diagram....................................................................................22
4. Chapter Four...................................................................................................23
4.1 Design.........................................................................................................24
4.1.1 Mobile application.............................................................................24
4.1.2 Android..............................................................................................33
4.1.3 Back-End...........................................................................................42
4.1.4 Artificial intelligent (AI)....................................................................48
4.1.5 Embedded System..............................................................................66
5. Chapter Five...................................................................................................72
5.1 Implementation............................................................................................73
5.1.1 Mobile Application............................................................................73
5.1.2 Back-End...........................................................................................79
5.1.3 android...............................................................................................79
5.1.4 AI…...................................................................................................93
5.2 Testing.........................................................................................................97
5.2.1 Testing Implementation.....................................................................97
5.2.2 Testing Report...................................................................................98
6. Chapter Six......................................................................................................99
6.1 Conclusion.................................................................................................100
6.2 Future Work..............................................................................................100
6.3 References.................................................................................................101

5
Table of Figures
Figure 3.1 Use Case Diagram..................................................................................18
Figure 3.2 Sequence Diagram.................................................................................19
Figure 3.3 Activity Diagram....................................................................................20
Figure 3.4 ERD........................................................................................................21
Figure 3.5 Class Diagram........................................................................................22
Figure 4.1 Home Page.............................................................................................27
Figure 4.2Service Page............................................................................................28
Figure 4.3 Signup Page............................................................................................29
Figure 4.4. Login Page............................................................................................30
Figure 4.5. Home Page............................................................................................31
Figure 4.6. Add object.............................................................................................32
Figure 4.7. MVVM Model......................................................................................34
Figure 4.8. Interaction Design VS UX....................................................................36
Figure 4.9. View Group Layout...............................................................................37
Figure 4.10 Recycler View......................................................................................38
Figure 4.11 Fragment Layout..................................................................................39
Figure 4.12 Android Home& Registration page......................................................40
Figure 4.13 PHP Architecture..................................................................................42
Figure 4.14 phpMyAdmain........................................................................45
Figure 4.15 Cloud Ways..........................................................................................47
Figure 4.16 popular object detection algorithms.....................................................51
Figure 4.17 Object Detection...................................................................................52
Figure 4.18 Face_recognition..................................................................................52
Figure 4.19 Text to voice.........................................................................................54
Figure 4.20. Face Detection Model.........................................................................59
Figure 4.21 Object Detection Model.......................................................................59
Figure 4.22 Tools of Embedded System.................................................................71
Figure 4.23 Firestore security Configuration...........................................................80
Figure 4.24 Single Ton Pattern................................................................................82
Figure 4.25 SharedPref VS Saved Instance.............................................................88
Figure 4.26 Testing Duration...................................................................................98

6
1. Chapter
One

7
1.1 Introduction
In the ever-evolving landscape of social media platforms, Save Content emerges as a
dynamic and innovative solution designed to revolutionize the way users interact, share, and
connect online. With an emphasis on seamless multimedia content sharing and fostering
genuine user engagement, Save Content represents a new frontier in social networking.

At its essence, Save Content is more than just a conventional social media application. It
embodies a vision of interconnectedness, creativity, and community, where users are
empowered to express themselves freely and connect with like-minded individuals from
around the globe. Through a combination of cutting-edge technology, intuitive design, and
user-centric features, Save Content transcends traditional boundaries to deliver an
unparalleled social experience.

This documentation serves as a comprehensive guide to understanding the intricacies of Save


Content, from its robust architecture and backend infrastructure to its innovative features and
content moderation mechanisms. By delving into the core components and functionalities of
Save Content, readers will gain invaluable insights into the platform's development,
implementation,
and ongoing evolution.

1.2 Background

Save Content was conceived in response to the growing demand for a social media platform
that puts user engagement and community building at the forefront. Existing platforms often
lacked effective content moderation and struggled to foster meaningful connections among
users. Recognizing these shortcomings, Save Content was developed to offer a solution that
prioritizes user satisfaction and authenticity.

The goal of Save Content is simple: to provide a platform where users feel empowered to
share their interests and connect with like-minded individuals in a vibrant and diverse
community. By listening to user feedback and leveraging advanced technology, Save Content
aims to redefine the social media experience, making it more engaging, inclusive, and
enjoyable for all users.
8
1.3 Motivation

The motivation behind Save Content is straightforward: to create a social media


platform that truly puts users first. We noticed that many existing platforms were
missing the mark when it came to providing a positive and fulfilling user
experience. Users often felt overwhelmed by irrelevant content, frustrated by
limited interaction options, and disconnected from the community.
Save Content aims to change that by offering a platform where users can feel
heard, valued, and connected. We want to empower users to share their passions,
connect with others who share their interests, and engage in meaningful
conversations. By focusing on user satisfaction and community building, we
believe Save Content can make social media a more enjoyable and enriching
experience for everyone involved.

1.4 Problem Definition

Save Content aims to tackle the prevalent issue of content copyright infringement and
theft that plagues many social media platforms. Existing platforms often struggle to
effectively protect users' content rights, leading to instances where original content is
plagiarized, misappropriated, or used without proper attribution.
The lack of robust copyright protection mechanisms not only undermines the creative
efforts of content creators but also erodes trust within the community. Users are
hesitant to share their original work, fearing that it may be exploited or misrepresented
by others.
Save Content recognizes the importance of safeguarding content ownership and
integrity. By implementing comprehensive copyright protection measures and
promoting responsible content sharing practices, Save Content seeks to create a
platform where users can confidently share their creations while respecting the rights
of others. Through these efforts, Save Content aims to foster a culture of respect,
integrity, and creativity within its community.
9
1.5 Why Save Content?
Save Content aims to solve the prevalent issue of content copyright infringement
and theft on social media platforms. By implementing robust copyright protection
measures and promoting responsible content sharing practices, Save Content
provides a platform where users can confidently share their creations while
respecting the rights of others.

1.6 Objectives

1. Implement Robust Copyright Protection: Develop and deploy advanced


algorithms and mechanisms to detect and prevent content copyright
infringement, ensuring that users' original creations are adequately protected.
2. Facilitate Content Attribution: Enable users to easily attribute and credit the
original creators when sharing content, promoting transparency and
accountability in content dissemination.
3. Enhance Content Moderation Tools: Continuously improve content
moderation tools to swiftly address instances of copyright infringement and
enforce community guidelines, maintaining a safe and respectful environment
for all users.
4. Foster Collaboration with Content Creators: Establish partnerships and
collaborations with content creators to gather feedback, address concerns, and
co-create solutions that effectively address the challenges of content copyright
protection.
5. Promote Ethical Content Sharing Practices: Encourage users to engage in
ethical content sharing practices by respecting copyright laws, seeking
permission before using others' content, and acknowledging the contributions
of original creators.

10
1.7 Expected Outcome

1. Reduction in Copyright Infringement: By implementing robust copyright


protection measures and promoting responsible content sharing practices, Save
Content anticipates a significant decrease in instances of content copyright
infringement on the platform.
2. Increased User Confidence: As users witness the effectiveness of Save
Content's copyright protection mechanisms, they are expected to feel more
confident in sharing their original creations, knowing that their rights are
adequately safeguarded.
3. Enhanced Community Trust: The implementation of clear guidelines and
resources on copyright best practices, along with transparent content
attribution, is projected to foster a culture of trust and integrity within the Save
Content community.
4. Improved Content Quality: With a reduction in content theft and plagiarism,
Save Content anticipates an overall improvement in the quality of content
shared on the platform, as users are encouraged to create and share original
and authentic content.
5. Positive User Experience: As users experience a safer and more respectful
environment for content sharing, Save Content expects to see increased user
satisfaction and engagement, ultimately contributing to the long-term success
and sustainability of the platform.

11
2. Chapter
Two

12
2.1 Related Works
While some social media platforms have implemented measures to address
content theft, such as reporting mechanisms and copyright infringement policies,
many still struggle to effectively prevent it. Users may encounter instances where
their original content is misappropriated, reused without permission, or
improperly attributed, leading to frustration and mistrust within the community.

Save Content recognizes the importance of protecting users' content rights and
promoting ethical content sharing practices. By implementing robust copyright
protection measures and promoting responsible content attribution, Save Content
aims to create a platform where users can confidently share their creations while
respecting the rights of others. Through these efforts, Save Content seeks to foster
a culture of respect, integrity, and creativity within its community, setting a new
standard for social media platform

2.2 Comparative Studies


Despite the absence of comprehensive comparative studies exclusively addressing content
theft prevention among social media platforms, existing analyses offer valuable insights into
related aspects, including platform policies, user experiences, and technological solutions.

Researchers often evaluate the content moderation policies and practices of various social
media platforms, assessing factors such as transparency, accessibility of copyright policies,
and effectiveness in handling copyright-related issues. Studies also gauge user satisfaction
and trust regarding platform approaches to copyright, shedding light on user perceptions and
expectations.

Moreover, comparative analyses delve into the technological solutions employed by


platforms to safeguard content creators' rights. These evaluations include the effectiveness of
content recognition algorithms, watermarking techniques, and other tools aimed at preventing
content theft and enforcing copyright policies.

13
Furthermore, compliance with legal standards and industry regulations is a crucial aspect of
comparative studies. Researchers assess platforms' adherence to relevant laws and regulations
governing copyright protection, identifying areas for enhancement and promoting best
practices.

Finally, while not explicitly focused on content theft prevention, comparative studies explore
disparities in user experiences and community dynamics across platforms. These insights
offer contextual understanding of how platform features and community norms influence
user behaviors and interactions related to content sharing and copyright compliance.

2.3 Scope of the Problem


Pervasiveness: Content theft is widespread across social media platforms, affecting users
from diverse backgrounds and industries. From photographs and videos to written content
and artwork, virtually all types of digital content are susceptible to theft.

Impact on Content Creators: Content theft undermines the rights and livelihoods of content
creators, depriving them of recognition, compensation, and control over their work. The
problem is particularly acute for independent creators and small businesses, who may lack
the resources to combat infringement effectively.

Challenges in Detection and Enforcement: Detecting and addressing instances of content


theft pose significant challenges due to the sheer volume of content shared on social media
platforms. Moreover, the global nature of social media complicates enforcement efforts, as
copyright laws and enforcement mechanisms vary across jurisdictions.

Erosion of Trust and Integrity: Content theft erodes trust and integrity within social media
communities, undermining the credibility of platforms and diminishing users' confidence in
sharing their original work. This erosion of trust can have far-reaching consequences,
impacting user engagement, platform reputation, and long-term sustainability.

Need for Comprehensive Solutions: Addressing the problem of content theft requires a
multifaceted approach that combines technological innovation, legal frameworks, and
community engagement. Effective solutions must strike a balance between protecting content
creators' rights and preserving the open and collaborative nature of social media platforms.
14
2.4 Challenges

During the process of researching content theft policies for both text and images,
several challenges were encountered:

1. Fragmented Information Sources: Information about content theft policies is


often dispersed across various platforms, legal documents, and industry
publications. This fragmentation makes it challenging to access comprehensive
and up-to-date information in a centralized manner.
2. Complex Legal Frameworks: Copyright laws and policies governing content
theft vary widely across jurisdictions, adding complexity to the research
process. Navigating these legal frameworks requires a nuanced understanding
of intellectual property law and its application in the context of digital content.
3. Platform-Specific Policies: Social media platforms may have their own
copyright policies and enforcement mechanisms, further complicating the
research process. Understanding the nuances of each platform's policies and
practices requires thorough investigation and analysis.
4. Technical Limitations: Gathering information about content theft policies for
images may involve technical challenges, such as limitations in accessing
metadata or reverse image search tools. These technical barriers can hinder the
effectiveness of research efforts and require alternative approaches to data
collection.
5. Evolution of Policies: Content theft policies are subject to change over time in
response to evolving legal standards, technological advancements, and
community feedback. Staying abreast of these changes and ensuring the
information remains current poses a continuous challenge for researchers

15
3. Chapter
Three

16
3.1 Requirements & Analysis

Some simple but essential specifications are acquired during the program's
implementation and data collection.

3.1.1 Functional Requirement


1. User Registration and Login:
o Users should be able to create accounts and log in securely.
2. Content Creation and Posting:
o Users can create and post text and images with captions.
3. Interactions:
o Users can like, share, comment, and repost content.
4. User Profiles:
o Users have customizable profiles with profile pictures, bios, and privacy settings.
5. Following and Followers:
o Users can follow/unfollow others and manage their followers.
6. Copyright Protection:
o The platform prevents content theft and educates users on copyright.
7. Analytics:
o Administrators can access analytics on user engagement and content performance.
8. Integration:
o Integration with third-party services is supported.
9. Accessibility:
o The platform is accessible to users with disabilities.
10.Scalability:
o The system can handle a large number of users and content efficiently.

17
3.1.2 Non-Functional Requirement
 Security:

 The platform must comply with industry-standard security practices to protect user
data and prevent unauthorized access.

 Performance:

 The system should be responsive and able to handle concurrent user interactions
without significant latency.

 Scalability:

 The architecture should be scalable to accommodate a growing user base and


increasing content volume.

 Reliability:

 The platform should have high availability and minimal downtime, ensuring users can
access it whenever needed.

 Usability:

 The user interface should be intuitive and easy to navigate, catering to users of all
levels of technical proficiency.

 Compatibility:

 The platform should be compatible with a wide range of devices and web browsers to
ensure accessibility for all users.

 Accessibility:

 The platform should adhere to accessibility standards to accommodate users with


disabilities.

 Maintainability:

18
 The codebase should be well-documented and structured to facilitate maintenance and
future updates.

 Regulatory Compliance:

 The platform must comply with relevant data protection regulations and copyright
laws.

 Performance Metrics:

 Key performance indicators (KPIs) should be defined and monitored to assess the
platform's performance and identify areas for improvement.

19
3.1.3 Hardware requirements (Android)

3.1.3.1 Android
 Device capabilities: touch screen, Internet connectivity
 RAM: GB, preferably higher
 CPU: 1.0 GHz minimum, dual-core
 Disk: At least 1 GB

3.1.4 Software requirements

3.1.4.1 Android
 Operating system: Android
 API level: 21
 Android Version: 8.0

20
.1 UML Diagrams

1.1 Use Case Diagram


The purposes of use case diagram can be said to be as follows
 Used to gather the requirements of a system.
 Used to get an outside view of a system.
 Identify the external and internal factors influencing the system.
 Show the interaction among the system and actors.

Figure 3.1 Use Case Diagram

21
.1.1 Sequence diagram
It explains how and in what order a collection of items interacts, a sequence
diagram is similar to an interaction diagram. A sequence diagram focuses on
lifelines, or concurrent processes and objects, and the messages that are passed
back and forth to complete a function before the lifeline terminates.

Figure 3.2 Sequence Diagram

22
.1.1 Activity diagram
It shows the system's main operations and restrictions, which lead to the
project's pathways. They were classified to inform programmers and users about
the conduct of Vehicle Rental System.
Software operations are also depicted as a set of actions in the activity
diagram. These diagrams are used to describe and define system processes and use
cases. It has the potential to simplify and improve any process by highlighting
difficult use cases. An activity diagram also shows the system's actions, functions,
and processes.

Figure 3.3 Activity Diagram

23
.1.1 ERD

Figure 3.4 ERD

24
.1.1 Class Diagram

Figure 3.5Class Diagram

25
4. Chapter
Four

26
4.1 Design

This chapter introduces the design of Smart vision. And what is the approaches
and technology used to construct this framework were used

4.1.1 Mobile Application

4.1.1.1 Front-end Design


The user interface is designed to work at the presentation level. It is the
user's only means of interacting with our tariff system. The most crucial aspect of
Mobile Application system development is the external interface.

The client zone refers to the external interface. The goal of Mobile
Application creation is for people to be able to read and condense information
quickly when they visit the Mobile Application. Mobile Application front
development, also known as client-level development, is the process of creating
Mobile Application pages using some technologies like:
 Flutter
The Flutter program is a toolkit for programming and developing applications
“sdk”. Google launched it in early 2017. During this period, it achieved great
success, and many international companies relied on it to program and develop
their applications, such as the famous Google Adword program, BMW Motor
Company, and the Google Play Store. Alibaba, Ebay, and many, many more.

The Flutter program is based on the Dart language, which is a programming


language that Google programmed in 2011. Its main goal was to compete with the
Java language, but the competition between them was very difficult because of
the spread of the Java language at that time and the dependence of most designers
on it and after a while it became Some depend on the Dart language, due to the
remarkable development of it. It is also a very simple and easy-to-learn language
that gives the user complete freedom to modify every point in the application
interface simply.

27
Getting Started: This document provides a detailed introduction to Flutter and how to get
started using it, including installing Flutter, setting up an editor, and creating your first
Flutter app.

Flutter Basics: This document provides an overview of Flutter basics, including


fundamental concepts such as widgets, layouts, transitions, and animation.

Widgets: This document provides detailed information on widgets in Flutter, including


different types of widgets, how to use them, and how to customize them.

Layouts: This document provides information on how to layout app elements and
widgets in Flutter, including different types of layouts and how to customize them.

Navigation: This document provides information on how to navigate between screens in


a Flutter app, including how to create, customize, and organize pages.

Animations: This document provides information on how to add motion and animation to
app elements in Flutter, including how to use animations, effects, and transformations.

Networking: This document provides information on how to connect to web servers and
retrieve data in Flutter-designed apps.

State Management: This document provides information on how to manage state in Flutter-
designed apps, including using state management libraries like Provider and Redux.

Dart
Dart is a programming language designed by Lars Bak and Kasper Lund and
developed by Google. The programming language can be used to develop web
and mobile apps as well as server and
desktop applications.
One of the most important features of
the Dart language on which the Flutter
program relies is the fast download
feature, especially when modifying the
application, as it only uploads the files
that have been modified and not the entire application again.

28
 Plugins
Instead of having to build a feature from scratch, adding a plugin to the back end
of the application will give the mobile application owner more creative control
over the functionality of the application without the need for code. For example,
we used firebase as a backend service for database and authentication

4.1.1.2 Our Work


Developers build components and functions that users access directly
via a programme or system interface. It's a way for users and servers
to communicate. Customer development is what interface design is
all about. The construction of anexternal interface is a crucial part of
many aspects of software development. We designed a simple
external interface that allows users to interact with the software
easily.

29
Signup Page
This page allows the user to create a new account on the system.

figure 4.3 Signup Page

30
 Login Page
This page allows the user to log in to a website after confirming his e-mail.

figure 4.4login page

31
After logging in, the user can view the Home Page

 Home Page
This page is one of the most important pages of the application , it displays
the posts of followed users and enable the current user to interact with them

figure4.5 Home page

32
 add new post screen.
Inside the Add new post screen, the user can add the new post whether it is a
text or image or both of them, also decided to save the copyrights of this post or
not

figure 4.6 add object

 profile page.
33
this screen shows user posts and user data.

34
 explore page.

This screen shows all users in the app, so current user can follow them and browse their
posts.

35
4.1.2 Android

4.1.2.1 Architecture

In the Save Content app, we've implemented a structured architecture using Flutter that ensures the
app's functionality remains organized, scalable, and easy to maintain. Here's how the architecture is
structured from the perspective of our app:

1. UI Layer - Visual Appeal and User Interaction:


o In our app, the UI layer is where users interact with the app's interface. We've designed
visually appealing screens using Flutter's widget-based approach, creating a seamless
and intuitive user experience.
o Each screen is composed of widgets representing different UI elements such as
buttons, text fields, and images. We've organized these widgets into reusable
components, making it simple to update and maintain the app's visual appearance.
2. Business Logic Layer - Functionality and Data Processing:
o Behind the scenes, our app's business logic layer handles the app's functionality, data
processing, and business rules. This layer contains classes and modules responsible for
managing the app's state and handling data flow.
o We've utilized Flutter's state management solutions, such as Provider or Bloc, to
manage the app's state effectively and ensure smooth data flow between different
components.
o Business logic is encapsulated within separate classes or modules, allowing us to
maintain a clear separation of concerns and facilitating unit testing to ensure the app's
reliability.
3. Data Layer - Data Retrieval and Storage:
o The data layer of our app manages data retrieval and storage operations, including
communication with remote servers, local database access, and caching mechanisms.
o We've integrated packages like Dio for making HTTP requests to our backend API and
SQLite or Hive for local database storage, ensuring efficient data management within
the app.

36
o To promote flexibility and maintainability, we've implemented the repository pattern
or data source abstraction, decoupling the business logic from specific data sources and
enabling seamless data access.
4. Platform Integration - Accessing Native Device Features:
o Our app requires integration with platform-specific features and APIs to access device
functionalities such as camera access, geolocation, and push notifications.
o We've leveraged platform channels or plugins to communicate with native code written
in Java/Kotlin for Android and Swift/Objective-C for iOS, enabling seamless
integration of platform-specific functionality into our Flutter app.
5. Dependency Injection - Managing Dependencies:
o Dependency injection is used to manage our app's dependencies and facilitate
component decoupling and testability.
o We've utilized Flutter's built-in support for dependency injection using packages like
get it or provider, allowing for the injection of dependencies into various parts of our
app and ensuring a clean and modular codebase.

Overall, the architecture of the Save Content app emphasizes clarity, organization, and flexibility,
enabling us to deliver a robust and user-friendly social media platform that meets the needs of our
users.

37
4.1.2.2 UI Design

interaction design User Experience Design


It is the practice of designing It focuses on the overall experience
interactive digital products and between a user and a product. It is
services. concerned not only with the interactive
Interaction designers focus on the way elements, but also with how certain
users interact with products, and they elements look, feel, or concoct
use principles of good communication themselves to deliver certain outputs.
to create desired user experiences.
Table 4.8 Interaction Design VS UX

A layout defines the structure for a user interface in android app, such as in an activity.
All elements in the layout are built using a hierarchy of view and View Group objects. A
view usually draws something the user can see and interact with. Whereas a View Group
is an invisible container that defines the layout structure for View and other View Group
objects, as shown in figure.

Figure 4–9 View Group Layout

38
4.1.3 Back-End
The logic of the software is contained in the back-end design. This is the
most important part of programming. It is necessary for the entire system to work.
When there is a problem with the backend of the server, it leads to
stopping front-end functions.
The back end includes server-language sites, automated environments,
database management, authentication, validation, authorization, data analysis, and
data validation.

4.1.3.1 Architecture

In the architecture of the similarity check Flask app integrated with Firebase for text and image
comparison, the following components and interactions are involved:

1. Firebase Integration:
o The Flask app connects to Firebase to fetch existing text and image data from the
database. This connection is established using Firebase SDKs or RESTful APIs,
allowing the Flask app to retrieve the necessary data securely.
2. Text Similarity Check:
o When a new text post is submitted by a user through the Flutter frontend, the app
sends a request to the Flask app's endpoint dedicated to text similarity checks.
o The Flask app retrieves the existing text data from Firebase and utilizes text
similarity algorithms or APIs to compare the new post with the existing content.
o If the similarity threshold is exceeded, indicating potential duplication or
plagiarism, the Flask app communicates the result back to the Flutter frontend,
which can then notify the user and handle the rejection of the post.
3. Image Similarity Check:
o Similarly, when a new image post is uploaded by a user, the Flutter app sends a
request to the Flask app's endpoint for image similarity checks.
o The Flask app retrieves the existing image data from Firebase and employs image
recognition algorithms or APIs to compare the new image with the images stored in
the database.
39
o If the similarity score surpasses the predefined threshold, signaling a high degree of
similarity with existing images, the Flask app communicates this information to the
Flutter frontend for appropriate action, such as rejecting the post.
4. Feedback to the User:
o Upon completing the similarity checks for text and images, the Flask app provides
feedback to the Flutter frontend regarding the similarity results.
o This feedback includes information about the similarity score or degree of
similarity between the new post and existing content, enabling the frontend to
notify the user and enforce content duplication prevention measures if necessary.
5. Scalability and Performance:
o The Flask app is designed to handle multiple concurrent requests from the Flutter
frontend, ensuring scalability and responsiveness as the user base grows.
o Performance optimizations, such as caching frequently accessed data and
implementing efficient similarity algorithms, are implemented to minimize
response times and enhance user experience.

By integrating Firebase for data storage and retrieval and employing Flask for text and image
similarity checks, our architecture provides a robust solution for preventing content duplication
and ensuring the integrity of user-generated content in the Save Content app.

40
 Firebase:

In the architecture of the Save Content app, Firebase serves as a foundational component for data
storage and retrieval, leveraging its NoSQL database capabilities. Here's how Firebase and NoSQL
database integration contributes to the functionality and scalability of our app:
1. Real-Time Data Sync:
 Firebase offers real-time data synchronization, enabling seamless updates and
notifications across devices. This feature is particularly advantageous for a social
media platform like Save Content, where users expect instant updates on posts,
comments, and interactions.
 With Firebase Realtime Database or Firestore, changes made to the database are
immediately propagated to all connected clients, ensuring consistent and up-to-date
data across the app.
2. Scalability and Performance:
 Firebase's NoSQL database is designed for scalability, allowing our app to handle a
growing user base and increasing data volume without sacrificing performance.
NoSQL databases excel at horizontal scaling, making it easy to accommodate spikes in
user traffic and data ingestion.
 Firebase automatically handles scaling and load balancing behind the scenes, freeing
developers from the burden of managing infrastructure and ensuring a smooth user
experience even under heavy loads.
3. Flexible Data Modeling:
 NoSQL databases like Firebase offer flexible data modeling, allowing us to adapt our
data structures to meet the evolving needs of our app. Unlike traditional relational
databases, NoSQL databases do not enforce a rigid schema, enabling us to store
complex and hierarchical data structures efficiently.
 This flexibility is advantageous for a social media platform where user-generated
content may vary in structure and format, ranging from text posts and comments to
multimedia files and metadata.
4. Developer Productivity:
 Firebase simplifies the development process by providing a comprehensive suite of
tools and services, including authentication, cloud storage, and analytics. This
integrated approach streamlines app development and reduces time-to-market,
allowing us to focus on building innovative features and delivering value to our users.

41
 With Firebase's intuitive APIs and client SDKs for various platforms, developers can
quickly integrate backend functionality into our app and leverage advanced features
such as offline data synchronization and push notifications.
5. Security and Reliability:
 Firebase ensures robust security and reliability for our app's data. Data transmission is
encrypted using industry-standard protocols, protecting sensitive information from
unauthorized access.
 Firebase's built-in security rules enable fine-grained access control, allowing us to
define access permissions based on user roles and data hierarchy. This granular control
ensures data integrity and confidentiality, bolstering user trust and confidence in our
platform.
By leveraging Firebase's NoSQL database capabilities, the Save Content app benefits from real-
time data synchronization, scalability, flexibility, developer productivity, and robust security,
enabling us to build a responsive, feature-rich, and reliable social media platform for our users.

42
 Firebase console:

Figure 4.14 Firebase console

Firestore, part of the Firebase platform, is a NoSQL database offering real-time data
synchronization, scalability, offline support, rich querying capabilities, and robust security. It
seamlessly integrates with Firebase services, providing developers with a powerful tool for
building modern, cloud-native applications. With features like real-time data sync, scalable
querying, offline support, and granular security rules, Firestore simplifies development and
enables the creation of responsive, feature-rich apps across various platforms.

43
4.2 Artificial intelligent (AI)

4.2.1 Python
It is a high-level programming language,
which is easy to read and write. It is an open
source object-oriented programming language,
which offers fast development. The Python
programming language is an interpretive
language with multiple uses in several functions in several languages, such as
independent programs by graphical interfaces, and is used in creating the
Web. Learning Python is one of the easiest tasks in programming.

4.2.1.1 The most important characteristics and advantages of


the Python programming language:-
Ease of learning, as it contains easy and simple structures. - Python is an
open source and free language, as it is possible to distribute copies of it and
make changes to it freely. - Python is a high-level language, so you don't
need to review the details. It works on all major operating systems such as
Linux, Macintosh, and Windows. An object-oriented language that also
supports procedural programming. Learn about object-oriented languages
through this article. It has multiple uses, as it is used in many fields in many
programming paths.

44
4.2.1.2 Uses of the Python language
Python has wide uses in a large number of areas of programming. For example,
you can program games through the PyGame library, which enables you to
program games quickly and smoothly, and this library is an ideal start for
learning the basics of programming and game design, you will learn about a set
of technologies and the structure of games, this does not mean that it is not
suitable for making powerful games, for example Metin2 game is based on this
library, in addition to programming games you can also program desktop
applications. Also, to do this, there are many libraries, the most famous of which
is GTK or the QT library. On the other hand, you can program websites in the
Python language, relying on a set of frameworks, the most famous of which is
Django, which is a strong and solid framework, enough that large sites use it such
as Bitbucket or Pinterest, What the framework adds is an environment that
provides speed, organization, and protection, and this is one of the most
important factors for the success of any site. The areas of using Python do not
stop here, but also include a more exciting field, which is the world of hacking
experiments and other areas such as artificial intelligence. Despite this, many
criticize this language as being rather slow. This is due to the structure of the
language itself. On the other hand, most programmers prefer it because it is
beautiful and helps productivity. In a survey conducted by Stack overflow,
Python ranked sixth in the Back-End category, which is a hint of the popularity
of this language.

45
4.2.1.3 Use of TF-IDF for text similarity

The TF-IDF (Term Frequency-Inverse Document Frequency) and cosine similarity techniques are
widely used in natural language processing (NLP) for measuring the similarity between documents
based on their textual content. Here's a detailed explanation of each technique:

1. TF-IDF (Term Frequency-Inverse Document Frequency):


o Term Frequency (TF): This measures the frequency of a term (word) within a
document. It indicates how often a term appears in a document relative to the total
number of terms in that document. The formula for term frequency is:
TF(t,d)=Number of times term t appears in document dTotal number of terms in docu
ment dTF(t,d)=Total number of terms in document dNumber of times term t appears in
document d
o Inverse Document Frequency (IDF): This measures the importance of a term across
a collection of documents (corpus). It is calculated as the logarithm of the total number
of documents divided by the number of documents containing the term. The formula
for inverse document frequency is:
IDF(t,D)=log⁡Total number of documents in the corpusNumber of documents containin
g term tIDF(t,D)=logNumber of documents containing term tTotal number of documen
ts in the corpus
o TF-IDF Score: The TF-IDF score combines the TF and IDF values to give a
numerical representation of the importance of a term in a document relative to the
entire corpus. It is calculated as the product of the TF and IDF values: TF-
IDF(t,d,D)=TF(t,d)×IDF(t,D)TF-IDF(t,d,D)=TF(t,d)×IDF(t,D)
2. Cosine Similarity:
o Cosine similarity is a metric used to measure the similarity between two vectors in a
multidimensional space, commonly used in text similarity tasks.
o In the context of text similarity, documents are represented as vectors, where each
dimension corresponds to a unique term in the vocabulary, and the value of each
dimension represents the TF-IDF score of the corresponding term in the document.
o Cosine similarity measures the cosine of the angle between two vectors, representing
the similarity of their directions in the vector space. It ranges from -1 (completely
dissimilar) to 1 (completely similar), with 0 indicating orthogonality (no similarity).
o The cosine similarity sim(d1,d2)sim(d1,d2) between two documents d1d1 and d2d2 is
calculated as the dot product of their TF-IDF vectors divided by the product of their
Euclidean norms: sim(d1,d2)=d1⋅d2∥d1∥∥d2∥sim(d1,d2)=∥d1∥∥d2∥d1⋅d2
46
These techniques are commonly used in various NLP tasks such as document clustering,
information retrieval, and plagiarism detection. By computing the TF-IDF scores for terms in
documents and measuring the cosine similarity between document vectors, we can effectively
assess the textual similarity between documents and identify potentially duplicate or similar
content.

47
4.2.1.4 Using CNN for image similarity

Using Convolutional Neural Networks (CNNs) with the CIFAR-10 dataset for image similarity
involves training a neural network model to learn representations of images in the CIFAR-10
dataset and then using these representations to measure the similarity between images. Here's how
you can approach it:

1. CIFAR-10 Dataset:
o The CIFAR-10 dataset consists of 60,000 32x32 color images in 10 classes, with 6,000
images per class. It is commonly used for image classification tasks in computer
vision.
o Each image in the CIFAR-10 dataset belongs to one of the following classes: airplane,
automobile, bird, cat, deer, dog, frog, horse, ship, or truck.
2. Convolutional Neural Networks (CNNs):
o CNNs are a type of deep learning model commonly used for image-related tasks due to
their ability to capture spatial hierarchies and learn meaningful representations from
raw pixel data.
o The architecture of a typical CNN consists of convolutional layers, pooling layers, and
fully connected layers, followed by classification layers such as softmax or sigmoid for
prediction.
3. Image Similarity with CNNs:
o To measure image similarity using CNNs, you can train a CNN model on the CIFAR-
10 dataset to learn feature representations of images.
o Once the CNN model is trained, you can use it to extract feature vectors from images
in the dataset.
o To compare the similarity between two images, you can compute the cosine similarity
or Euclidean distance between their corresponding feature vectors.
o Images with similar feature representations (i.e., closer feature vectors) are considered
more similar, while images with dissimilar feature representations are considered less
similar.
4. Implementation Steps:
o Preprocess the CIFAR-10 dataset by resizing images to a consistent size (e.g., 32x32
pixels) and normalizing pixel values.
o Design and train a CNN model architecture using popular deep learning frameworks
such as TensorFlow or PyTorch.
48
o Extract feature representations from images using the trained CNN model's
intermediate layers (e.g., output of the last convolutional layer or fully connected layer
before classification).
o Compute pairwise similarities between images using cosine similarity or Euclidean
distance metrics applied to their feature representations.
o Optionally, visualize the similarity matrix or use it for downstream tasks such as image
retrieval or clustering.

By leveraging CNNs trained on the CIFAR-10 dataset, you can effectively measure the similarity
between images and identify visually similar images within the dataset. This approach is widely
used in applications such as image search engines, content-based image retrieval systems, and
image recommendation systems.

49
4.2.2 Our Work

2.2.5.1 Libraries we had used


4.2.5.1.1OpenCVpython.

OpenCV stands for Open Source Computer Vision Library. It is an open-source


computer vision and machine learning software library that provides a wide
range of tools and functions for image and video processing, object detection
and recognition, and other computer vision tasks.
Originally developed by Intel, OpenCV has grown into a popular library used by
researchers, developers, and hobbyists around the world. It supports multiple
programming languages such as C++, Python, Java, and MATLAB, making it
accessible to a wide range of developers. OpenCV offers a comprehensive set of
functionalities for various computer vision tasks. Some of the key features
include image and video I/O (input/output), image and video processing, feature
detection and extraction, object detection and tracking, camera calibration,
machine learning algorithms, and graphical user interface (GUI) support.
Some Usage of opencv:-
 Image and Video Processing: OpenCV provides a rich set of functions and
algorithms for manipulating and processing images and videos. It allows tasks
50
such as resizing, cropping, filtering, color conversion, and enhancement.

51
4.2.5.1.2 NumPy:
NumPy (Numerical Python) is a powerful library in Python that provides
support for large, multi-dimensional arrays and matrices.
Here are some common use cases and areas where NumPy is frequently utilized:
 Numerical Operations: NumPy provides a wide range of mathematical
functions and operators that can efficiently operate on arrays. It allows
performing element-wise operations, such as addition, subtraction,
multiplication, and division, as well as more advanced operations like
trigonometric functions, exponential and logarithmic functions, and linear
algebra operations.
 Data Analysis and Manipulation: NumPy is widely used in data analysis tasks.
It provides tools for indexing, slicing, and reshaping arrays, making it easy to
extract and manipulate subsets of data. NumPy arrays can be used for data
cleaning, filtering, aggregation, and transformation tasks.
 Linear Algebra: NumPy offers a comprehensive set of functions for linear
algebra operations, such as matrix multiplication, matrix factorization,
eigenvalues and eigenvectors computation, solving linear equations, and more.
These capabilities make NumPy suitable for tasks involving linear algebra,
such

52
as solving systems of equations, least squares fitting, and performing principal
component analysis (PCA). Overall, NumPy is a fundamental library for
scientific computing and data analysis in Python. Its ability to handle large
multi-dimensional arrays, along with its mathematical functions and
integration with other libraries, makes it a valuable tool in various domains,
including data analysis, machine learning, signal processing, and scientific
research.

53
3. TensorFlow:
o TensorFlow is an open-source machine learning framework developed by Google
Brain.
o It provides a flexible ecosystem for building and deploying machine learning models,
particularly deep learning models.
o TensorFlow's architecture revolves around computational graphs, where nodes
represent mathematical operations, and edges represent data flow.
o Key features of TensorFlow include:
1. Flexibility: TensorFlow supports various machine learning tasks, including
classification, regression, clustering, and reinforcement learning.
2. Scalability: TensorFlow is designed for scalability, enabling distributed training
across multiple CPUs or GPUs and deployment on cloud platforms such as
Google Cloud AI Platform.
3. High-level APIs: TensorFlow offers high-level APIs like Keras, which
simplifies the process of building and training neural networks. Keras provides
an intuitive interface for defining neural network architectures and training
models.
4. TensorBoard: TensorFlow includes TensorBoard, a visualization toolkit for
visualizing and debugging machine learning models. TensorBoard allows users
to visualize training metrics, model graphs, and embeddings, facilitating model
interpretation and optimization.
o TensorFlow is widely used in various domains, including computer vision, natural
language processing, speech recognition, and reinforcement learning.
4. NLTK (Natural Language Toolkit):
o NLTK is a leading platform for building Python programs to work with human
language data.
o It provides easy-to-use interfaces and libraries for text processing tasks such as
tokenization, stemming, tagging, parsing, and semantic reasoning.
o Key features of NLTK include:
1. Text Processing Utilities: NLTK offers a wide range of text processing utilities
for tasks such as tokenization (breaking text into words or sentences), stemming
(reducing words to their base or root form), and part-of-speech tagging
(assigning grammatical categories to words).

54
2. Lexical Resources: NLTK includes lexical resources such as WordNet, which
provides a lexical database of English words and their semantic relationships,
synonyms, and antonyms.
3. Statistical and Machine Learning Modules: NLTK includes modules for
statistical and machine learning-based NLP tasks, such as classification,
clustering, and information retrieval.
4. Corpora: NLTK provides access to numerous annotated corpora and lexical
resources, which are essential for training and evaluating NLP models.
o NLTK is widely used in academia and industry for research, education, and practical
applications in areas such as sentiment analysis, named entity recognition, text
classification, and machine translation.

55
5. Chapter
Five

56
5.1 Implementation

5.1.1 Mobile Application


How we authenticate in the front-end.
 User Login

import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:smart_vision/Work/linkapi.dart';
import 'package:smart_vision/component/crud.dart';
import 'package:smart_vision/component/customtextform.dart';
import 'package:smart_vision/main.dart';

import '../component/valid.dart';
import '../widgets/textformfield.dart';

class Login extends StatefulWidget {


@override
_LoginState createState() => _LoginState();
}
class _LoginState extends State<Login>
{ GlobalKey<FormState> formstate = GlobalKey();
TextEditingController email = TextEditingController();
TextEditingController password = TextEditingController();

Crud crud = Crud();


bool isLoading = false;

login() async {
if (formstate.currentState!.validate())
{ isLoading = true;
setState(() {});
var response = await crud.postRequest(linkLogin,
{"email" : email.text, "password": password.text});
isLoading = false;
setState(() {});
if (response['status'] == "success")
{ sharedPref.setString("id", response
['data']['id'].toString());
sharedPref.setString("username", response
['data']['username']);
sharedPref.setString("email", response ['data']['email']);
57
Navigator.of(context).pushNamedAndRemoveUntil("Home",
(route) => false) ;
}
else{
AwesomeDialog( contex
t: context,
// btnCancel: Text("Cancel"),
title: "Attention",
body: Text("The email or password is incorrect, or the
account does not exist"))..show();
}
}
}

 Logout
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Builder(builder: (context) {
return Scaffold(
appBar: AppBar(backgroundColor: Color(0xFFA9A9A9),
actions: [
IconButton(onPressed: (){
sharedPref.clear();
Navigator.of(context).pushNamedAndRemoveUntil("login",
(route) => false) ;
}, icon: Icon(Icons.exit_to_app),),
]),

One of the most important concepts used in building the front-end is the
term AJAX to deal with the APIS of our backend structure.

 Here the processes of adding

58
class _AddNotesState extends State<AddNotes>
with Crud {

File? myfile ;

GlobalKey<FormState> formstate =
GlobalKey<FormState>();

TextEditingController title =
TextEditingController();

TextEditingController content =
TextEditingController();

bool isloading = false;

addNotes() async {

if (myfile == null)

return AwesomeDialog(context: context,

title: "Important",

body: Text("Please add the image of the


note"))..show();

if (formstate.currentState!.validate()) {

isloading = true;

setState(() {});

var response = await


postRequestWithFile(linkAddNotes, {

"title": title.text,

"content": content.text,

"id": sharedPref.getString("id")

} , myfile!);

isloading = false;

setState(() {});
59
if (response['status'] == "success")

{ setState(() {

isloading=false;

});

Navigator.of(context).pushReplacementNamed("O
bjects");

} else {

showBottomSheet(){

return showModalBottomSheet(context: context,


builder: (context){

return Container(

padding: EdgeInsets.all(20),

height: 170,

child: Column(

crossAxisAlignment:
CrossAxisAlignment.start,

children: [

Text("Please Choose Image",style:


TextStyle(fontSize: 25,fontWeight:
FontWeight.bold),),

InkWell(

onTap: ()async{

XFile? xfile = await


ImagePicker().pickImage(source:
ImageSource.gallery);

60
Navigator.of(context).pop();

myfile = File(xfile!.path);

setState(() {});

},

child: Container(

padding: EdgeInsets.all(10),

width: double.infinity,

child: Row(children: [

Icon(Icons.photo,size: 30,),

SizedBox(width: 20,),

Text("From Gallery",style:
TextStyle(fontSize: 20),)

],),

),

),

InkWell(

onTap: ()async{

XFile? xfile = await


ImagePicker().pickImage(source:
ImageSource.camera);

Navigator.of(context).pop();

myfile = File(xfile!.path);

setState(() {});

},

61
 The process of loading the pages we use on all pages of the site even in
the event of a malfunction or slow Internet, this process plays its part.

FutureBuilder(
future: getNotes() ,
builder: (BuildContext context, AsyncSnapshot snapshot)
{ if (snapshot.hasData){
if (snapshot.data['status'] == 'fail')
return Center(child: Text("There is no notes",style: TextStyle(fontSize: 20,
fontWeight: FontWeight.bold),));
return ListView.builder(
itemCount: snapshot.data['data'].length,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, i){
return
CardNotes( onDelete: ()
async{
var response = await postRequest(linkDeleteNotes,
{ "id": snapshot.data['data'][i]['object_id'].toString(),
"imagename" : snapshot.data['data'][i]['object_image'].toString()
});
if (response['status'] == "success") {
Navigator.of(context).pushReplacementNamed("Objects");
}
},
onEdit: (){
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => EditNotes(notes:
snapshot.data['data'][i])));},
ontap: (){
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => EditNotes(notes:
snapshot.data['data'][i])));
},
notemodel: NoteModel.fromJson(snapshot.data['data'][i]),
62
); });

63
5.1.2 Back-End

We will discuss some important concepts in the database and how it was
created.

5.1.3 Android

 REST API
API is an application program interface (API) that uses HTTP requests to
GET, PUT, POST and DELETE data.
Representational State Transfer (REST) is an architectural style that defines
a set of constraints to be used for creating Mobile Application services. REST API
is a way of accessing Mobile Application services in a simple and flexible way
without having any processing.
REST technology is generally preferred to the more robust Simple Object
Access Protocol (SOAP) technology because REST uses less bandwidth, simple

and flexible making it more suitable for internet usage. It’s used to fetch or give
some information from a Mobile Application service. All communication done via
REST API usesonly HTTP request.
A request is sent from client to server in the form of Mobile Application
URL as HTTP GET or POST or PUT or DELETE request. After that, a response
comes back fromserver in the form of a resource which can be anything like
HTML, XML, Image or JSON. But now JSON is the most popular format being
used in Web Services.

In our case we have been used JSON format as the form of resources.
In HTTP there are five methods which are commonly used in a REST based
Architecture i.e., POST, GET, and DELETE. These correspond to create, read,
update, and delete (or CRUD) operations respectively. There are other methods
which are less frequently used like OPTIONS and HEAD.

64
o GET: The HTTP GET method is used to read (or retrieve) a
representation of a resource. In the safe path, GET returns a
representation in JSON and an HTTP response code of 200 (OK). In
an error case, it most often returns a 404 (NOT FOUND) or 400
(BAD REQUEST).
o POST: The POST verb is most-often utilized to create new resources.
In particular, it’s used to create subordinate resources. That is,
subordinate to some other (e.g. parent) resource. On successful
creation, return HTTP status 201, returning a Location header with a
link to the newly-created resource with the 201 HTTP status.
o DELETE: It is used to delete a resource identified by a URI.
On successful deletion, return HTTP status 200 (OK) along with
a response body.

figure 5.1 Firestore Security Configuration

65
We need to add the following dependencies in our build.grade file.

implementation "org.jetbrains.kotlin:kotlin-stdlib-
jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:31.0.2')
implementation 'com.android.support:multidex:1.0.3'

We have made our API service as an Interface class to hold all our
requests.

const String linkServerName =


"http://10.0.2.2/back_smart_vision";
const String linkImageRoot =
"http://10.0.2.2/back_smart_vision/upload";
// Auth
const String linkSignUp =
"$linkServerName/auth/signup.php";
const String linkLogin =
"$linkServerName/auth/login.php";
// Note
const String linkViewNotes =
"$linkServerName/notes/view.php";
const String linkAddNotes =
"$linkServerName/notes/add.php";
const String linkEditNotes =
"$linkServerName/notes/edit.php";
const String linkDeleteNotes =
"$linkServerName/notes/delete.php";

66
To use this interface, we have to use lots of objects in the whole project.
This will lead to many issues, such as the "memory leak" issue.
To solve this issue, we used a pattern called “singleton design pattern”.
Singleton pattern is one of the simplest design patterns in Dart. This type of
design pattern comes under creational pattern as this pattern provides one of the
best ways to create an object.
This pattern involves a single class which is responsible to create an object
while making sure that only single object gets created. This class provides a way to
access its only object which can be accessed directly without need to instantiate the
object of the class.

Figure 5.2 SingleTon Pattern

67
$title = filterRequest("title") ;
$content = filterRequest("content") ;
$userid = filterRequest("id") ;

$imagename = imageUpload("file") ;

if ($imagename != 'fail'){
$stmt = $con->prepare("
INSERT INTO `add_object`(`object_title`,
`object_content`, `object_users`, `object_image`)
VALUES (?, ?, ?, ?)
") ;

$stmt->execute(array($title , $content , $userid ,


$imagename)) ;

$count = $stmt->rowCount() ;

 Dealing with Database Images


Glide is open source and one of the widely used image download libraries in
Android. It is created and maintained by bumptech. It is among the powerful
image download and caching library for Android. Picasso simplifies the process of
loading images from external URLs and displays them on your application. For

68
example, downloading an image from the server is one of the most common tasks
in any application. And it needs quite a larger amount of code to achieve this via
android networking API. By using Glide, we can achieve this with a few lines of
code.
We need to add the following dependencies in our build.grade file.
implementation 'com.github.bumptech.glide:glide:4.13.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.1'

69
More Functionalities of the Glide Library
For any real-time application, we must think of all possible cases. We just
download the image from the server link. But how to display that image in the app.
How to resize it and what if the image loading failed? We need to have another
image showing an error message that image loading failed. This all matters for an
app developer. The following code are made in the RecyclerViewAdapter.

$userid = filterRequest("id") ;

$stmt = $con->prepare("SELECT * FROM add_object WHERE `object_users`


= ? ") ;

$stmt->execute(array($userid)) ;

$data = $stmt->fetchAll(PDO::FETCH_ASSOC) ;

$count = $stmt->rowCount() ;

if($count > 0){


echo json_encode(array("status" => "success" , "data" => $data )) ;
}else {
echo json_encode(array("status" => "fail")) ;
}

<?php
include "../connect.php" ;

$noteid = filterRequest("id") ;
$title = filterRequest("title") ;
$content = filterRequest("content") ;
$imagename= filterRequest("imagename");

if (isset($_FILES['file']))
{ deleteFile("../upload" , $imagename)
;
$imagename = imageUpload("file") ;

$stmt = $con->prepare("UPDATE `add_object` SET

70
`object_title`=?,`object_content`=? , object_image = ? WHERE
object_id = ?
") ;

$stmt->execute(array($title , $content , $imagename, $noteid)) ;

$count = $stmt->rowCount() ;

if($count > 0){


echo json_encode(array("status" => "success")) ;
}else {
echo json_encode(array("status" => "fail")) ;
}

$noteid = filterRequest("id") ;
$imagename = filterRequest("imagename") ;

$stmt = $con->prepare("DELETE FROM add_object WHERE object_id = ?")


;

$stmt->execute(array($noteid)) ;

$count = $stmt->rowCount() ;

if($count > 0){


deleteFile("../upload" , $imagename) ;
echo json_encode(array("status" => "success")) ;
}else {
echo json_encode(array("status" => "fail")) ;
}

71
 Shared Preferences in Android
One of the most Interesting Data Storage option Android provides its users
is Shared Preferences. Shared Preferences is the way in which one can store and
retrieve small amounts of primitive data as key/value pairs to a file on the device
storage such as String, int, float, Boolean that make up preferences in an XML file
inside the app on the device storage. Shared Preferences can be thought of as a
dictionary or a key/value pair.
Shared Preferences class provides APIs for reading, writing, and managing
this data. A sample GIF is given below to get an idea about what we are going to
do in this article.
Shared Preferences are suitable in different situations. For example, when
the user’s settings need to be saved or to store data that can be used in different
activities within the app. As you know, onPause() will always be called before

72
your activity is placed in the background or destroyed, so for the data to be saved
persistently, it’s preferred to save it in onPause(), which could be restored in
onCreate() of the activity. The data stored using shared preferences are kept private
within the scope of the application. However, shared preferences are different from
that activity’s instance state.
Note that we have been implemented this app using the Dart language.

 How is Shared Preferences different from Saved Instance State?


Shared Preferences Saved Instance State
Persist Data across user sessions, even Preserves state data across activity
if the app is killed and restarted, or the instances in the same user session.
device is rebooted.
Data that should be remembered across Data that should not be remembered
sessions, such as the user’s preferred across sessions, such as the currently
settings or their game score. selected tab or current state of activity.
A common use is to store user A common use is to recreate the state
preferences after the device has been rotated
Table 5.3 SharedPref VS Saved Instance

73
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:dropdown_search/dropdown_search.dart';
import 'package:smart_vision/notes/edit.dart';

late SharedPreferences sharedPref ;

void main() async {


WidgetsFlutterBinding.ensureInitialized();
sharedPref = await SharedPreferences.getInstance();
// await Firebase.initializeApp();
runApp(MyApp());
}

class MyApp extends StatelessWidget {


@override
Widget build(BuildContext context)
{ return MaterialApp(
title: 'Smart Vision', debugShowCheckedModeBanner: false,
theme: ThemeData(
textTheme: TextTheme(
// headline1: TextStyle(fontSize: 50.0, fontWeight: FontWeight.bold, color:
Colors.white),
// headline2: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold, color:
Colors.white, letterSpacing: 3),
// bodyText1: TextStyle(fontSize: 16.0, color: Colors.white),
// bodyText2: TextStyle(fontSize: 15.0, color: Colors.white, letterSpacing: 1),
// headline3: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold,color:
Colors.black),
// headline4: TextStyle(fontSize: 35.0, color: Colors.black,fontWeight:
FontWeight.bold,),
// subtitle1: TextStyle(fontSize: 14.0, color: Colors.white, fontWeight:
FontWeight.bold, letterSpacing: 1,)
),
),
home: splash_screen(),
initialRoute: sharedPref.getString("id") == null ? "login" : "splash_screen",
routes: {
"Home": (context)=> Home(),
"splash_screen": (context)=> splash_screen(),
"SignUp" : (context) => SignUp(),
74
"Work": (context)=> MyHomePage(),
"Test": (context)=> test(),
"Objects": (context)=> Objects(),
"AddNotes":(context)=> AddNotes(),
"login":(context) => Login(), "signup":
(context) => SignUp(), "editnotes":
(context) => EditNotes(),
},
);
}
}

<?php
include "../connect.php" ;

$email = filterRequest("email") ;
$password = filterRequest("password") ;

$stmt = $con->prepare("SELECT * FROM users WHERE `password` = ? AND


email = ? ") ;

$stmt->execute(array($password , $email)) ;

$data = $stmt->fetch(PDO::FETCH_ASSOC) ;

$count = $stmt->rowCount() ;

if($count > 0){


echo json_encode(array("status" => "success" , "data" => $data )) ;
}else {
echo json_encode(array("status" => "fail")) ;
}

 MVVM Pattern
As we already knew, we used the MVVM architecture in our project. One
of the most important concepts in this architecture is called "Repository".

75
Repository is a class which purpose is to provide a clean API for accessing
data. What that means is that the Repository can gather data from different data
sources (different REST APIs, cache, local database storage) and it provides this
data to the rest of the app.
Repository pattern will persist objects and the need of having to know how
those objects would be actually persisted in the underlying database, i.e., without
having to be bothered about how the data persistence happens underneath. The
knowledge of this persistence, i.e., the persistence logic, is encapsulated inside a
class called “Repository”.

try {

$con = new PDO($dsn , $user , $pass ,


$option );
$con->setAttribute(PDO::ATTR_ERRMODE ,
PDO::ERRMODE_EXCEPTION) ;
header("Access-Control-Allow-Origin:
*");
header("Access-Control-Allow-Headers:
Content-Type, Access-Control-Allow-Headers,
Authorization, X-Requested-With, Access-
Control-Allow-Origin");
header("Access-Control-Allow-Methods:
POST, OPTIONS , GET");

include "functions.php";
checkAuthenticate() ;

76
import 'dart:io';

import
'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:path/path.dart';
import 'package:smart_vision/auth/Signup.dart';

String _basicAuth = 'Basic ' +


base64Encode(utf8.encode(
'wael:wael12345'));

Map<String, String> myheaders =


{ 'authorization': _basicAuth
};

class Crud {
getRequest(String url) async {
try{
var response = await http.get(Uri.parse(url));
if (response.statusCode == 200){
var responsebody = jsonDecode(response.body);
return responsebody;
}else {
print("Error ${response.statusCode}");
}
}catch(e){
print("Error Catch $e");
}
}

postRequest(String url, Map data) async {


try{
var response = await http.post(Uri.parse(url), body: data,
headers:myheaders);
if (response.statusCode == 200){
var responsebody = jsonDecode(response.body);
return responsebody;
77
}else {

78
print("Error ${response.statusCode}");
}
}catch(e){
print("Error Catch $e");
}
}

postRequestWithFile(String url, Map data, File file) async


{ var request = http.MultipartRequest("POST",
Uri.parse(url)); var length = await file.length();
var stream = http.ByteStream(file.openRead());
var multipartFile = http.MultipartFile("file", stream, length,
filename: basename(file.path));
request.headers.addAll(myheaders);
request.files.add(multipartFile);
data.forEach((key, value)
{ request.fields[key] = value;
});
var myrequest = await request.send();

var response = await http.Response.fromStream(myrequest);


if (myrequest.statusCode == 200){
return jsonDecode(response.body);
}else {
print("Error ${myrequest.statusCode}");
}
}
}

5.1.4 AI
5.1.4.1 Object Detection
import cv2
cap=cv2.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)

79
classNames= []
classFile = "coco.names"
with open(classFile,'rt') as f:
classNames =f.read().rstrip('\n').split('\n')

configPath = 'ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
weightsPath = 'frozen_inference_graph.pb'

net = cv2.dnn_DetectionModel(weightsPath,configPath)

net.setInputSize (320,320)
net.setInputScale(1.0/ 127.5)
net. setInputMean ((127.5, 127.5, 127.5))
net.setInputSwapRB(True)
while True:
success,img=cap.read()
classIds, confs, bbox = net.detect(img, confThreshold=0.5)
print(classIds, bbox)

if len(classIds) != 0:
for classId, confidence, box in zip(classIds.flatten(),confs.flatten(),bbox):
cv2.rectangle(img,box,color=(0,255,0),thickness=2)
cv2.putText(img, classNames[classId-1].upper(), (box [0]+10,box[1]+30),
cv2.FONT_HERSHEY_COMPLEX,1,(0,255.0),2)
cv2.imshow("output",img)
cv2.waitKey(1)

5.1.4.2 Face Recognition


import cv2
import numpy as np
import face_recognition
import os

def CountFreq(li):
freq = {}
80
for items in li:
freq[items] = li.count(items)
# print(freq)
a=str(freq)
if cv2.waitKey(1) & 0xFF == ord('r'):

path = 'images/'
images = []
classNames = []
personsList = os.listdir(path)

for cl in personsList:
curPersonn = cv2.imread(f'{path}/{cl}')
images.append(curPersonn)
classNames.append(os.path.splitext(cl)[0])
print(classNames)
0
def findEncodeings(image):
encodeList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
encode = face_recognition.face_encodings(img)[0]
encodeList.append(encode)
CountFreq(classNames)
return encodeList

encodeListKnown = findEncodeings(images)
print('Encoding Complete.')

cap = cv2.VideoCapture(0)

while True:
_, img = cap.read()

imgS = cv2.resize(img, (0,0), None, 0.25, 0.25)

81
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)

faceCurentFrame = face_recognition.face_locations(imgS)
encodeCurentFrame = face_recognition.face_encodings(imgS, faceCurentFrame)

for encodeface, faceLoc in zip(encodeCurentFrame, faceCurentFrame):


matches = face_recognition.compare_faces(encodeListKnown, encodeface)
faceDis = face_recognition.face_distance(encodeListKnown, encodeface)
matchIndex = np.argmin(faceDis)

if matches[matchIndex]:
name = classNames[matchIndex].upper()
print(name)
y1, x2, y2, x1 = faceLoc
y1, x2, y2, x1 = y1*4, x2*4, y2*4, x1*4
cv2.rectangle(img, (x1, y1), (x2, y2), (0,0,255), 2)
cv2.rectangle(img, (x1,y2-35), (x2,y2), (0,0,255), cv2.FILLED)
cv2.putText(img, name, (x1+6, y2-6), cv2.FONT_HERSHEY_COMPLEX, 1,
(255,255,255), 2)

cv2.imshow('Face Recogntion', img)


cv2.waitKey(1)

5.1.4.3 Speech

from PIL import Image


from pytesseract import image_to_string
from playsound import playsound
import gtts

image=Image.open('ss.JPG')
text=image_to_string(image,lang='eng')
tts=gtts.gTTS(text,lang='en',slow='false')
tts.save('voic.mp3')
playsound('voic.mp3')

82
5.2 Testing

5.2.1 Testing Implementation


Is the process of putting a strategy into action. Before it can be implemented,
the strategy must be finished and the target must be determined. Any activity
mentioned in the plan is evaluated for success.
Test Case Input Expected Obtained Pass/Fail Test On
Outcome Outcome

Registration Register Register Register Pass 20/3/2023


Name, Successful Successful
E-mail,
Password,

Login E-mail, Login Login Pass 20/3/2023


Password Successful Successful

83
Taking Open Photo taken Photo taken Pass 1/4/2023
Photo Camera successfully successfully

Manage Create, All All Pass 15/4/2022


Read, operations operations
Update, work work
Delete
Table 5.4. Testing Duration

5.2.2 Testing Report


This test report is required in order to acquire formal test results, allowing
for a quick and detailed review of the results. It's a report that uses data from the
patch test office to explain the environmental and operating circumstances, as well
as how the test results compare to the test objectives. The test report is quite
important, and you must comprehend it. The test report is vital because you need
to know whether or not the equipment is ready. It's a text that documents the
results of a research study:
 Registration Test
 Practical Tests
 Presentation Testing
 Usability Tests
 Scalability Testing

Here are some benefits of testing.


 Make the UI better and simpler for interaction.
 Improve The functionality of the application.
 Enhance the system's performance
 Make the system very easy to use.

84
6. Chapter
Six

85
6.1 Conclusion

In general, this project aims to help the blind in all areas of life and make life
better through (smart vision) and make life better and more flexible for them, where
they can practice life better and live like normal people, where (smart vision) can see
things or people in front of them and get to know them And saying what this thing is,
and from the salvation of this idea,
we learn that there is no impossible with persistence and determination, and any
problem we face can be solved, but we must work on them with effort, persistence, and
determination to achieve it, in addition to true cooperation with teamwork without any
obstacles.

6.2 Future Work

We are looking forward to improving our project and we have the ability to
provide our project with other ideas. There are some future features that we
would like to add to our idea, for
Example:-
 Helping people with special abilities (the deaf) by hearing the voice
and displaying it as text on the interface of the application.

86
6.3 References

[1] Google, "Speech to Text," 2023. [Online]. Available:


https://www.geeksforgeeks.org/python-convert-speech-to-text-and-text-to-
speech/.
[2] "speech.py," [Online]. Available:
https://www.thepythoncode.com/article/using- speech-recognition-to-convert-
speech-to-text-python.
[3] " ESP32-CAM Video Streaming and Face Recognition," 2022. [Online].
Available: https://randomnerdtutorials.com/esp32-cam-video-streaming-face-
recognition-arduino-ide/.
[4] A. Tyagi, "Better Android Apps Using MVVM with Clean Architecture,"
[Online]. Available: https://www.toptal.com/android/android-apps-mvvm-
with-clean-architecture.
[5] " ESP32-CAM - Video Streaming and Face Recognion," [Online].
Available: https://www.elementzonline.com/blog/esp32-cam-video-
streaming-face- recognition-tutorial.
[6] " ESP32 CAM Based Face & Eyes Recognition System,"
2022. [Online]. Available:
https://how2electronics.com/esp32-cam-based-face-eyes-
recognition-system/.
[7] " object detection" 2023. [Online]. Available:
https://paperswithcode.com/task/object-detection.
[8] " object detection " 2023. [Online]. Available:
https://machinelearningmastery.com/object-recognition-with-deep-learning/.
[9] "Flutter Dev," 2023. [Online]. Available:https://flutter.dev/.

[10] Flutter Documentation, 2023. [Online]. Available: https://docs.flutter.dev/

[11] "Dart Dev," 2023. [Online]. Available: https://dart.dev/effective-


dart/documentation.
[12] "phpmyadmain," 2023. [Online]. Available: https://www.phpmyadmin.net/
10
[13] "connect mysql with phpmyadmain," 2022. [Online]. Available:
https://www.digitalocean.com/community/tutorials/how-to-connect-to-
mysql-managed-database-via-phpmyadmin.
[14] Xiaoyue Jiang, Abdenour Hadid, Yanwei Pang, Eric
Granger, Xiaoyi Feng2019, "Deep Learning in Object Detection
and Recognition". [Online].Available:
https://link.springer.com/book/10.1007/978-981-10-5152-4.
[15] S Poonkuntran, Rajesh Kumar Dhanraj, Balamurugan Balusamy 2022:
Object Detection with Deep Learning Models
Principles and Applications. Available: https://www.routledge.com/Object-
Detection-with-Deep-Learning-Models-Principles-and-
Applications/Poonkuntran-Dhanraj-Balusamy/p/book/9781032074009
[16] "object detection library yolo," [Online]. Available:
https://docs.ultralytics.com/usage/python/.
[17] " object detection," [Online]. Available:
https://towardsdatascience.com/enhanced-object-detection-how-to-
effectively-implement-yolov8-afd1bf6132ae.
[18] " dataset yolo," [Online]. Available:
https://github.com/ibaiGorordo/ONNX- YOLOv8-Object-Detection.
[19] " face-recognition," [Online].
Availablehttps://github.com/ageitgey/face_recognition.
[20] " face-recognition," [Online]. Available: https://pypi.org/project/face-
recognition/.

10

You might also like