I get a parameter gender from my client application and using that value (male/female/None) I would like to change the video shown on the display. I have written an if-else loop. But the issue is that there is a lot of delay in switching the video when the gender changes. Is there a more elegant solution? I would appreciate your thoughts. Thanks.
I have tried this code (server side)
def getData(self):
dst = None
if self.myHandler.items is not None:
if len(self.myHandler.items.decode('utf-8')) != 0:
# dst = self.myHandler.items.decode('utf-8')
output = self.myHandler.items.decode('utf-8')
dst = json.loads(output)
if dst["gender"] == "F":
cap = cv2.VideoCapture('No.1/women.mp4')
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
elif dst["gender"] == "M":
cap = cv2.VideoCapture('No.1/men.mp4')
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
elif dst["gender"] == None :
cap = cv2.VideoCapture('No.1/normal.mov')
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()