From df33340ecc4f53d3a2657d08dc3aac1bd00feff8 Mon Sep 17 00:00:00 2001 From: pbiskup Date: Mon, 29 Nov 2021 18:02:09 +0100 Subject: [PATCH] create transformed img --- lab5/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lab5/main.py b/lab5/main.py index 239be86..4594074 100644 --- a/lab5/main.py +++ b/lab5/main.py @@ -13,10 +13,11 @@ def click_event(event, x, y, flags, params): def add_img_in_area(): - # src_points = np.array([[0, 0], [bakery_w - 1, 0], [bakery_w - 1, bakery_h - 1], [0, bakery_h - 1]], dtype=float) dst_points = np.array(vertexes, dtype=float) - - + src_points = np.array([[0, 0], [bakery_w, 0], [bakery_w, bakery_h], [0, bakery_h]], dtype=float) + mat_h = cv.findHomography(src_points, dst_points)[0] + image_transformed_h = cv.warpPerspective(bakery, mat_h, (img_w, img_h)) + cv.imshow('image', image_transformed_h) vertexes.clear() @@ -25,6 +26,7 @@ if __name__ == '__main__': img = cv.imread('../img/billboards.jpg') bakery = cv.imread('../img/bakery.jpg') bakery_h, bakery_w = bakery.shape[0:2] + img_h, img_w = img.shape[0:2] cv.imshow('image', img) cv.setMouseCallback('image', click_event) cv.waitKey(0)