Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstrings #24

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions coreapi/main_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@


def FaceRecogniseInImage(request, filename):
"""Face Recognition in image

Args:
request: Post https request containing a image file
filename: filename of the video

Returns:
Dictionary having all the faces and corresponding bounding boxes
"""
file_path = os.path.join(MEDIA_ROOT, 'images/' + filename)
handle_uploaded_file(request.FILES['file'], file_path)
file = request.FILES['file']
Expand Down Expand Up @@ -61,6 +70,15 @@ def FaceRecogniseInImage(request, filename):


def FaceRecogniseInVideo(request, filename):
"""Face Recognition in Video

Args:
request: Post https request containing a video file
filename: filename of the video

Returns:
Dictionary having all the faces and corresponding time durations
"""
file_path = os.path.join(MEDIA_ROOT, 'videos/' + filename)
handle_uploaded_file(request.FILES['file'], file_path)
try:
Expand Down Expand Up @@ -134,6 +152,16 @@ def FaceRecogniseInVideo(request, filename):


def createEmbedding(request, filename):
"""
To create embeddings of face

Args:
request: Post https request containing a image file
filename: filename of the video

Returns:
success flag
"""
file = request.FILES['file']
if file and allowed_file(filename=filename, allowed_set=allowed_set):
filename = secure_filename(filename=filename).replace('_', ' ').split('.')[0].title()
Expand Down Expand Up @@ -167,6 +195,16 @@ def createEmbedding(request, filename):


def stream_video_download(url, filename):
"""
to download a youtube video

Args:
url: url of the youtube video
filename: filename of the video

Returns:
Nothing
"""
output_dir = "{}/{}/".format(MEDIA_ROOT, 'videos')
command = "youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \"{}\" -o {}.mp4".format(url, filename)
try:
Expand Down