Skip to content

Commit

Permalink
Merge pull request #96 from lahirumenik/main
Browse files Browse the repository at this point in the history
player distance up to 4m distance
  • Loading branch information
lahirumenik authored Jan 22, 2024
2 parents 61980ae + 892ac10 commit 3da033f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions backend/serverless/Lambda/bullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import numpy as np
from io import BytesIO
import base64
import json



def zoom(img, zoom_factor=2):
return cv2.resize(img, None, fx=zoom_factor, fy=zoom_factor)


def imread_from_base64(base64_string):
image_binary_data = base64.b64decode(base64_string)
Expand Down Expand Up @@ -71,18 +76,17 @@ def findColor(img, points, decoded_info):
return False

def lambda_handler(event, context):
#print(event)
body_dict = json.loads(event['body'])
#print(body_dict)

encoded_str = body_dict['img']
img = imread_from_base64(encoded_str)
encoded_str = event.body.img
img_un = imread_from_base64(encoded_str)
row, col = img_un.shape[0], img_un.shape[1]
img_c = img_un[(1 * row) // 8:(5 * row) // 8, (3 * col) // 16:(5 * col) // 8]
img = zoom(img_c, 3)
retval, decoded_info, points, straight_qrcode = qcd.detectAndDecodeMulti(img)
result = findColor(img, points, decoded_info)
if result:
return {"statusCode": 200, "body": result}
return {"statusCode": 200, "body": result}
else:
return {"statusCode":404, "body": "Not a hit"}
return {"statusCode":200, "body": "Not a hit"}

#body: json.dumps
# findColor()
Expand Down

0 comments on commit 3da033f

Please sign in to comment.