365 lines
1.8 MiB
Plaintext
365 lines
1.8 MiB
Plaintext
|
{
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 0,
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"name": "python3",
|
|||
|
"display_name": "Python 3",
|
|||
|
"language": "python"
|
|||
|
},
|
|||
|
"colab": {
|
|||
|
"name": "building-a-panoramic-view-of-images.ipynb",
|
|||
|
"provenance": [],
|
|||
|
"include_colab_link": true
|
|||
|
}
|
|||
|
},
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {
|
|||
|
"id": "view-in-github",
|
|||
|
"colab_type": "text"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"<a href=\"https://colab.research.google.com/github/PacktPublishing/Hands-On-Computer-Vision-with-PyTorch/blob/master/Chapter18/building_a_panoramic_view_of_images.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
|
|||
|
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
|
|||
|
"trusted": true,
|
|||
|
"id": "h-U2So3mvjXY",
|
|||
|
"outputId": "c529bb58-ec02-4fd7-c616-09ee422357e3",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 625
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"!pip install torch_snippets\n",
|
|||
|
"from torch_snippets import *\n",
|
|||
|
"# feature_extractor = 'orb' \n",
|
|||
|
"# feature_matching = 'bf'"
|
|||
|
],
|
|||
|
"execution_count": 1,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Collecting torch_snippets\n",
|
|||
|
" Downloading https://files.pythonhosted.org/packages/d6/56/1093531de48ccc64410a480def65c386d18c981cfac21e7e3f92c9496352/torch_snippets-0.228-py3-none-any.whl\n",
|
|||
|
"Collecting loguru\n",
|
|||
|
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/6d/48/0a7d5847e3de329f1d0134baf707b689700b53bd3066a5a8cfd94b3c9fc8/loguru-0.5.3-py3-none-any.whl (57kB)\n",
|
|||
|
"\u001b[K |████████████████████████████████| 61kB 2.8MB/s \n",
|
|||
|
"\u001b[?25hRequirement already satisfied: Pillow in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (7.0.0)\n",
|
|||
|
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (3.2.2)\n",
|
|||
|
"Collecting opencv-python-headless\n",
|
|||
|
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/e2/e2/6670da2b12544858657058a5db2f088a18c56d0144bef8d178ad4734b7a3/opencv_python_headless-4.4.0.44-cp36-cp36m-manylinux2014_x86_64.whl (36.7MB)\n",
|
|||
|
"\u001b[K |████████████████████████████████| 36.7MB 1.3MB/s \n",
|
|||
|
"\u001b[?25hRequirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (4.41.1)\n",
|
|||
|
"Requirement already satisfied: dill in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (0.3.2)\n",
|
|||
|
"Requirement already satisfied: pandas in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (1.1.2)\n",
|
|||
|
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torch_snippets) (1.18.5)\n",
|
|||
|
"Collecting aiocontextvars>=0.2.0; python_version < \"3.7\"\n",
|
|||
|
" Downloading https://files.pythonhosted.org/packages/db/c1/7a723e8d988de0a2e623927396e54b6831b68cb80dce468c945b849a9385/aiocontextvars-0.2.2-py2.py3-none-any.whl\n",
|
|||
|
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->torch_snippets) (1.2.0)\n",
|
|||
|
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->torch_snippets) (0.10.0)\n",
|
|||
|
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->torch_snippets) (2.8.1)\n",
|
|||
|
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->torch_snippets) (2.4.7)\n",
|
|||
|
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->torch_snippets) (2018.9)\n",
|
|||
|
"Collecting contextvars==2.4; python_version < \"3.7\"\n",
|
|||
|
" Downloading https://files.pythonhosted.org/packages/83/96/55b82d9f13763be9d672622e1b8106c85acb83edd7cc2fa5bc67cd9877e9/contextvars-2.4.tar.gz\n",
|
|||
|
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from cycler>=0.10->matplotlib->torch_snippets) (1.15.0)\n",
|
|||
|
"Collecting immutables>=0.9\n",
|
|||
|
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/99/e0/ea6fd4697120327d26773b5a84853f897a68e33d3f9376b00a8ff96e4f63/immutables-0.14-cp36-cp36m-manylinux1_x86_64.whl (98kB)\n",
|
|||
|
"\u001b[K |████████████████████████████████| 102kB 10.4MB/s \n",
|
|||
|
"\u001b[?25hBuilding wheels for collected packages: contextvars\n",
|
|||
|
" Building wheel for contextvars (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
|
|||
|
" Created wheel for contextvars: filename=contextvars-2.4-cp36-none-any.whl size=7666 sha256=f8a165c3ac2b22ad80f61738b271ef93036c96cd11af1335186f06598bb97516\n",
|
|||
|
" Stored in directory: /root/.cache/pip/wheels/a5/7d/68/1ebae2668bda2228686e3c1cf16f2c2384cea6e9334ad5f6de\n",
|
|||
|
"Successfully built contextvars\n",
|
|||
|
"Installing collected packages: immutables, contextvars, aiocontextvars, loguru, opencv-python-headless, torch-snippets\n",
|
|||
|
"Successfully installed aiocontextvars-0.2.2 contextvars-2.4 immutables-0.14 loguru-0.5.3 opencv-python-headless-4.4.0.44 torch-snippets-0.228\n"
|
|||
|
],
|
|||
|
"name": "stdout"
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
|
|||
|
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
|
|||
|
"trusted": true,
|
|||
|
"id": "HnNYEe9mvjXb",
|
|||
|
"outputId": "eae81cce-c495-49c2-c528-a5d05ef20e46",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 728
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"!wget https://www.dropbox.com/s/mfg1codtc2rue84/g1.png\n",
|
|||
|
"!wget https://www.dropbox.com/s/4yhui8s1xjndavm/g2.png"
|
|||
|
],
|
|||
|
"execution_count": 2,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"--2020-10-05 17:11:49-- https://www.dropbox.com/s/mfg1codtc2rue84/g1.png\n",
|
|||
|
"Resolving www.dropbox.com (www.dropbox.com)... 162.125.5.1, 2620:100:601d:1::a27d:501\n",
|
|||
|
"Connecting to www.dropbox.com (www.dropbox.com)|162.125.5.1|:443... connected.\n",
|
|||
|
"HTTP request sent, awaiting response... 301 Moved Permanently\n",
|
|||
|
"Location: /s/raw/mfg1codtc2rue84/g1.png [following]\n",
|
|||
|
"--2020-10-05 17:11:49-- https://www.dropbox.com/s/raw/mfg1codtc2rue84/g1.png\n",
|
|||
|
"Reusing existing connection to www.dropbox.com:443.\n",
|
|||
|
"HTTP request sent, awaiting response... 302 Found\n",
|
|||
|
"Location: https://uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com/cd/0/inline/BAtSVe1XsaaYz-dNUT8PucSdjy59J17P0-IX4lxNRncoz7CpXaFnCeJ_3ClhJ_xqjSaE8G_HWaraS8s184p7sjLBHHXf1_83whtDGgIVRo2edKrdQAlEKy5qjMY03HJmeZU/file# [following]\n",
|
|||
|
"--2020-10-05 17:11:49-- https://uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com/cd/0/inline/BAtSVe1XsaaYz-dNUT8PucSdjy59J17P0-IX4lxNRncoz7CpXaFnCeJ_3ClhJ_xqjSaE8G_HWaraS8s184p7sjLBHHXf1_83whtDGgIVRo2edKrdQAlEKy5qjMY03HJmeZU/file\n",
|
|||
|
"Resolving uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com (uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com)... 162.125.9.15, 2620:100:601d:15::a27d:50f\n",
|
|||
|
"Connecting to uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com (uc5ae3b5e6d89a5d1f941a070eb5.dl.dropboxusercontent.com)|162.125.9.15|:443... connected.\n",
|
|||
|
"HTTP request sent, awaiting response... 200 OK\n",
|
|||
|
"Length: 277132 (271K) [image/png]\n",
|
|||
|
"Saving to: ‘g1.png’\n",
|
|||
|
"\n",
|
|||
|
"g1.png 100%[===================>] 270.64K --.-KB/s in 0.07s \n",
|
|||
|
"\n",
|
|||
|
"2020-10-05 17:11:50 (3.86 MB/s) - ‘g1.png’ saved [277132/277132]\n",
|
|||
|
"\n",
|
|||
|
"--2020-10-05 17:11:50-- https://www.dropbox.com/s/4yhui8s1xjndavm/g2.png\n",
|
|||
|
"Resolving www.dropbox.com (www.dropbox.com)... 162.125.5.1, 2620:100:601f:1::a27d:901\n",
|
|||
|
"Connecting to www.dropbox.com (www.dropbox.com)|162.125.5.1|:443... connected.\n",
|
|||
|
"HTTP request sent, awaiting response... 301 Moved Permanently\n",
|
|||
|
"Location: /s/raw/4yhui8s1xjndavm/g2.png [following]\n",
|
|||
|
"--2020-10-05 17:11:50-- https://www.dropbox.com/s/raw/4yhui8s1xjndavm/g2.png\n",
|
|||
|
"Reusing existing connection to www.dropbox.com:443.\n",
|
|||
|
"HTTP request sent, awaiting response... 302 Found\n",
|
|||
|
"Location: https://uc65628330652e93bcd853321184.dl.dropboxusercontent.com/cd/0/inline/BAuCQY7ifx2KBi0o8py2GUxyM83OvafOWPQ3dMQXD9Wn7FYLst90ueZBfgamB3FAxGpwSXkZM1pS-gztpoq7icc8Vg16vSaBkCymRK-48aZJj3-VwhY7sZMuNVXn4EyIcpA/file# [following]\n",
|
|||
|
"--2020-10-05 17:11:51-- https://uc65628330652e93bcd853321184.dl.dropboxusercontent.com/cd/0/inline/BAuCQY7ifx2KBi0o8py2GUxyM83OvafOWPQ3dMQXD9Wn7FYLst90ueZBfgamB3FAxGpwSXkZM1pS-gztpoq7icc8Vg16vSaBkCymRK-48aZJj3-VwhY7sZMuNVXn4EyIcpA/file\n",
|
|||
|
"Resolving uc65628330652e93bcd853321184.dl.dropboxusercontent.com (uc65628330652e93bcd853321184.dl.dropboxusercontent.com)... 162.125.9.15, 2620:100:601d:15::a27d:50f\n",
|
|||
|
"Connecting to uc65628330652e93bcd853321184.dl.dropboxusercontent.com (uc65628330652e93bcd853321184.dl.dropboxusercontent.com)|162.125.9.15|:443... connected.\n",
|
|||
|
"HTTP request sent, awaiting response... 200 OK\n",
|
|||
|
"Length: 330008 (322K) [image/png]\n",
|
|||
|
"Saving to: ‘g2.png’\n",
|
|||
|
"\n",
|
|||
|
"g2.png 100%[===================>] 322.27K --.-KB/s in 0.07s \n",
|
|||
|
"\n",
|
|||
|
"2020-10-05 17:11:53 (4.47 MB/s) - ‘g2.png’ saved [330008/330008]\n",
|
|||
|
"\n"
|
|||
|
],
|
|||
|
"name": "stdout"
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a",
|
|||
|
"_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0",
|
|||
|
"trusted": true,
|
|||
|
"id": "D1oKuroRvjXe",
|
|||
|
"outputId": "36d8b4fe-0028-4b23-bff4-9161289eaf62",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 211
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"queryImg = read('g1.png', 1)\n",
|
|||
|
"queryImg_gray = read('g1.png')\n",
|
|||
|
"\n",
|
|||
|
"trainImg = read('g2.png', 1)\n",
|
|||
|
"trainImg_gray = read('g2.png')\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"subplots([trainImg, queryImg], nc=2, figsize=(10,5), titles = ['Query image','Training image (Image to be stitched to Query image)'])"
|
|||
|
],
|
|||
|
"execution_count": 3,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"2020-10-05 17:11:53.215 | INFO | torch_snippets.loader:subplots:339 - plotting 2 images in a grid of 1x2 @ (10, 5)\n"
|
|||
|
],
|
|||
|
"name": "stderr"
|
|||
|
},
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAq0AAACwCAYAAAAli1fHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy9ebwtS1bX+V2ZezrzHd547xt5VfUeNUAVY4PQ8GlRKYTGRoVGRJSZz4fBbj4KTdMKUgLaoKBYgGgzCCg4oILggAgFxSQyFEVVvao33vfufO+590x7zMzoPyIic0Vk5j773KHuffX2+nzOyZ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eOci/N3gH5LXj8LPCUip26WaWPMe4Dvxm7Uuohd7/pOFeWHsMD0XVjP+M9jPVO5C/9LQA9b5mvYdYlN08xQbfS5KiK/635/PnZN7jngZ7BrBX9xDss/iR3wbAMfjdvIc0QZJtjNU+dcOp8C+APifwn4I+CCiNSmxY0x78PW3XNuuvgUdlPbT2PltAv8U2xbn0vGmJ9xPP4LN239buwUOcaYK1jP53di2+5rCeslppuSrTHm17AbxD4H613fxm5I+uPGmHe7OO8H/hbwi9h11b8WJfMNwDPAb7ry/CJ2dmWeDEbY9aiPY8Hj7aDb1jfFblh8PRZ8zyVxC2CX9CogEfl64K9jO9F/xa7LeTt2R/AnGWNmtzi/zoLTXUta0pJeQSQiP4U94/S2e3oP4ePvYDeW3dCXvUTky4HXG2P+6q3l7NB83wr8gDHm0UMjL+kVS84z+9+Av+CWUtzOvP4G8DpjzF88NPIHgY7SN0Xku4FnjTFvPyzu0tP6KiER2cQew
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 720x360 with 2 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"tags": [],
|
|||
|
"needs_background": "light"
|
|||
|
}
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"trusted": true,
|
|||
|
"id": "Rg0WWkqJvjXg",
|
|||
|
"outputId": "a44bee5e-708e-496d-c148-24082e094af9",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 227
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"# Fetch the keypoints and features corresponding to the images\n",
|
|||
|
"descriptor = cv2.ORB_create()\n",
|
|||
|
"kpsA, featuresA = descriptor.detectAndCompute(trainImg_gray, None)\n",
|
|||
|
"kpsB, featuresB = descriptor.detectAndCompute(queryImg_gray, None)\n",
|
|||
|
"\n",
|
|||
|
"# Draw the keypoints obtained on images\n",
|
|||
|
"img_kpsA = cv2.drawKeypoints(trainImg_gray,kpsA,None,color=(0,255,0))\n",
|
|||
|
"img_kpsB = cv2.drawKeypoints(queryImg_gray,kpsB,None,color=(0,255,0))\n",
|
|||
|
"subplots([img_kpsB, img_kpsA], nc=2, figsize=(10,5), titles=['Query image with keypoints','Training image with keypoints'])"
|
|||
|
],
|
|||
|
"execution_count": 4,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"2020-10-05 17:11:53.638 | INFO | torch_snippets.loader:subplots:339 - plotting 2 images in a grid of 1x2 @ (10, 5)\n"
|
|||
|
],
|
|||
|
"name": "stderr"
|
|||
|
},
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAsgAAADBCAYAAADSO0aXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nOy9aZRk2VUe+u2Y54ycs7Kyhq6hu6qlKvVgSQ3IYpIlJOSHmc1kJjF4LYGxgcVbYIOEQcZ+gGUQfvbDWAIEYhQYhJERaJZac7fUg7q75qqcIyMyMub5vB839qkTt+6599zIyKpS9/3WqpUV95575uHb++yzDwkhECBAgAABAgQIECBAAAuhO52BAAECBAgQIECAAAHuJgQEOUCAAAECBAgQIEAABQFBDhAgQIAAAQIECBBAQUCQAwQIECBAgAABAgRQEBDkAAECBAgQIECAAAEUBAQ5QIAAAQIECBAgQAAFAUEOoAUR/SwR/Y87nY9JgIiOElGNiMIuYQQRnTKM701E9M7J5XB/eD61VYAAAQIECHCnERDkOwwi+j4ieoKIGkS0SUT/lYim7nS+AEAI8RYhxBvudD4mASHEdSFERgjRBwAi+iARPS/KBvhrq7uN3AcIECBAgAB3GwKCfAdBRD8J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fpxgD8FDxARD8P6wzLVwohVgH8yrB+HgBwCparzJ8fBv89DP3UD/E6ABtCiMeUZ18Nq95eDeBniOhVw+c/B8v15wOwfM6/DMC/dcnatwH4OgD3wKqX7xuePXotgPVh2TNCiHVYZ2b+y9Aj1ElYh/kDHDACghwgQIAAAV7oGMA69NoeXq5TFEL8uRCiMdzp+WXcvOjICdeEE
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 720x360 with 2 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"tags": [],
|
|||
|
"needs_background": "light"
|
|||
|
}
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"trusted": true,
|
|||
|
"id": "KPrCD8JNvjXj"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"bf = cv2.BFMatcher(cv2.NORM_HAMMING)\n",
|
|||
|
"best_matches = bf.match(featuresA,featuresB)\n",
|
|||
|
"matches = sorted(best_matches, key = lambda x:x.distance)"
|
|||
|
],
|
|||
|
"execution_count": 5,
|
|||
|
"outputs": []
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"trusted": true,
|
|||
|
"id": "yWuBz2BFvjXl",
|
|||
|
"outputId": "d1cedcf0-bcaa-43cc-c89b-d79a0ca4450e",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 280
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"img3 = cv2.drawMatches(trainImg,kpsA,queryImg,kpsB,matches[:100], None,flags=cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)\n",
|
|||
|
"show(img3)"
|
|||
|
],
|
|||
|
"execution_count": 6,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABGoAAAE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pql0/sxI/90t2nKJjGh3DqP5ywrnGVnY2VihAz/fGPzUyb7r4lNsoFSzW68FQdeYm4tj+pJzdUMejo4SvyGYXJbN2Iczxdvl4vELAOOY80dfN6hCHUYkPuF2Yi5mc8YzkIVTVhWbYOK4UPcBjPM/L9Mx2MbWIb1bmASKGkbazBGIyj1F0GvZYBFsnMXcGpum36ooYlt9TsrcETMcJu/0eBCBsNmnRhmDS4uUxhS1WPGjFTxze+DexO9+vCzng43N1e5RX+7B6XaNtn7flnhgsTs13BU8XSOrlY+Yufd7GYMW3zcpmj2+uzJ+ombluRHrtgMJYKRxxiFPit699GKm/Ns3+qiJ1vzU7UhjdP4MorVr5Q5AI5LVNF9BWQntDQl1dRme9UzCPvdyRLmOufc/pWdyuMgkl6S2r0ETZLHs4BwIuZG4RrzlFiedi9VvJrT8eDVrWN9V5XUAzn8sBb3k7bZpHMreEzofCQIqWkWyuwa/4Qobck2CfwVsAZf6X2L+qdYaY6s61vfB2WPi9KaOL7eaJshk8mM+TWZwapmVgMc75OVkFgyyjOXHr6Xn+oWHqJMHj4AT4Q/LWAs3ctcazhpZF9bTOxB+e756c6tp9LCAuGqOiVX+OocZ17GU8Mpioz8YQOzzJ1vF0iA9E2lB/zpbDeh7WP91LGha0QxmO3f9y/698RWerbRw6HhCuaOFUFrwleRkM1cA5sFdx2NBv5+AXqBkOLVPl3hUbDhiJTU/MLF12s+V+Qi4aNLiWMRErDHGO6LKv+/7mfJs+aWS34/xui0jGQkHGKZsRg9mDGOcyB
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1440x1440 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"tags": [],
|
|||
|
"needs_background": "light"
|
|||
|
}
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"trusted": true,
|
|||
|
"id": "2HQFribjvjXn"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"kpsA = np.float32([kp.pt for kp in kpsA])\n",
|
|||
|
"kpsB = np.float32([kp.pt for kp in kpsB])\n",
|
|||
|
"ptsA = np.float32([kpsA[m.queryIdx] for m in matches])\n",
|
|||
|
"ptsB = np.float32([kpsB[m.trainIdx] for m in matches])\n",
|
|||
|
"\n",
|
|||
|
"(H, status) = cv2.findHomography(ptsA, ptsB, cv2.RANSAC,4)"
|
|||
|
],
|
|||
|
"execution_count": 7,
|
|||
|
"outputs": []
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"trusted": true,
|
|||
|
"id": "U2Ly0WjVvjXq",
|
|||
|
"outputId": "82c35d79-5426-4bd1-ea96-9156200532bf",
|
|||
|
"colab": {
|
|||
|
"base_uri": "https://localhost:8080/",
|
|||
|
"height": 372
|
|||
|
}
|
|||
|
},
|
|||
|
"source": [
|
|||
|
"width = trainImg.shape[1] + queryImg.shape[1]\n",
|
|||
|
"height = trainImg.shape[0] + queryImg.shape[0]\n",
|
|||
|
"\n",
|
|||
|
"result = cv2.warpPerspective(trainImg, H, (width, height))\n",
|
|||
|
"result[0:queryImg.shape[0], 0:queryImg.shape[1]] = queryImg\n",
|
|||
|
"\n",
|
|||
|
"_x = np.nonzero(result.sum(0).sum(-1) == 0)[0][0]\n",
|
|||
|
"_y = np.nonzero(result.sum(1).sum(-1) == 0)[0][0]\n",
|
|||
|
"\n",
|
|||
|
"show(result[:_y,:_x])"
|
|||
|
],
|
|||
|
"execution_count": 8,
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"output_type": "display_data",
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABGoAAAFjCAYAAABlgO1pAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAA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t5jrs3nSFboFYK9oRVCgMN0XL2+7t5Rk4lnDvSxoHy8J/j1jCRKlbBKH6osIKVlP/PeUJDuOXlRDRCCKqfrtU/QWHzxaWGf9llPq19vhJb1PZh9HBkPtx4CwOKPN93dbNnJEdXJzUlcr56Ju1D0NKvbkpd+BIoTU+Ws5OTAmFm4VeMocOOqiragR4A5YtvIKr5MMna/V8nL4ZvLECAvWuMnSmsyefBxuR7/PoqzzC8fNNR9FH2Kux5e18cmQ6Uly4Iqw363UCOdHNQTGfSgocBj9h7UeFu0dh3ItbTKVxIsbaFFxxCxBFHLMsPpfIbzOV5eeTgc4ObmBoCuQnv0HeAmwJ7vXrKmlcDJp2gDLAJHx3EQjLijb2uRVLPsPSjcsO1Yo3MN/cKECwYPFl9QFhOX+hg7FllLy4wppWwsWZjyoijBF8gj+jvDBQTNxcFAnGU1vGEta7VwKYGd27f82Gjdkd+99ghG2YEROmNg3Tj6LCPQi+tY34YVsN0kAISVi9/daMmDATvx4YE65Wjabz7fEVIM18FVW8pj1EwfQdtbC+fZabN90T/qY1rt9fuHjf7ZfFlrtfUvC4jxRLSRur0thyD6lwkXZ
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1440x1440 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {
|
|||
|
"tags": [],
|
|||
|
"needs_background": "light"
|
|||
|
}
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"metadata": {
|
|||
|
"id": "nNFkhfnLvzNg"
|
|||
|
},
|
|||
|
"source": [
|
|||
|
""
|
|||
|
],
|
|||
|
"execution_count": null,
|
|||
|
"outputs": []
|
|||
|
}
|
|||
|
]
|
|||
|
}
|