<s> import cv2 <EOL> def webcam_gui ( filter_func , video_src = <NUM_LIT:0> ) : <EOL> cap = cv2 . VideoCapture ( video_src ) <EOL> key_code = - <NUM_LIT:1> <EOL> while ( key_code == - <NUM_LIT:1> ) : <EOL> ret , frame = cap . read ( ) <EOL> frame_out = filter_func ( frame ) <EOL> cv2 . imshow ( '<STR_LIT>' , frame_out ) <EOL> key_code = cv2 . waitKey ( <NUM_LIT:10> ) <EOL> cap . release ( ) <EOL> cv2 . destroyAllWindows ( ) <EOL> def edge_filter ( frame_in ) : <EOL> frame_gray = cv2 . cvtColor ( frame_in , cv2 . COLOR_BGR2GRAY ) <EOL> frame_blur = cv2 . blur ( frame_gray , ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> frame_out = cv2 . Canny ( frame_blur , <NUM_LIT:30> , <NUM_LIT> ) <EOL> return frame_out <EOL> def threshold ( frame_in ) : <EOL> frame_gray = cv2 . cvtColor ( frame_in , cv2 . COLOR_BGR2GRAY ) <EOL> frame_blur = cv2 . blur ( frame_gray , ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> thresh1 , thresh = cv2 . threshold ( frame_blur , <NUM_LIT> , <NUM_LIT:255> , cv2 . THRESH_BINARY ) <EOL> frame_out = thresh <EOL> return frame_out <EOL> def adap_threshold ( frame_in ) : <EOL> frame_gray = cv2 . cvtColor ( frame_in , cv2 . COLOR_BGR2GRAY ) <EOL> frame_blur = cv2 . blur ( frame_gray , ( <NUM_LIT:3> , <NUM_LIT:3> ) ) <EOL> thresh = cv2 . adaptiveThreshold ( frame_blur , <NUM_LIT:255> , cv2 . ADAPTIVE_THRESH_GAUSSIAN_C , cv2 . THRESH_BINARY , <NUM_LIT:11> , <NUM_LIT:2> ) <EOL> frame_out = thresh <EOL> return frame_out <EOL> def gray_filter ( frame_in ) : <EOL> frame_out = cv2 . cvtColor ( frame_in , cv2 . COLOR_BGR2GRAY ) <EOL> return frame_out <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> webcam_gui ( adap_threshold ) </s>
