Skip to content
Snippets Groups Projects
Commit e113f8ec authored by Hyunseok_Sang's avatar Hyunseok_Sang
Browse files

이미지에서 객체를 탐지하고, 그 결과를 Dict형태로 리턴하는 Service

parent 980396b0
Branches
No related tags found
No related merge requests found
from services.api.object_detect_api import ObjectDetectAPI
class ObjectDetectionService:
def detect_objects(self, image_bytes):
objects = ObjectDetectAPI().detect_objects(image_bytes)
results = {}
for obj in objects:
name = obj.name.lower()
four_normalized_vertices_obj = obj.bounding_poly.normalized_vertices
left = four_normalized_vertices_obj[0].x
top = four_normalized_vertices_obj[0].y
right = four_normalized_vertices_obj[2].x
bottom = four_normalized_vertices_obj[2].y
result = {
"left": left,
"top": top,
"right": right,
"bottom": bottom
}
if name in results:
results[name].append(result)
else:
results[name] = [result]
return results
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment