Save Content
Save Content
Modern Academy
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
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.
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.
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.
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
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
10
1.7 Expected Outcome
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
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.
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.
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.
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:
15
3. Chapter
Three
16
3.1 Requirements & Analysis
Some simple but essential specifications are acquired during the program's
implementation and data collection.
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:
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:
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.1 Android
Operating system: Android
API level: 21
Android Version: 8.0
20
.1 UML Diagrams
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.
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.
23
.1.1 ERD
24
.1.1 Class 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
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.
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.
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.
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
29
Signup Page
This page allows the user to create a new account on the system.
30
Login Page
This page allows the user to log in to a website after confirming his e-mail.
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
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
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:
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
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.
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:
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.
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:
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
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
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';
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.
58
class _AddNotesState extends State<AddNotes>
with Crud {
File? myfile ;
GlobalKey<FormState> formstate =
GlobalKey<FormState>();
TextEditingController title =
TextEditingController();
TextEditingController content =
TextEditingController();
addNotes() async {
if (myfile == null)
title: "Important",
if (formstate.currentState!.validate()) {
isloading = true;
setState(() {});
"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 Container(
padding: EdgeInsets.all(20),
height: 170,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
InkWell(
onTap: ()async{
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{
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.
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.
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.
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 (?, ?, ?, ?)
") ;
$count = $stmt->rowCount() ;
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->execute(array($userid)) ;
$data = $stmt->fetchAll(PDO::FETCH_ASSOC) ;
$count = $stmt->rowCount() ;
<?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") ;
70
`object_title`=?,`object_content`=? , object_image = ? WHERE
object_id = ?
") ;
$count = $stmt->rowCount() ;
$noteid = filterRequest("id") ;
$imagename = filterRequest("imagename") ;
$stmt->execute(array($noteid)) ;
$count = $stmt->rowCount() ;
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.
73
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:dropdown_search/dropdown_search.dart';
import 'package:smart_vision/notes/edit.dart';
<?php
include "../connect.php" ;
$email = filterRequest("email") ;
$password = filterRequest("password") ;
$stmt->execute(array($password , $email)) ;
$data = $stmt->fetch(PDO::FETCH_ASSOC) ;
$count = $stmt->rowCount() ;
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 {
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';
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");
}
}
78
print("Error ${response.statusCode}");
}
}catch(e){
print("Error Catch $e");
}
}
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)
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()
81
imgS = cv2.cvtColor(imgS, cv2.COLOR_BGR2RGB)
faceCurentFrame = face_recognition.face_locations(imgS)
encodeCurentFrame = face_recognition.face_encodings(imgS, faceCurentFrame)
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)
5.1.4.3 Speech
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
83
Taking Open Photo taken Photo taken Pass 1/4/2023
Photo Camera successfully successfully
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.
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
10