Skip to content

Commit

Permalink
fix: fixing pointer code
Browse files Browse the repository at this point in the history
  • Loading branch information
shinsj4653 committed Feb 25, 2024
1 parent c303fc9 commit 5f13eec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions OCR/googleOCR.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ def text_pointer(uri, x, y):
words = []

for i, text in enumerate(texts):

if i == 0: # 사진 내 전체 문자는 제외해야함
continue

print(f"Image Size: {img_width} x {img_height}")
word = text.description
print('word:', word)
Expand All @@ -217,6 +221,7 @@ def text_pointer(uri, x, y):
print('hand y :', y)

for vertex in text.bounding_poly.vertices :

print('vertex x :',vertex.x)
print('vertex y :',vertex.y)
x_set.add(vertex.x)
Expand Down Expand Up @@ -247,8 +252,8 @@ def text_pointer(uri, x, y):
print('min_x, x, max_x', min_x, x, max_x)
print('max_y y', max_y, y)
# print("거리 : math.sqrt((abs(x - mid_x) ** 2) + (abs(y - mid_y) ** 2))" )
# words.append((word, math.sqrt((abs(x - mid_x) ** 2) + (abs(y - mid_y) ** 2)))) # (단어, 단어의 가운데 좌표 값과 손 좌표 간 거리)
words.append((word, abs(y - max_y) + abs(x - mid_x)))
words.append((word, math.sqrt((abs(x - mid_x) ** 2) + (abs(y - mid_y) ** 2)))) # (단어, 단어의 가운데 좌표 값과 손 좌표 간 거리)
#words.append((word, abs(y - max_y) + abs(x - mid_x)))


words.sort(key=lambda x: x[1]) # 손과 가장 가까운 단어를 반환
Expand Down
2 changes: 1 addition & 1 deletion OCR/handLandmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_finger_coordinate(uri):
handYset.add(value.y)

#min_x = max(handXset)
min_y = max(handYset)
min_y = min(handYset)

right_hand_x_coordinate = int(detection_result.hand_landmarks[0][8].x * image_shape[1])
right_hand_y_coordinate = int(min_y * image_shape[0])
Expand Down

0 comments on commit 5f13eec

Please sign in to comment.