def camera_show(window_name='camera'):
    '最好在改进一下关闭窗口部分的功能\n    建立一个窗口捕捉摄像头显示的内容\n    当左键点击过窗口，且按过任意键盘键，才会退出窗口'
    clicked = False
    camera_capture = cv2.VideoCapture(0)

    def on_mouse(event, x, y, flags, param):
        global clicked
        if (event == cv2.EVENT_LBUTTONUP):
            clicked = True
    cv2.namedWindow(window_name)
    cv2.setMouseCallback(window_name, on_mouse)
    (success, frame) = camera_capture.read()
    while (success and (cv2.waitKey(1) == (- 1)) and (not clicked)):
        cv2.imshow(window_name, frame)
        (success, frame) = camera_capture.read()
    cv2.destroyAllWindows()
    camera_capture.release()
最好在改进一下关闭窗口部分的功能
建立一个窗口捕捉摄像头显示的内容
当左键点击过窗口，且按过任意键盘键，才会退出窗口
def camera_show(window_name='camera'):
    '最好在改进一下关闭窗口部分的功能\n    建立一个窗口捕捉摄像头显示的内容\n    当左键点击过窗口，且按过任意键盘键，才会退出窗口'
    clicked = False
    camera_capture = cv2.VideoCapture(0)

    def on_mouse(event, x, y, flags, param):
        global clicked
        if (event == cv2.EVENT_LBUTTONUP):
            clicked = True
    cv2.namedWindow(window_name)
    cv2.setMouseCallback(window_name, on_mouse)
    (success, frame) = camera_capture.read()
    while (success and (cv2.waitKey(1) == (- 1)) and (not clicked)):
        cv2.imshow(window_name, frame)
        (success, frame) = camera_capture.read()
    cv2.destroyAllWindows()
    camera_capture.release()