diff --git a/lab5.ipynb b/lab5.ipynb deleted file mode 100644 index 282bb17..0000000 --- a/lab5.ipynb +++ /dev/null @@ -1,77 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "a484c0ac", - "metadata": {}, - "outputs": [], - "source": [ - "import cv2 as cv" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "733098ae", - "metadata": {}, - "outputs": [], - "source": [ - "img = cv.imread('img/billboards.jpg')" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "22fc2441", - "metadata": {}, - "outputs": [], - "source": [ - "def click_event(event, x, y, flags, params):\n", - " \n", - " if event == cv2.EVENT_LBUTTONDOWN:\n", - " \n", - " # displaying the coordinates\n", - " # on the Shell\n", - " print(x, ' ', y)\n", - " \n", - " # displaying the coordinates\n", - " # on the image window\n", - " font = cv2.FONT_HERSHEY_SIMPLEX\n", - " cv2.putText(img, str(x) + ',' +\n", - " str(y), (x,y), font,\n", - " 1, (255, 0, 0), 2)\n", - " cv2.imshow('image', img)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "49972565", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.8" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/lab5/.idea/.gitignore b/lab5/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/lab5/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/lab5/.idea/inspectionProfiles/Project_Default.xml b/lab5/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..579ee6c --- /dev/null +++ b/lab5/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/lab5/.idea/inspectionProfiles/profiles_settings.xml b/lab5/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/lab5/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/lab5/.idea/lab5.iml b/lab5/.idea/lab5.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/lab5/.idea/lab5.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/lab5/.idea/misc.xml b/lab5/.idea/misc.xml new file mode 100644 index 0000000..08c1c41 --- /dev/null +++ b/lab5/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lab5/.idea/modules.xml b/lab5/.idea/modules.xml new file mode 100644 index 0000000..1423290 --- /dev/null +++ b/lab5/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lab5/.idea/vcs.xml b/lab5/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/lab5/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab5/main.py b/lab5/main.py new file mode 100644 index 0000000..239be86 --- /dev/null +++ b/lab5/main.py @@ -0,0 +1,31 @@ +import cv2 as cv +import numpy as np + + +def click_event(event, x, y, flags, params): + if event == cv.EVENT_LBUTTONDOWN: + # print(x, ' ', y) + cv.circle(img, (int(x), int(y)), 10, [0, 255, 255], -1) + cv.imshow('image', img) + vertexes.append([x, y]) + if len(vertexes) == 4: + add_img_in_area() + + +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) + + + vertexes.clear() + + +if __name__ == '__main__': + vertexes = [] + img = cv.imread('../img/billboards.jpg') + bakery = cv.imread('../img/bakery.jpg') + bakery_h, bakery_w = bakery.shape[0:2] + cv.imshow('image', img) + cv.setMouseCallback('image', click_event) + cv.waitKey(0) + cv.destroyAllWindows()