Python Opencv实现相机使用OpenCV模块进行摄像头捕捉,从而实现相机的功能
pos = event.pos if viewRect.collidepoint(pos): view = True if view == False else False elif BlightRect.collidepoint(pos): circled = "blight" elif ColorRect.collidepoint(pos): circled = "color" elif changeRect.collidepoint(pos): video = True if video == False else False elif catchRect.collidepoint(pos): if video == False: try: if view == False: image = Image.open('temp.png') image = ImageEnhance.Brightness(image) image = image.enhance(Blight / 20) image = ImageEnhance.Color(image) image = image.enhance(Color / 20) image.save("./美丽照片/" str(time.strftime("%y%m%d%H%M%S")) ".png") else: image = Image.open('temp.png') image.save("./美丽照片/" str(time.strftime("%y%m%d%H%M%S")) ".png") print("拍摄成功!") except Exception as e: print("因某种原因,拍摄出错,错误代码:",e) else: if writing == True: writing = False else: writing = True video_ = cv2.VideoWriter( str(time.strftime("%y%m%d%H%M%S")) ".avi", cv2.VideoWriter_fourcc("M","P","4","2"), out_fps, size ) circled = ""
评论