Yes of course I understand, it will be easier with the code 
Here it is:
import cv2
import argparse
import numpy as np
import picamera
import picamera.array
import time
#------------------ GLOBALS---------------------------
# define image to be wrapped in real time
im_src = cv2.imread("image.png")
# load the aruco dictionary
dictionary = cv2.aruco.Dictionary_get(cv2.aruco.DICT_4X4_250)
# initialize detector params
parameters = cv2.aruco.DetectorParameters_create()
# marker corners coordinates on paper (real world)
realWorldMarkerCorners = np.float32([ [0, 0], [30, 0], [30, 30], [0, 30], \
[125, 40], [155, 40], [155, 70], [125, 70] ])
# frame corners coordinates on paper (real world)
realWorldFrameBoardCorners = np.float32([[-2, 34], [158, 42], [158, 84], [-2, 92]])
#------------------ FUNCTIONS---------------------------
def process_frame(frame, img_to_process):
"""Detect markers and wrap"""
global realWorldMarkerCorners
global realWorldFrameBoardCorners
try:
# detect the markers in the image
markerCorners, markerIds, rejectedCandidates = cv2.aruco.detectMarkers(frame, dictionary, parameters=parameters)
imageMarkerCorners = np.asarray(markerCorners)
# tips from crackwitz (ocv forum)
realWorldMarkerCorners.shape = (-1, 1, 2)
realWorldFrameBoardCorners.shape = (-1, 1, 2)
# marker with Id 85
index1 = np.squeeze(np.where(markerIds==85))
# marker with Id 10
index2 = np.squeeze(np.where(markerIds==10))
Marker85_UpperLeft_Point = np.squeeze(markerCorners[index1[0]])[0]
Marker85_UpperRight_Point = np.squeeze(markerCorners[index1[0]])[1]
Marker85_LowerRight_Point = np.squeeze(markerCorners[index1[0]])[2]
Marker85_LowerLeft_Point = np.squeeze(markerCorners[index1[0]])[3]
Marker10_UpperLeft_Point = np.squeeze(markerCorners[index2[0]])[0]
Marker10_UpperRight_Point = np.squeeze(markerCorners[index2[0]])[1]
Marker10_LowerRight_Point = np.squeeze(markerCorners[index2[0]])[2]
Marker10_LowerLeft_Point = np.squeeze(markerCorners[index2[0]])[3]
# dest points
pts_dst = [Marker85_UpperLeft_Point] + [Marker85_UpperRight_Point] + [Marker85_LowerRight_Point] + [Marker85_LowerLeft_Point] \
+ [Marker10_UpperLeft_Point] + [Marker10_UpperRight_Point] + [Marker10_LowerRight_Point] + [Marker10_LowerLeft_Point]
pts_dst_m = np.asarray(pts_dst)
# 1st homography : get matrix1 for “real world markers” to “image markers”
matrix1, status = cv2.findHomography(realWorldMarkerCorners, pts_dst_m)
# get the projection of “my real world frame" to “image world frame"
imagePointsABCD = cv2.perspectiveTransform(realWorldFrameBoardCorners, matrix1)
# source points
pts_src = [[0,0], [img_to_process.shape[1], 0], [img_to_process.shape[1], img_to_process.shape[0]], [0, img_to_process.shape[0]]]
pts_src_m = np.asarray(pts_src)
# 2nd homography : get matrix2 for “my picture to project” to “image world frame"
matrix2, status = cv2.findHomography(pts_src_m, np.asarray(imagePointsABCD))
# warp source image to destination based on homography
warped_image = cv2.warpPerspective(im_src, matrix2, (frame.shape[1],frame.shape[0]))
# return the processed image
return warped_image
except Exception as inst:
print(inst)
return None
def take_picture(cam):
"""
Returns an openCV compatible colour image
"""
with picamera.array.PiRGBArray(cam) as stream:
cam.capture(stream, format="rgb", use_video_port=True)
return stream.array
def execute(flip=1):
camera = picamera.PiCamera()
camera.framerate = 30
if (flip == 1):
camera.hflip = True
# gives camera warm-up time
time.sleep(2)
camera.start_preview()
frame = take_picture(camera)
ovr = camera.add_overlay(frame, format="rgb", layer=3, alpha=64)
if (flip == 1):
ovr.hflip = True
try:
while True:
frame = take_picture(camera)
frame_out = process_frame(frame, im_src)
if (frame_out is not None):
ovr.update(frame_out)
except Exception as e:
print(e)
pass
#------------------ MAIN---------------------------
def main():
# ---- ARGS parsing -----------
ap = argparse.ArgumentParser(description='AR frame projection test')
ap.add_argument("--flip", "-f", default=1,
help="Flip both preview and overlay")
args = vars(ap.parse_args())
if (
isinstance(args["flip"], str)
and args["flip"].isdigit()
):
args["flip"] = int(args["flip"])
#-------------------------
execute(args["flip"])
if __name__ == "__main__":
main()