Frontend
Overview
Angular ( TypeScript ) framework is used for frontend of the application. We have written code in a modular way, segregating different parts into following components.
- App root component
- Input Video component
- Video Streaming component
- Snapshots Rendering component
- Radio buttons component
App root component
Main component of the framework.
Objectives
- Keep Track of state of the application.
- Manage global state of the application.
Functions
-
refreshEvent(event)
:- Input : Feature Type wrapped in an Angular Event
- Trigger : User clicking a different feature type will trigger this function
- Function : Reloading video stream and snapshots based on selected feature
- Output : None
-
stateOff(event)
:- Input : Application state wrapped in an Angular Event
- Trigger : Backend processing getting completed
- Function : Changing application state at global level
- Output : None
Variables
-
state
:- Type : Boolean ( True / False )
- Purpose : Global application state indicating whether media files should be rendered or not
- Default Value :
false
-
title
:- Type : String
- Purpose : Title of the application
- Default Value :
frontend
Modules
@angular/core/ViewChild
:- Purpose : To access video streaming and snapshots components from typescript code.
Input Video Component
Objectives
- Take user's video as input and send it to backend
- Once user selects video, ask users for different parameters which will be used in analysis
- Send parameters to backend for analysis
Functions
-
startProcessing()
:- Input : None
- Trigger : User clicking 'Start' button
- Purpose : To set the application status to 'processing'
- Output : None
-
finishProcessing()
:- Input : None
- Trigger : Backend finishing processing
- Purpose : To set the application status to done with processing
- Output : None
-
upload()
:- Input : None
- Trigger : User clicking upload button
- Purpose : To upload video to backend
- Output : None
-
getImage()
:- Input : Image url ( String )
- Trigger : User starting process of uploaded video
- Purpose : To get a frame of video on which user can draw
- Output : None
-
openModal(templateReference)
:- Input : Reference to a modal box tag in template
- Trigger : User clicking next on modal boxes
- Purpose : Open the corresponding modal box
- Output : None
-
saveRoadLength(input_)
:- Input : Reference to input tag in template
- Trigger : User clicking next after typing road length
- Purpose : Save the typed road length input
- Output : None
-
loadCanvas(modalName)
:- Input : Name of modal box
- Trigger : User wanting to draw on image
- Purpose : Load canvas on top of image on which user can draw
- Output : None
-
btnClick()
:- Input : None
- Trigger : Finishing inputting parameters
- Purpose : Finishing inputting parameters
- Output : None
-
finalize()
:- Input : None
- Trigger : User clicking 'Next' button in the last modal box
- Purpose : Finalize parameters
- Output : None
-
makePolygon()
:- Input : None
- Trigger : User clicking 4th point in the drawing
- Purpose : Making polygon out of selected points
- Output : None
-
clearCanvas()
:- Input : None
- Trigger : User finishing drawing
- Purpose : Clear drawing canvas
- Output : None
-
diableButtonsOnClearCanvas()
:- Input : None
- Trigger : User clicking buttons on canvas
- Purpose : Disable buttons on clear canvas selection
- Output : None
-
getCoordinatesZebra()
:- Input : None
- Trigger : User clicking next on zebra crossing modal box
- Purpose : To save coordinates of zebra corssing
- Output : None
-
getCoordinatesPedestrian()
:- Input : None
- Trigger : User clicking next on pedestrian modal box
- Purpose : To save coordinates of pedesitrian area
- Output : None
-
getCoordinatesLane()
:- Input : None
- Trigger : User clicking next on lane marking modal box
- Purpose : To save coordinates of lane markings
- Output : None
Variables
-
uploadedFiles
:- Type : Array<'File'>
- Purpose : Store uploaded files
- Default Value : Empty
-
state
:- Type : Boolean
- Purpose : State of the application
- Default Value : Same as root component
-
processingStatus
:- Type : Boolean
- Purpose : Stores whether processing is completed or not
- Default Value :
false
-
stateOff
:- Type : Event Emitter
- Purpose : To trigger parent component to change status
- Default Value :
false
-
uploadStatus
:- Type : Boolean
- Purpose : To show whether uploading is done or not
- Default Value :
false
-
scalingFactorX
:- Type : Float
- Purpose : To show how much to scale coordinates in x direction
- Default Value :
1
-
scalingFactorY
:- Type : Float
- Purpose : To show how much to scale coordinates in y direction
- Default Value :
1
-
uploaded
:- Type : Boolean
- Purpose : To show status about uploading
- Default Value :
false
-
imageToShow
:- Type : any
- Purpose : Image which will be showed
- Default Value : None
-
isImageLoading
:- Type : any
- Purpose : To store status of image loading
- Default Value : None
-
fileName
:- Type : String
- Purpose : To store filename of uploaded video
- Default Value : Empty String
-
uploadDisabled
:- Type : Boolean
- Purpose : To show whether upload button is disabled or not
- Default value :
false
-
fileSize
:- Type : Integer
- Purpose : To store size of file
- Default value : 0
-
inputSpeedForm
:- Type : FormGroup
- Purpose : Form for taking speed limit as input
- Default value : None
-
roadLendthForm
:- Type : FormGroup
- Purpose : Form for taking road length as input
- Default value : None
-
speedlimit
:- Type : Integer
- Purpose : Speedlimit
- Default Value : 100
-
roadLendth
:- Type : Integer
- Purpose : To store approximate lenght of road in metres
- Default Value : 0
Modules
-
@angular/common/http
:- Purpose : To make HTTP requests including posting videos and parameters
-
rxjs/operators
:- Purpose : To extend timeout period of HTTP requests to ensure that
Video Streaming Component
Objectives
- Render video from backend onto frontend
- Reload appropriate video based on feature selected
Functions
reload(feature)
:- Input : Rule breaking feature selected
- Trigger : User clicking radio button of a traffic rule feature
- Purpose : To change the video based on traffic rule selected
- Output : None
Variables
-
videoelement
:- Type : HTMLVideoElement
- Purpose : Based on feature selected, reloading video
- Default Value : None
-
base
:- Type : String
- Purpose : Base url from where to retrieve video
- Default Value : '/api/getvideo/'
-
url
:- Type : String
- Purpose : Final url from where to retrieve video
- Default Value : '/api/getvideo/'
-
state
:- Type : Boolean
- Purpose : Global application state binded to parent, to show whether to render application or not
- Default Value : Same as Parent
Modules
@angular/core/Input
:- Purpose : To bind a variable to parent component variable
Snapshots Rendering Component
Objectives
- Retrieve images corresponding to a particular feature
- Render images with a scrollbar
Functions
reload(feature)
:- Input : Rule breaking feature selected
- Trigger : User clicking radio button of a traffic rule feature
- Purpose : To change the images based on traffic rule selected
- Output : None
Variables
-
imagesList
:- Type : Array
- Purpose : To store list of images to render on the component
- Default Value : Empty Array
-
feature
:- Type : String
- Purpose : Global variable to store feature, corresponding to that feature images will be rendered
- Default Value : 'default'
-
state
:- Type : Boolean
- Purpose : Global application state binded to parent, to show whether to render images or not
- Default Value : Same as Parent
Modules
@angular/common/http
:- Purpose : To make HTTP request to retrieve images from backend
Radio buttons component
Objectives
- Provide user with radio buttons for easy navigation between different features
- Based on radio button selected reload video streaming and rendering snapshots
Functions
handleClick(event)
:- Input : Rule breaking feature selected wrapped in an event
- Trigger : User clicking radio button of a traffic rule feature
- Purpose : To invoke reload functions in snapshot and video components
- Output : None
Variables
-
refreshEvent
:- Type : EventEmitter
- Purpose : Event Emitter, binded with parent
- Default Value : None
-
feature
:- Type : String
- Purpose : Global variable to store feature, that feature will be passed to snapshots and video components
- Default Value : 'default'
-
state
:- Type : Boolean
- Purpose : Global application state binded to parent, to show whether to render images/video or not
- Default Value : Same as Parent
Modules
-
@angular/common/http
:- Purpose : To make HTTP request to retrieve images from backend
-
@angular/core/EventEmitter
:- Purpose : Binding variables from parent to child components