Accessing 'response' variables in coroutine to record webcam feed
I am using a coroutine in order to record webcam feed while displaying some text stimulus and taking in a keyboard response. The coroutine should end when the user presses a key. This is the function i have written and supplied to the "Generator function name":
def recordVidResponse(): frame_width = int(var.cap.get(3)) frame_height = int(var.cap.get(4)) out = cv2.VideoWriter('/home/upamanyu/Desktop/outpy.avi', cv2.VideoWriter_fourcc('M','J','P','G'), 30, (frame_width,frame_height)) yield while True: ret, frame = var.cap.read() if ret: print("dv") out.write(frame) if var.response_video_keyboard is not None: break yield out.release()
Although the documentation says that "response" and "response_[item_name]" variables should always be available i keep getting this error:
The variable 'response_video_keyboard' does not exist.
I have tried the above code with var.response instead of var.response_video_keyboard and i get the same error.
I have attached a picture of my coroutine structure. Please help out if you know what's going wrong.