Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Adding a feature matching program. #250

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Coding/Python/Color filtering, hue.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np \n",
"import cv2"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"cap=cv2.VideoCapture(0)\n",
"while True:\n",
" _, frame=cap.read()\n",
" hsv=cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)\n",
" lower_red=np.array([150,150,150])\n",
" upper_red=np.array([180,255,255])\n",
" mask=cv2.inRange(hsv,lower_red, upper_red)\n",
" res=cv2.bitwise_and(frame, frame, mask=mask)\n",
" kernel=np.ones((15,15), np.float32)/255\n",
" median=cv2.medianBlur(res,15)\n",
" bilateral=cv2.bilateralFilter(res, 15, 15 , 75)\n",
" cv2.imshow('frame',frame)\n",
" #cv2.imshow('mask',mask)\n",
" cv2.imshow('res',res)\n",
" if cv2.waitKey(5) & 0xFF==ord('q'):\n",
" break\n",
"cv2.destroyAllWindows()\n",
"cap.release()"
]
}
],
"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.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
80 changes: 80 additions & 0 deletions Coding/Python/Feature matching.ipynb

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions Coding/Python/Template matching.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<function destroyAllWindows>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import cv2\n",
"import numpy as np\n",
"\n",
"img_rgb = cv2.imread('temp.jpg')\n",
"img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)\n",
"\n",
"template = cv2.imread('1.jpg',0)\n",
"w, h = template.shape[::-1]\n",
"res = cv2.matchTemplate(img_gray,template,cv2.TM_CCOEFF_NORMED)\n",
"threshold = 1.0\n",
"loc = np.where( res >= threshold)\n",
"for pt in zip(*loc[::-1]):\n",
" cv2.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,255,255), 2)\n",
"\n",
"cv2.imshow('Detected',img_rgb)\n",
"cv2.waitKey()\n",
"cv2.destroyAllWindows"
]
}
],
"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.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}