Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
369f5fcb
Commit
369f5fcb
authored
Oct 17, 2020
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing the implementation of lecture activity frame recordings.
parent
f451b8fa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
10 deletions
+67
-10
FirstApp/MongoModels.py
FirstApp/MongoModels.py
+3
-3
FirstApp/api.py
FirstApp/api.py
+55
-4
FirstApp/serializers.py
FirstApp/serializers.py
+9
-3
No files found.
FirstApp/MongoModels.py
View file @
369f5fcb
...
...
@@ -189,9 +189,9 @@ class LectureActivityFrameGroupings(models.Model):
# this abstract class will contain lecture activity frame recognition details
class
LectureActivityFrameRecognitionDetails
(
models
.
Model
):
frame_name
=
models
.
CharField
(
max_length
=
15
)
phone_perct
=
models
.
DecimalField
(
default
=
0.0
,
max_digits
=
3
,
decimal_places
=
1
)
listen_perct
=
models
.
DecimalField
(
default
=
0.0
,
max_digits
=
3
,
decimal_places
=
1
)
note_perct
=
models
.
DecimalField
(
default
=
0.0
,
max_digits
=
3
,
decimal_places
=
1
)
phone_perct
=
models
.
FloatField
(
)
listen_perct
=
models
.
FloatField
(
)
note_perct
=
models
.
FloatField
(
)
class
Meta
:
abstract
=
True
...
...
FirstApp/api.py
View file @
369f5fcb
...
...
@@ -361,8 +361,59 @@ class GetLectureActivityRecognitionsForFrames(APIView):
def
get
(
self
,
request
):
video_name
=
request
.
query_params
.
get
(
'video_name'
)
# finding the existence of Lecture activity frame recognition record
isExist
=
LectureActivityFrameRecognitions
.
objects
.
filter
(
lecture_activity_id__lecture_video_id__video_name
=
video_name
)
.
exists
()
if
(
isExist
):
lecture_activity_frame_recognitions
=
LectureActivityFrameRecognitions
.
objects
.
filter
(
lecture_activity_id__lecture_video_id__video_name
=
video_name
)
lecture_activity_frame_recognitions_ser
=
LectureActivityFrameRecognitionsSerializer
(
lecture_activity_frame_recognitions
,
many
=
True
)
lecture_activity_frame_recognitions_data
=
lecture_activity_frame_recognitions_ser
.
data
[
0
]
frame_detections
=
lecture_activity_frame_recognitions_data
[
'frame_recognition_details'
]
return
Response
({
"response"
:
frame_detections
})
else
:
# retrieve the lecture activity id
lec_activity
=
LectureActivity
.
objects
.
filter
(
lecture_video_id__video_name
=
video_name
)
lec_activity_ser
=
LectureActivitySerializer
(
lec_activity
,
many
=
True
)
lec_activity_data
=
lec_activity_ser
.
data
[
0
]
lec_activity_id
=
lec_activity_data
[
'id'
]
# create a new lecture activity frame detections id
last_lec_activity_frame_recognitions
=
LectureActivityFrameRecognitions
.
objects
.
order_by
(
'lecture_activity_frame_recognition_id'
)
.
last
()
new_lecture_activity_frame_recognitions_id
=
"LAFR00001"
if
(
last_lec_activity_frame_recognitions
is
None
)
else
\
ig
.
generate_new_id
(
last_lec_activity_frame_recognitions
.
lecture_activity_frame_recognition_id
)
# calculate the frame detections
frame_detections
=
ar
.
get_frame_activity_recognition
(
video_name
)
frame_recognition_details
=
[]
# save the new lecture activity frame recognitions
for
detection
in
frame_detections
:
lec_activity_frame_recognition_details
=
LectureActivityFrameRecognitionDetails
()
lec_activity_frame_recognition_details
.
frame_name
=
detection
[
'frame_name'
]
lec_activity_frame_recognition_details
.
phone_perct
=
detection
[
'phone_perct'
]
lec_activity_frame_recognition_details
.
listen_perct
=
detection
[
'listening_perct'
]
lec_activity_frame_recognition_details
.
note_perct
=
detection
[
'note_perct'
]
frame_recognition_details
.
append
(
lec_activity_frame_recognition_details
)
lec_activity_frame_recognitions
=
LectureActivityFrameRecognitions
()
lec_activity_frame_recognitions
.
lecture_activity_frame_recognition_id
=
new_lecture_activity_frame_recognitions_id
lec_activity_frame_recognitions
.
lecture_activity_id_id
=
lec_activity_id
lec_activity_frame_recognitions
.
frame_recognition_details
=
frame_recognition_details
lec_activity_frame_recognitions
.
save
()
return
Response
({
"response"
:
frame_detections
})
...
...
FirstApp/serializers.py
View file @
369f5fcb
...
...
@@ -289,6 +289,7 @@ class LectureActivityFrameRecognitionsSerializer(serializers.ModelSerializer):
lecture_activity_id
=
LectureActivitySerializer
()
frame_recognition_details
=
serializers
.
SerializerMethodField
()
# this method will be used to serialize the 'frame_recogition_details' field
def
get_frame_recognition_details
(
self
,
obj
):
return_data
=
[]
...
...
@@ -297,9 +298,9 @@ class LectureActivityFrameRecognitionsSerializer(serializers.ModelSerializer):
recognition
=
{}
recognition
[
"frame_name"
]
=
frame_recognition
.
frame_name
recognition
[
"phone_perct"
]
=
frame_recognition
.
frame_name
recognition
[
"listen_perct"
]
=
frame_recognition
.
frame_name
recognition
[
"note_perct"
]
=
frame_recognition
.
frame_name
recognition
[
"phone_perct"
]
=
frame_recognition
.
phone_perct
recognition
[
"listen_perct"
]
=
frame_recognition
.
listen_perct
recognition
[
"note_perct"
]
=
frame_recognition
.
note_perct
return_data
.
append
(
recognition
)
...
...
@@ -307,6 +308,11 @@ class LectureActivityFrameRecognitionsSerializer(serializers.ModelSerializer):
return
return_data
class
Meta
:
model
=
LectureActivityFrameRecognitions
fields
=
'__all__'
# EMOTIONS section
# lecture emotions serailzier
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment