Opencv 摄像头水平镜像


import cv2

cap = cv2.VideoCapture(0)
start_time = time.time()
while cap.isOpened():
    ok, im = cap.read() 
    if not ok:            
         break   
    img = copy.deepcopy(im)
    h,w,_ = img.shape
    for i in range(h):
       for j in range(w):
            img[i,w-1-j] = im[i,j] #水平镜像   
    
    finall_time = time.time()
    cv2.imshow('d', img)
    c = cv2.waitKey(1)    
    if c & 0xFF == ord('q'):
        cap.release()
        cv2.destroyAllWindows()
        break  
    if finall_time - start_time > 10:
        cap.release()
        cv2.destroyAllWindows()
        break       

你可能感兴趣的:(Opencv 摄像头水平镜像)