Skip to content

Commit

Permalink
Merge pull request #51 from sptramer/pep8
Browse files Browse the repository at this point in the history
Run PEP8 on content
  • Loading branch information
emmanuel-bv authored Dec 4, 2019
2 parents c314687 + 5b8b269 commit 40c8d24
Show file tree
Hide file tree
Showing 14 changed files with 398 additions and 317 deletions.
81 changes: 45 additions & 36 deletions modules/CameraCapture/app/AnnotationParser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#To make python 2 and python 3 compatible code
# To make python 2 and python 3 compatible code
from __future__ import absolute_import

#Returns rectangle boundaries in the CV2 format (topLeftX, topLeftY, bottomRightX, bottomRightY) given by a processing service
# Returns rectangle boundaries in the CV2 format (topLeftX, topLeftY, bottomRightX, bottomRightY) given by a processing service


class AnnotationParser:
def getCV2RectanglesFromProcessingService1(self, response):
try:
Expand All @@ -10,53 +12,60 @@ def getCV2RectanglesFromProcessingService1(self, response):
for decoration in item:
if "box" in decoration.lower():
rectList = item[decoration].split(",")
top = int(rectList[0])
left = int(rectList[1])
width = int(rectList[2])
height = int(rectList[3])
top = int(rectList[0])
left = int(rectList[1])
width = int(rectList[2])
height = int(rectList[3])
for decorationProperty in item[decoration]:
if "top" in decorationProperty.lower():
top = int(item[decoration][decorationProperty])
if "left" in decorationProperty.lower():
left = int(item[decoration][decorationProperty])
left = int(item[decoration]
[decorationProperty])
if "width" in decorationProperty.lower():
width = int(item[decoration][decorationProperty])
width = int(item[decoration]
[decorationProperty])
if "height" in decorationProperty.lower():
height = int(item[decoration][decorationProperty])
height = int(item[decoration]
[decorationProperty])
if top is not None and left is not None and width is not None and height is not None:
topLeftX = left
topLeftY = top
bottomRightX = left + width
bottomRightY = top + height
listOfCV2Rectangles.append([topLeftX, topLeftY, bottomRightX, bottomRightY])
listOfCV2Rectangles.append(
[topLeftX, topLeftY, bottomRightX, bottomRightY])
return listOfCV2Rectangles
except:
#Ignoring exceptions for now so that video can be read and analyzed without post-processing in case of errors
# Ignoring exceptions for now so that video can be read and analyzed without post-processing in case of errors
pass

def getCV2RectanglesFromProcessingService2(self, response):
try:
listOfCV2Rectangles = []
for item in response:
for decoration in item:
if "rect" in decoration.lower():
for decorationProperty in item[decoration]:
if "top" in decorationProperty.lower():
top = int(item[decoration][decorationProperty])
if "left" in decorationProperty.lower():
left = int(item[decoration][decorationProperty])
if "width" in decorationProperty.lower():
width = int(item[decoration][decorationProperty])
if "height" in decorationProperty.lower():
height = int(item[decoration][decorationProperty])
if top is not None and left is not None and width is not None and height is not None:
topLeftX = left
topLeftY = top
bottomRightX = left + width
bottomRightY = top + height
listOfCV2Rectangles.append([topLeftX, topLeftY, bottomRightX, bottomRightY])
return listOfCV2Rectangles
except:
#Ignoring exceptions for now so that video can be read and analyzed without post-processing in case of errors
pass

try:
listOfCV2Rectangles = []
for item in response:
for decoration in item:
if "rect" in decoration.lower():
for decorationProperty in item[decoration]:
if "top" in decorationProperty.lower():
top = int(item[decoration][decorationProperty])
if "left" in decorationProperty.lower():
left = int(item[decoration]
[decorationProperty])
if "width" in decorationProperty.lower():
width = int(item[decoration]
[decorationProperty])
if "height" in decorationProperty.lower():
height = int(item[decoration]
[decorationProperty])
if top is not None and left is not None and width is not None and height is not None:
topLeftX = left
topLeftY = top
bottomRightX = left + width
bottomRightY = top + height
listOfCV2Rectangles.append(
[topLeftX, topLeftY, bottomRightX, bottomRightY])
return listOfCV2Rectangles
except:
# Ignoring exceptions for now so that video can be read and analyzed without post-processing in case of errors
pass
Loading

0 comments on commit 40c8d24

Please sign in to comment.