Exemple #1
0

def nothing(x):
    pass


source_path = sys.argv[1]  # =Path to the input file
video = int(sys.argv[2])  # =True if the file is video file
flag = int(sys.argv[3])  # =0 for equirectangular image,
# =1 for fisheye image, =2 for horizontaly placed fisheye image

WINDOW_NAME = "360 Viewer"
param_file_path = "../fisheyeParams.txt"

if flag == 0:
    mapper = fisheyeImgConv()
else:
    mapper = fisheyeImgConv(param_file_path)

cv2.namedWindow(WINDOW_NAME)

cv2.createTrackbar("FOV", WINDOW_NAME, 90, 150, nothing)
cv2.createTrackbar("theta", WINDOW_NAME, 180, 360, nothing)
cv2.createTrackbar("phi", WINDOW_NAME, 180, 360, nothing)

if video:
    cap = cv2.VideoCapture(source_path)
    ret, img = cap.read()
    cv2.imshow("input image", img)
    cv2.waitKey(1)
else:
cv2.resizeWindow(WINDOW_NAME, 600, 1200)
cv2.createTrackbar('aperture', WINDOW_NAME, 0, 1000, nothing)
cv2.createTrackbar('del Cx', WINDOW_NAME, 500, 1000, nothing)
cv2.createTrackbar('del Cy', WINDOW_NAME, 500, 1000, nothing)

# Example of using the converter class
frame = cv2.imread(Image_Path)
frame = cv2.circle(frame, (frame.shape[1] // 2, frame.shape[0] // 2), 4,
                   (255, 255, 255), -1)
frame = cv2.circle(frame, (frame.shape[1] // 2, frame.shape[0] // 2), 2,
                   (0, 0, 0), -1)

outShape = [400, 800]
inShape = frame.shape[:2]

mapper = fisheyeImgConv()
mapper.fisheye2equirect(frame, outShape, edit_mode=True)
while True:
    if True:
        aperture = cv2.getTrackbarPos('aperture', WINDOW_NAME)
        delx = cv2.getTrackbarPos('del Cx', WINDOW_NAME) - 500
        dely = cv2.getTrackbarPos('del Cy', WINDOW_NAME) - 500
        frame2 = mapper.fisheye2equirect(frame,
                                         outShape,
                                         aperture=aperture,
                                         delx=delx,
                                         dely=dely,
                                         radius=RADIUS,
                                         edit_mode=True)
        frame2 = cv2.line(frame2, (int(frame2.shape[1] * 0.25), 0),
                          (int(frame2.shape[1] * 0.25), int(frame2.shape[0])),