Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from _ctypes import COMError #84

Closed
SMRaza1009 opened this issue Nov 28, 2023 · 1 comment
Closed

from _ctypes import COMError #84

SMRaza1009 opened this issue Nov 28, 2023 · 1 comment
Labels

Comments

@SMRaza1009
Copy link

Hey!

I currently using Ubuntu 22.04 and python 3.8.

When i am running my code.
import time
import cv2
import numpy as np
import HandTrackingModule as htm
import mediapipe as mp
import math
from comtypes import CLSCTX_ALL
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume

widthCam, heightCam = 640, 480

cap = cv2.VideoCapture(0)
cap.set(3, widthCam)
cap.set(4, heightCam)
previousTime = 0

detector = htm.handDetector(detectionCon=0.8)

devices = AudioUtilities.GetSpeakers()
interface = devices.Activate(
IAudioEndpointVolume.iid, CLSCTX_ALL, None)
volume = interface.QueryInterface(IAudioEndpointVolume)
volume.GetMute()
volume.GetMasterVolumeLevel()
volume.GetVolumeRange()
volume.SetMasterVolumeLevel(-20.0, None)

while True:

succcess, img = cap.read()
img = detector.findHands(img)
landmarkList = detector.findPosition(img, draw=False)
if len(landmarkList) != 0:
    #print(landmarkList[4], landmarkList[8])

    x1, y1 = landmarkList[4][1], landmarkList[4][2]
    x2, y2 = landmarkList[8][1], landmarkList[8][2]

    # Making a circle in between line
    cx, cy = (x1+ x2)//2, (y1+y2)//2

    cv2.circle(img, (x1, y1), 10, (128, 70, 66), cv2.FILLED)
    cv2.circle(img, (x2, y2), 10, (128, 70, 66), cv2.FILLED)
    cv2.line(img, (x1, y1), (x2, y2), (92, 135, 100), 2)
    cv2.circle(img, (cx, cy), 10, (92, 135, 100), cv2.FILLED)
    #print((x1, y1), (x2, y2))

    length_points = math.hypot((x2-x1), (y2-y1))

    if length_points < 50:
        cv2.circle(img, (cx, cy), 10, (0, 100, 255), cv2.FILLED)


    print(length_points)

# FPS Logic
currentTime = time.time()
fps = (1 / (currentTime - previousTime))
previousTime = currentTime

cv2.putText(img, f'FPS: {int(fps)}', (30,60), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 3, 255), 3)

cv2.imshow("Image", img)
cv2.waitKey(1)

Getting this error!
from _ctypes import COMError

ImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so)

@katyalmohit
Copy link

katyalmohit commented Jul 23, 2024

This library is supported only on the Windows operating system. It is stated in the README.md file. You can also refer to the issue COMError from '_ctypes #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants