|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [ |
| 8 | + { |
| 9 | + "name": "stderr", |
| 10 | + "output_type": "stream", |
| 11 | + "text": [ |
| 12 | + "E:\\Anaconda\\envs\\djangoProject\\lib\\site-packages\\numpy\\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs:\n", |
| 13 | + "E:\\Anaconda\\envs\\djangoProject\\lib\\site-packages\\numpy\\.libs\\libopenblas.NOIJJG62EMASZI6NYURL6JBKM4EVBGM7.gfortran-win_amd64.dll\n", |
| 14 | + "E:\\Anaconda\\envs\\djangoProject\\lib\\site-packages\\numpy\\.libs\\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll\n", |
| 15 | + " stacklevel=1)\n" |
| 16 | + ] |
| 17 | + } |
| 18 | + ], |
| 19 | + "source": [ |
| 20 | + "# Feature detection and description\n", |
| 21 | + "import numpy as np\n", |
| 22 | + "import cv2 as cv\n", |
| 23 | + "\n", |
| 24 | + "# load the image using cv2.imread function in grayscale\n", |
| 25 | + "img = cv.imread(\"D:/Wallpapers/1.jpeg\",cv.IMREAD_GRAYSCALE)\n", |
| 26 | + "\n", |
| 27 | + "#create ORB object\n", |
| 28 | + "orb = cv.ORB_create(nfeatures=1500)\n", |
| 29 | + "\n", |
| 30 | + "# detecting the feature\n", |
| 31 | + "keypoints, descriptors = orb.detectAndCompute(img, None)\n", |
| 32 | + "\n", |
| 33 | + "# it will draw the Keypoints that detect using ORB\n", |
| 34 | + "img = cv.drawKeypoints(img, keypoints, None)\n", |
| 35 | + "\n", |
| 36 | + "#show the image as output\n", |
| 37 | + "cv.imshow(\"Image\", img)\n", |
| 38 | + "cv.waitKey(0)\n", |
| 39 | + "cv.destroyAllWindows()" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "code", |
| 44 | + "execution_count": 2, |
| 45 | + "metadata": {}, |
| 46 | + "outputs": [], |
| 47 | + "source": [ |
| 48 | + "# Feature detection , description and Matching using Brout-Force matching method\n", |
| 49 | + "import cv2 as cv\n", |
| 50 | + "import numpy as np\n", |
| 51 | + "\n", |
| 52 | + "img1 = cv.imread(\"D:/Wallpapers/1.jpeg\",cv.IMREAD_GRAYSCALE)\n", |
| 53 | + "img2 = cv.imread(\"D:/Wallpapers/2.jpeg\",cv.IMREAD_GRAYSCALE)\n", |
| 54 | + "\n", |
| 55 | + "# ORB Detector\n", |
| 56 | + "orb = cv.ORB_create()\n", |
| 57 | + "kp1, des1 = orb.detectAndCompute(img1, None)\n", |
| 58 | + "kp2, des2 = orb.detectAndCompute(img2, None)\n", |
| 59 | + "\n", |
| 60 | + "#Brute Force Matching\n", |
| 61 | + "bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck = True)\n", |
| 62 | + "matches = bf.match(des1,des2)\n", |
| 63 | + "matches = sorted(matches,key = lambda x:x.distance)\n", |
| 64 | + "\n", |
| 65 | + "# Draw the macthing features\n", |
| 66 | + "matchesing_result = cv.drawMatches(img1, kp1, img2, kp2, matches[:50], None,flags=2)\n", |
| 67 | + "\n", |
| 68 | + "# Display the Output\n", |
| 69 | + "cv.imshow(\"Img1\",img1)\n", |
| 70 | + "cv.imshow(\"Img2\",img2)\n", |
| 71 | + "cv.imshow(\"Result\",matchesing_result)\n", |
| 72 | + "cv.waitKey(0)\n", |
| 73 | + "cv.destroyAllWindows()" |
| 74 | + ] |
| 75 | + }, |
| 76 | + { |
| 77 | + "cell_type": "code", |
| 78 | + "execution_count": null, |
| 79 | + "metadata": {}, |
| 80 | + "outputs": [], |
| 81 | + "source": [] |
| 82 | + } |
| 83 | + ], |
| 84 | + "metadata": { |
| 85 | + "kernelspec": { |
| 86 | + "display_name": "Python 3.7.6 64-bit ('djangoProject': conda)", |
| 87 | + "language": "python", |
| 88 | + "name": "python37664bitdjangoprojectconda6b36c2a086f74a4487d0008552a080c8" |
| 89 | + }, |
| 90 | + "language_info": { |
| 91 | + "codemirror_mode": { |
| 92 | + "name": "ipython", |
| 93 | + "version": 3 |
| 94 | + }, |
| 95 | + "file_extension": ".py", |
| 96 | + "mimetype": "text/x-python", |
| 97 | + "name": "python", |
| 98 | + "nbconvert_exporter": "python", |
| 99 | + "pygments_lexer": "ipython3", |
| 100 | + "version": "3.7.6" |
| 101 | + } |
| 102 | + }, |
| 103 | + "nbformat": 4, |
| 104 | + "nbformat_minor": 4 |
| 105 | +} |
0 commit comments