me python script eka wada karanawa awl

hecker_thama

Well-known member
  • Dec 27, 2022
    6,764
    6,977
    113
    Python:
    import cv2
    import pyautogui
    
    # Initialize the webcam
    cap = cv2.VideoCapture(0)
    
    while True:
        # Capture the current frame
        ret, frame = cap.read()
        # Convert the frame to grayscale
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        # Apply Gaussian blur to the frame
        blur = cv2.GaussianBlur(gray, (5,5), 0)
        # Apply thresholding to the frame
        ret, thresh = cv2.threshold(blur, 60, 255, cv2.THRESH_BINARY_INV)
        # Find contours in the frame
        contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        # Iterate through the contours
        for cnt in contours:
            # Check if the contour is a finger
            if cv2.contourArea(cnt) > 500:
                # Draw a bounding box around the finger
                x,y,w,h = cv2.boundingRect(cnt)
                cv2.rectangle(frame, (x,y), (x+w, y+h), (0,255,0), 2)
        # Display the frame
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1)
        if key == ord('q'):
            break
        elif key == ord('u'):
            pyautogui.hotkey('volumeup')
        elif key == ord('d'):
            pyautogui.hotkey('volumedown')
    
    # Release the webcam and close the window
    cap.release()
    cv2.destroyAllWindows()
     

    IndrajithGamage

    Well-known member
  • Oct 6, 2022
    13,447
    1
    15,100
    113
    ChatGPT ගඳ එන්නෙ මට විතරද. 😜🙏

    මට හිතෙන්නෙ උඹ මේ try කරන්නෙ hand gestures වලින් volume අඩු වැඩි කරන එකක් හදන්න වගේ නේද? උඹෙ declaration ටික පොඩ්ඩක් අංජබජල් බං. මේ වගේ try කරලා බලහන්කො.

    Python:
    import cv2
    import pyautogui
    
    # Initialize the webcam
    cap = cv2.VideoCapture(0)
    
    while True:
        # Capture the current frame
        ret, frame = cap.read()
        # Convert the frame to grayscale
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        # Apply Gaussian blur to the frame
        blur = cv2.GaussianBlur(gray, (5,5), 0)
        # Apply thresholding to the frame
        ret, thresh = cv2.threshold(blur, 60, 255, cv2.THRESH_BINARY_INV)
        # Find contours in the frame
        contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        
        for cnt in contours:
            if cv2.contourArea(cnt) > 2000:
                x,y,w,h = cv2.boundingRect(cnt)
                cv2.rectangle(frame, (x,y), (x+w, y+h), (0,255,0), 2)
                cv2.putText(frame, "Hand gesture detected", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,0,0), 2)
                pyautogui.hotkey('volumeup')
            else:
                cv2.putText(frame, "No hand gesture detected", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2)
    
        # Display the frame
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1)
        if key == ord('q'):
            break
    
    # Release the webcam and close the window
    cap.release()
    cv2.destroyAllWindows()
     
    Last edited:
    • Haha
    Reactions: x0th3r

    x0th3r

    Member
    Dec 6, 2022
    19
    23
    3
    ChatGPT ගඳ එන්නෙ මට විතරද. 😜🙏

    මට හිතෙන්නෙ උඹ මේ try කරන්නෙ hand gestures වලින් volume අඩු වැඩි කරන එකක් හදන්න වගේ නේද? උඹෙ declaration ටික පොඩ්ඩක් අංජබජල් බං. මේ වගේ try කරලා බලහන්කො.

    Python:
    import cv2
    import pyautogui
    
    # Initialize the webcam
    cap = cv2.VideoCapture(0)
    
    while True:
        # Capture the current frame
        ret, frame = cap.read()
        # Convert the frame to grayscale
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        # Apply Gaussian blur to the frame
        blur = cv2.GaussianBlur(gray, (5,5), 0)
        # Apply thresholding to the frame
        ret, thresh = cv2.threshold(blur, 60, 255, cv2.THRESH_BINARY_INV)
        # Find contours in the frame
        contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
       
        for cnt in contours:
            if cv2.contourArea(cnt) > 2000:
                x,y,w,h = cv2.boundingRect(cnt)
                cv2.rectangle(frame, (x,y), (x+w, y+h), (0,255,0), 2)
                cv2.putText(frame, "Hand gesture detected", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,0,0), 2)
                pyautogui.hotkey('volumeup')
            else:
                cv2.putText(frame, "No hand gesture detected", (50,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,0,255), 2)
    
        # Display the frame
        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1)
        if key == ord('q'):
            break
    
    # Release the webcam and close the window
    cap.release()
    cv2.destroyAllWindows()
    OW OW ChatGPT thama 😂
     
    • Haha
    Reactions: IndrajithGamage

    x0th3r

    Member
    Dec 6, 2022
    19
    23
    3
    yeah mage linux ekata camera detection seen adui kiwwa chat gpt eken generate kala hariyata wada na
    Bro oka oya stackoverflow eken ahnna poddak. ChatGPT wala script aul godak welawata. oya script eka stack eke danna epa. eken detect wenawa chatgpt kiyla. oyage question eka witharak danna.
     
    • Wow
    Reactions: hecker_thama