使用cv2时如何“镜像”实时网络摄像头视频?

时间:2019-06-06 09:05:49

标签: python cv2

我想有两种不同的网络摄像头视频输出,一种是普通的网络摄像头素材,另一种是其“镜像”版本。 cv2有可能吗?

 stripe.paymentIntents.capture(session.payment_intent)

2 个答案:

答案 0 :(得分:1)

简而言之,是的,可以使用cv2。我已经对您的代码进行了一些修改以使其实现。

# Loading modules
import cv2
import numpy as np     # Numpy module will be used for horizontal stacking of two frames

video=cv2.VideoCapture(0)
a=0
while True:
    a=a+1
    check, frame= video.read()

    # Converting the input frame to grayscale
    gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)   

    # Fliping the image as said in question
    gray_flip = cv2.flip(gray,1)

    # Combining the two different image frames in one window
    combined_window = np.hstack([gray,gray_flip])

    # Displaying the single window
    cv2.imshow("Combined videos ",combined_window)
    key=cv2.waitKey(1)

    if key==ord('q'):
        break
print(a)

video.release()
cv2.destroyAllWindows

希望您能找到想要的东西:)

答案 1 :(得分:1)

获取镜像:

flip_img = cv2.flip(img,1)