gesture_servo
gesture_servo
gesture_servo
pwm = pigpio.pi()
pwm.set_mode(servo, pigpio.OUTPUT)
pwm.set_PWM_frequency( servo, 50 )
detector=HandDetector(detectionCon=0.5,maxHands=1)
width=640
height=480
Known_distance = 50.0
Known_width = 9.0
cap=cv2.VideoCapture(0)
a=[]
def Focal_Length_Finder(Known_distance, real_width, width_in_rf_image):
ref_image = cv2.imread("/home/rdr/rf.png")
ref_image_obj_width = obj_data(ref_image)
Focal_length_found = Focal_Length_Finder(Known_distance, Known_width,
ref_image_obj_width)
cv2.imshow("ref_image", ref_image)
print(Focal_length_found)
while True:
ret,frame=cap.read()
#frame=cv2.flip(frame,1)
obj_width_in_frame=obj_data(frame)
if not obj_width_in_frame:
print("no hands")
else:
Distance = Distance_finder(Focal_length_found, Known_width,
obj_width_in_frame)
print(Distance)
if(Distance>=15 or Distance<=50):
for i in a:
x1=i[0]
y1=i[1]
frame=cv2.imshow("FRAME",frame)
cv2.waitKey(1)
cap.relase()
cv2.destroyAllWindows()