Got it to work!! it is streaming and correcting in realtime. Let me play around with the code a little.
I can even create a panorama from perspective corrected images.
import cv2
import os
import Equirec2Perspec2 as E2P
import numpy as np
print(f"OpenCV version {cv2.__version__}")
cap = cv2.VideoCapture(1)
# Check if the webcam is opened correctly
if not cap.isOpened():
raise IOError("Cannot open webcam")
while True:
ret, frame = cap.read()
#print(frame.shape)
equ = E2P.Equirectangular(frame)
frame1 = equ.GetPerspective(90, 0, 0, 400, 400)
frame2 = equ.GetPerspective(90, 90, 0, 400, 400)
frame3 = equ.GetPerspective(90, 180, 0, 400, 400)
frame4 = equ.GetPerspective(90, 270, 0, 400, 400)
hor_concat_top = np.concatenate((frame1, frame2), axis=1)
hor_concat_bottom = np.concatenate((frame3, frame4), axis=1)
all_four_frames = np.concatenate((hor_concat_top, hor_concat_bottom), axis=1)
cv2.imshow('Input', all_four_frames)
c = cv2.waitKey(1)
if c == 27:
break
cap.release()
cv2.destroyAllWindows()
-Jaap