Skip to main content

A Thai sign language translator library used with Mediapipe that translate Thai hand sign language into plain Thai characters.

Project description

Thai sign language translator (ThSLT)

License

Description

This is a Thai sign language library for python used for translating Thai sign language into plain Thai characters. This library is used with Mediapipe and OpenCV, so you should install those libraries first to make ThSLT function properly. Although the code works about 90% of the time, there are a lot of factors that you need to consider such as background , lighting , camera quality , hardware qualities. To increase the accuracy, you can adjust the min_tracking_confidence and min_detection_confidence from the default values.

Table of Contents

Installation

Use the following methods to install nessecary libraries

  • To install OpenCV, use the following command
pip install opencv-python
  • To install Mediapipe, use the following command
pip install mediapipe

Use the following method to install ThSLT

  • To install ThSLT, use the following command
pip install thslt

Usage

Here's an example setup for ThSLT:

import thslt , cv2 
import mediapipe as mp

mpdraw = mp.solutions.drawing_utils
mphands = mp.solutions.hands
mpdrawing_styles = mp.solutions.drawing_styles
hands = mphands.Hands(static_image_mode=False,
                      model_complexity=1,
                      min_detection_confidence=0.8,
                      min_tracking_confidence=0.8,
                      max_num_hands=2)

capture = cv2.VideoCapture(0)
text_encode = [] 

while True:
    ret, frame = capture.read()
    bgrtorgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    results = hands.process(bgrtorgb)
    thslt.translate(frame,results,text_encode)
    if results.multi_hand_landmarks:
        for hand_landmarks in results.multi_hand_landmarks:
            for id, lm in enumerate(hand_landmarks.landmark):
                h,w,c = frame.shape
                Cx,Cy = int(lm.x*w), int(lm.y*h)
                mpdraw.draw_landmarks(frame,
                                    hand_landmarks,
                                    mphands.HAND_CONNECTIONS,
                                    mpdrawing_styles.get_default_hand_landmarks_style(),
                                    mpdrawing_styles.get_default_hand_connections_style())

    cv2.imshow("Hand Tracking",frame)
    key = cv2.waitKey(1)
    if key == 27: ### Esc key
        break
cv2.destroyAllWindows()

translation = thslt.decode(text_encode)
print(translation)

ThSLT has a built in Mediapipe hand mapping. So mapping the hand landmarks is not necessary. It only helps you notice that the camera is actually mapping your hand.

Configuration

Text_encode

  • declare text_encode as a blank array before start capturing the video
text_encode = [] 

Features

Translate

  • use this function after you create a loop for OpenCV
translate(frame,results,text_encode)

Parameters

  • frame = capture.read()
  • results = Hands.process(bgrtorgb)
  • text_encode = [ ]

Decode

  • use this function after you exit the loop for OpenCV to encode text_encode
translation = encode(text_encode)

License

Copyright 2023 Papangkon Ninarundech

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledgments

Thank you to the individuals who assisted in creating this project.

  • Mr.Jiraroj Wiruchpongsanon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thslt-1.0.5.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file thslt-1.0.5.tar.gz.

File metadata

  • Download URL: thslt-1.0.5.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for thslt-1.0.5.tar.gz
Algorithm Hash digest
SHA256 262b191cde20b5ca8faa786d0d02cb9b0f0d35b705404dfd12d3cf4cb2954bf6
MD5 3493bf761a4738d4f8f57f7e4dc2a84e
BLAKE2b-256 60daedbbeabe4ababd79bf9586f3dbfe5104106a829c73a8c9ca1035aeca36d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page