656 lines
3.5 MiB
Plaintext
656 lines
3.5 MiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Лаба 10"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": null,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAGiCAYAAAAsv5dDAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9d5Rc2X3fi35OqJy6q3M30EAjpwEwETPDKEYNRYkSeWWJlhwoXzlci/YTn5/v1ZMlmusumZatZcuSScnPliX5mlSkSJqkGMRhmjyYAAxy6pyru3I+Vee8P6p+B7sPqhvADDADDPu3Vq3uqjp1zj777P3dv/39Jc1xHIdN2ZRN2ZRNuStEf6MbsCmbsimbsik3LpugvSmbsimbchfJJmhvyqZsyqbcRbIJ2puyKZuyKXeRbIL2pmzKpmzKXSSboL0pm7Ipm3IXySZob8qmbMqm3EWyCdqbsimbsil3kWyC9qZsyqZsyl0km6C9KZuyKZtyF8kbCtqf+cxn2L59O8FgkGPHjvH888+/kc3ZlE3ZlE254+UNA+0/+7M/4xOf+ASf/OQneemllzhy5Ajvf//7WV5efqOatCmbsimbcseL9kYljDp27BgPPvgg//k//2cAbNtm69atfPzjH+f/+r/+rzeiSZuyKZuyKXe8mG/ERev1Oi+++CK/8iu/4n6m6zrvec97eOaZZ645vlarUavV3Pe2bZNOp+np6UHTtNelzZuyKZuyKTcrjuNQKBQYHh5G128NsfGGgPbKygrNZpOBgYE1nw8MDHD+/Plrjv/0pz/Npz71qdereZuyKZuyKbdUZmZm2LJlyy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es>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/coins.jpg', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"sift = cv.SIFT_create()\n",
|
|||
|
"\n",
|
|||
|
"kp, des = sift.detectAndCompute(img, None)\n",
|
|||
|
"\n",
|
|||
|
"img2 = cv.drawKeypoints(img, kp, None, (255, 0, 0), 4)\n",
|
|||
|
"plt.imshow(img2)\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 3,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9d6wk+XXf+6ncOd0cJ+eZTbOZyyhSFClRFEnLVhZkPQs2LAE2YRgWYEuWYUB4fg/PenKAANvPlGwFi5IlkQRFUVwxLLmzaXZ3ZnfinXDn5tw5VH5/VFdv3ZrqOzMbRF5ufYFGd1dXV/1Sne8553d+5ye4rusSI0aMGDFi7BKI3+0CxIgRI0aMGPeCmLhixIgRI8auQkxcMWLEiBFjVyEmrhgxYsSIsasQE1eMGDFixNhViIkrRowYMWLsKsTEFSNGjBgxdhVi4ooRI0aMGLsKMXHFiBEjRoxdhZi4YsSIESPGrsJ3jbj+03/6T+zdu5dEIsFjjz3GCy+88N0qSowYMWLE2EX4rhDX//pf/4vPfvaz/Pqv/zov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6pGdZCM0muRdewJmdxbYs9PvvR5icRNA0pMFB1NVVhM1NxBdeQDh6FFeSQFXvqiwx3n2IiSvGXSEYIBDUqAVBQKhWkV56CfW3fxthbc07ZlnYH/oQ1sc+hv3hD+N2J96jsJPwj/ocnlfa0Qp8k2R3J1feTvcOz8/cjSsv6j/+nOK2l20jttswN4cjSTgjI9ipFLbr4nQJQt7cRGy1sKamsBMJXFnuW75
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9d5Ak2X3f+Ulfvqq97/F2Z+1gLRYLgFoABEgQIng8QSJ5DIpH3jEkRUgIhUKIkIPuIninU5x4lKjQ/SEJ5NGCVgRFwhLALoG1s7uzOzM73rSb9tXlq9K9+yMza7Kzs7p71gBobn4jKqoq7XsvX/78+/0kIYQgQYIECRIk2COQv98NSJAgQYIECe4GCeNKkCBBggR7CgnjSpAgQYIEewoJ40qQIEGCBHsKCeNKkCBBggR7CgnjSpAgQYIEewoJ40qQIEGCBHsKCeNKkCBBggR7CgnjSpAgQYIEewoJ40qQIEGCBHsK3zfG9Wu/9mvs37+fVCrFo48+yosvvvj9akqCBAkSJNhD+L4wrt/7vd/js5/9LP/yX/5LXnnlFe6//34+9rGPsby8/P1oToIECRIk2EOQvh9Jdh999FEefvhh/sN/+A8AuK7L1NQU/+Af/AP+6T/9p9/r5iRIkCBBgj0E9Xt9Q9M0OXPmDJ/73Oe622RZ5umnn+a5556LPafT6dDpdLr/XddlfX2dgYE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aRGg8KLL+LevIlj23Tuvx9pchLJMFAGB9GXlpDW1pBffBHp+HGEooCu76otCd57SBhXgl0hHCDgui7Sxgb6V7+K9oUvoFy5gtTpeEQ1IGLNJuqzz6K89BLq0hLW3/k7nhmohx8
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/df/d0c/tutorial_py_fast.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"from matplotlib import pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/blox.jpg', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"fast = cv.FastFeatureDetector_create()\n",
|
|||
|
"kp = fast.detect(img, None)\n",
|
|||
|
"img2 = cv.drawKeypoints(img, kp, None, color=(255, 0, 0))\n",
|
|||
|
"plt.imshow(img2)\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n",
|
|||
|
"fast.setNonmaxSuppression(0)\n",
|
|||
|
"kp = fast.detect(img, None)\n",
|
|||
|
"img3 = cv.drawKeypoints(img, kp, None, color=(255, 0, 0))\n",
|
|||
|
"plt.imshow(img3)\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 12,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGFCAYAAAASI+9IAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9eZxkVX03jr+rqmvtvXumZ5/p2Rlm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JhvdJhL01y5KDX+RDIAesmvNMNYrEYFi5ciFAohNdff10xpnA4bCPwbvtE9sfAwABeeeUVnHnmmSpKLRaLGeuze/dupFIpZLNZJVzQH3CC0UvBgEdq8brp5ofTHhsfbyycFKbgM4RqkLOY25K5Y1C3G7WWPbdYLKJUKsGyLEUAdfc4LVInZkBwu8hN99fa4OWGOEQiETQ0NFQRedpQxm3kZBaiPiGfC3+moaEBoVBIlRkMBtHW1lbFFEKhEOLxOCqVinFncD2YP38+Ojo6cODAAWVKCgaDajwlnBiD7MO+vj4MDw9jyZIlaGpqMmpulUoF+Xweu3btQi6XQzQaRalUQlNTk+pPmrdcA+QCC1DtFNfVUSeI+CGvb0z45qNTBMuykM/nlWTFFyqZMbjUGw6HEQwGkc/nlSbA/QUAcM0119gWlVdJ1qv9/2Sg1gYwYLKeF1xwQZWtn3DgwAE88cQTtmsNDQ0oFAqq7+g9FJIZjUaRSCRUFE4kEkEwGNRqCjqJeDrAzTpDQ0N48MEHlbbH66HTHGppbqVSCffddx8uuOACnHnmmdr39/T0qH4LBAIoFovKt5BOp5FKpdDY2IhYLIZyuYxYLKYYBB830m6IsVGdZPSUzgzmC5BvPPhM4RRCF80h7fjcDEILdHx8HJlMBseOHcPKlSvR0tI
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# https://docs.opencv.org/3.4/dc/d7d/tutorial_py_brief.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"from matplotlib import pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"def brief_descriptor(image, keypoints, patch_size=31, pairs=256):\n",
|
|||
|
" descriptors = []\n",
|
|||
|
" for kp in keypoints:\n",
|
|||
|
" x, y = int(kp.pt[0]), int(kp.pt[1])\n",
|
|||
|
" patch = image[y - patch_size // 2:y + patch_size // 2 + 1,\n",
|
|||
|
" x - patch_size // 2:x + patch_size // 2 + 1]\n",
|
|||
|
" if patch.shape != (patch_size, patch_size):\n",
|
|||
|
" continue\n",
|
|||
|
" patch = cv.GaussianBlur(patch, (5, 5), 0)\n",
|
|||
|
" desc = []\n",
|
|||
|
" for _ in range(pairs):\n",
|
|||
|
" p1 = np.random.randint(0, patch_size, 2)\n",
|
|||
|
" p2 = np.random.randint(0, patch_size, 2)\n",
|
|||
|
" desc.append(1 if patch[p1[0], p1[1]] < patch[p2[0], p2[1]] else 0)\n",
|
|||
|
" descriptors.append(desc)\n",
|
|||
|
" return np.array(descriptors, dtype=np.uint8)\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/blox.jpg', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"fast = cv.FastFeatureDetector_create()\n",
|
|||
|
"keypoints = fast.detect(img, None)\n",
|
|||
|
"descriptors = brief_descriptor(img, keypoints)\n",
|
|||
|
"\n",
|
|||
|
"img_with_circles = img.copy()\n",
|
|||
|
"for kp in keypoints:\n",
|
|||
|
" x, y = int(kp.pt[0]), int(kp.pt[1])\n",
|
|||
|
" radius = int(kp.size / 2)\n",
|
|||
|
" cv.circle(img_with_circles, (x, y), radius, (255, 0, 0), 2)\n",
|
|||
|
"\n",
|
|||
|
"plt.imshow(img_with_circles, cmap='gray')\n",
|
|||
|
"plt.axis('off')\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Лаба 11"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 9,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"(290, 32)\n",
|
|||
|
"Descriptor size: 32 bytes (default for BRIEF)\n",
|
|||
|
"Descriptor shape: (290, 32)\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGiCAYAAAC/NyLhAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOy9Z5Bk2XUe+N1n01Zmma6q9m56emZ6LGbAwYAACLcYgk4ksSuBgYilW1IhiYwVIROCVksKDO4iQqENMihDbawkUgyKThSDIVEkaIYgAXAGbrzp7mnvyldW+nz+7Y+X5/XJ2/dlZXX3ACjM+yIy0r1337XnO+fcc+8VcRzHyJEjR44cOXYJtG90BnLkyJEjR46dICeuHDly5Mixq5ATV44cOXLk2FXIiStHjhw5cuwq5MSVI0eOHDl2FXLiypEjR44cuwo5ceXIkSNHjl2FnLhy5MiRI8euQk5cOXLkyJFjVyEnrhw5cuTIsavwDSOuf/Nv/g2OHDmCQqGAJ598El/5yle+UVnJkSNHjhy7CN8Q4vqd3/kdfPKTn8TP/dzP4YUXXsAjjzyCp59+Gmtra9+I7OTIkSNHjl0E8Y3YZPfJJ5/EO9/5Tvzrf/2vAQBRFOHgwYP46Z/+afyTf/JPvt7ZyZEjR44cuwjG1/uBnufh+eefx6c+9an0N03T8OEPfxjPPfec8h7XdeG6bvo9iiI0Gg3Mzs5CCPGW5zlHjhw5ctxdxHGMTqeDffv2QdN25vz7uhPXxsYGwjDEwsLCyO8LCws4c+aM8p7PfOYz+PSnP/31yF6OHDly5Pg64tq1azhw4MCO7vm6E9ft4FOf+hQ++clPpt9brRYOHTqE119/HdVqdaI0csssR44cOb550Ol08MADD0wswzm+7sQ1NzcHXdexuro68vvq6ioWFxeV99i2Ddu2b/m9Wq1iampqoufmxJUjR44c33y4Hdn8dY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1Z/8v5fqu0QJmkVc/P+o+Ectb/JKzpWi7M5evpna7JKs+4uhtHuKp7eFqqMmcpMZyQuPLDr9d1/ZZrs/KR4+2JnLhyTAQSnrKwHHmPY4goAqIIME3gLrv/dkpa9NukpLiTvNB1MllPYjnRfyOkkiQIhGFyn6YBmpZ5ugCvd0orLWcYJmlROgrBryrjdv9PCvl0iKz0ZfKWyVom6kktuRzf+siJK8dE4EJFZWkAAFwX6PUQt9uI9+5NyEthhanSNoy3riveLUGnEuZBENzyDLl+Jpl7iqMoIZxmE7GuIy4UEBYKiDOeS0JfG5LbCAYDiMEAsCygXE7aQbpP1/Xx+ZlgXms7a5OTOj2XW4WciMgVOEkecuTIiSvHRJCF5Ii10GxCe+01WL/1WxArK4DjIN63D/4HPgD//e9HvLCQav1ZQnzSeTGVi227+3ZCXJOQDIcscCd1FY58bjahnT0L/U/+BNqNG4mlVanA+Zt/E9GhQxBzc+lz5Lms9OV5EN0u7N/5HWhXrkBsbACWhfD970d46hSiBx8ccdGprB2VGzLLyhnngiXLT06DW7683pTlkVyFmqapSTrH2xI5ceXYEW7RltfXIS5dgvGXfwn9C1+AtrGBOAiA2VnEmobYNBF85CNAsQiY5kQkkuUS/EYIre0ske2shKwADACJW9V1ob/yCvTXX4d25kxitYYhNE2D8dxzCFwXoRCIZmdvsWDSeS/Xhba8DP38eWgvv5xYbYMBRBBAe/FFxIMBwqkpBDMziE0TMRJLUVXPO3GTqpQY4CZBZbkeNU2DruspGckkttN5yRxvP+TElWMicEGZatQAzC99CebnPw/7P/yH5DohEutqZQXW7/0ezL/8S/TvvRfx0aMQGZssjxP+qs/yvFKWAM36bRKME+iqz6r5m3H5EkJ
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/d1/d89/tutorial_py_orb.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"from matplotlib import pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/blox.jpg', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"orb = cv.ORB_create()\n",
|
|||
|
"kp, des = orb.detectAndCompute(img, None)\n",
|
|||
|
"\n",
|
|||
|
"print(des.shape)\n",
|
|||
|
"print(f\"Descriptor size: {des.shape[1]} bytes (default for BRIEF)\")\n",
|
|||
|
"print(f\"Descriptor shape: {des.shape}\")\n",
|
|||
|
"img_with_keypoints = cv.drawKeypoints(img, kp, None, color=(255, 0, 0))\n",
|
|||
|
"plt.imshow(img_with_keypoints)\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 13,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAD3CAYAAACAR1dxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9WXBdWXIejH77zPOE4RyMBEAQIEGCM4tkV7FYrK6qrupB3eqhWuqWWvol9R/Xclz7RijCD/fJ4et3h+xwyPYf17JsyZKs7laruqq7uqaugcV5JkGCBEDMOBjOgDPPe9+H07mYJ7HBKvra8T+IKwIB4Jy915ArV+aXuXLl0gzDMPC0PC1Py9PytDwtT8s/2mL5v7sDT8vT8rQ8LU/L0/K0/N9bnoKBp+VpeVqelqflaflHXp6CgaflaXlanpan5Wn5R16egoGn5Wl5Wp6Wp+Vp+UdenoKBp+VpeVqelqflaflHXp6CgaflaXlanpan5Wn5R16egoGn5Wl5Wp6Wp+Vp+UdenoKBp+VpeVqelqflaflHX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0rmkfXfaHeJsDFjOZLcEJnzdaf7wO3idap5xuUvFIC5pkS7lcNpU5ZjSidsiNzo0TM2DA+RPAFoNFej0kwNvOYMvlcmoOzPgOaJUPvE2fzwePx9PSvnxe0pYKn1deN2+T8yW9s518fVz53GAAgIpy5Q1TocETSqvVarh58yaCwSA0TVMgwm63o1qttqAov9+vlC3QVLy1Wk0pBe7epb16m82GSqXSIgTIIiQmJWVEysMwDGX9SeFBxCYQQ8SmBUOInCs2Ais0Zq6
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/dc/dc3/tutorial_py_matcher.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img1 = cv.imread('img/box.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"img2 = cv.imread('img/box_in_scene.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"orb = cv.ORB_create()\n",
|
|||
|
"kp1, des1 = orb.detectAndCompute(img1, None)\n",
|
|||
|
"kp2, des2 = orb.detectAndCompute(img2, None)\n",
|
|||
|
"\n",
|
|||
|
"bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck=True)\n",
|
|||
|
"matches = bf.match(des1, des2)\n",
|
|||
|
"matches = sorted(matches, key=lambda x: x.distance)\n",
|
|||
|
"\n",
|
|||
|
"img3 = cv.drawMatches(img1, kp1, img2, kp2, matches[:10], None, flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)\n",
|
|||
|
"plt.imshow(img3)\n",
|
|||
|
"plt.axis('off')\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 14,
|
|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NSjrQt0r99F0S1iCH0n7cPjT7STZnhetdatQ/10qT1Wn6rsSgtITJUGgbFPRWM2lUvpK+Ni2zc9//nMuX77s0kAVXZnJIkGoPl+SNjq95IKXRXf5egkenbZetJb9lvfoAkPd42VVyHWor+e9tvF+G728hKEcn5fS0Okgx6LPg2xHX2Oqv7INLxrK+6ViU8970U9fS7pHSKdLoVBga2urjYawy++1Ws2VpfV6vW3rVcpNn8/X5qVV/dX7odPIMAw3FswLtOlzpJSPAg+SvtJI08drmib5fN4dixdY0+cJIB6PP8Ab6lP3PEuQpK8B1Y4X4NPnX46lUCi0eUr1OmQsjfouPXapVKoNIMi1L8fsJfd0fpHgUfKw5CXJe/9DPANNO8i271n2V98GTGrhU5SizxM0mwSsVYLVW/gKv8IwTRx/F0T3Q/wQVqgf24iAGcA0/W2Dh11FK4mvJlIpNMdpt6DlYKUykopO1ucV/CKZQPZHtuE4jtu3YDDoWo+SJmpCVb9brVab0tAXmJwcL7e1ZAgv95BulelMJf/XBZsOMrwsRCnIdaDitVjVXOn0lMJFoWnVpgJWuvBWdajtIH1OFD2lF0e1pXih0Wi0jU3SUPKWsjRUXxRgkSBRzaWsfy/3sr6QJZ28FJn+uypyLr1oL+m7FyjwErC64JPfdT7w2gqQz0tvgeRpdY++76/3W86PzjO6QpFrUdJZH4OqV8a96PXtRTepvHTa6d+9+qCKtBi92tJBjLIOfT4fxWKRtbW1tm02ea/ymgWDQRxn17pW++h6fxRvS8CiAywp56SMVUWtP1mH7JNap5JuuuLRLWglW2q1mqfM8aKRake50aVx4gUMJH8CDxgsutdDB3h7GWzFYtGdAy++g3b5INuMx+NEo9G29vX7ddqqIudV1i3b1IGTF3j7LOU
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img1 = cv.imread('img/box.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"img2 = cv.imread('img/box_in_scene.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"sift = cv.SIFT_create()\n",
|
|||
|
"kp1, des1 = sift.detectAndCompute(img1, None)\n",
|
|||
|
"kp2, des2 = sift.detectAndCompute(img2, None)\n",
|
|||
|
"\n",
|
|||
|
"bf = cv.BFMatcher()\n",
|
|||
|
"matches = bf.knnMatch(des1, des2, k=2)\n",
|
|||
|
"\n",
|
|||
|
"good_matches = []\n",
|
|||
|
"for m, n in matches:\n",
|
|||
|
" if m.distance < 0.75 * n.distance:\n",
|
|||
|
" good_matches.append([m])\n",
|
|||
|
"\n",
|
|||
|
"img3 = cv.drawMatchesKnn(img1, kp1, img2, kp2, good_matches, None, flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)\n",
|
|||
|
"plt.imshow(img3)\n",
|
|||
|
"plt.axis('off')\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 15,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAD3CAYAAACAR1dxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9Z5hk13XfC//qVI7d1dU5z0z35BwwGACDnEGCIJgpihJpJcqy/FrXlpyt63QtyTYl+7VEZSaBEYEgACINgJnBREzOuXOO1ZXDOef90L0Lq/ecBoH7+j73g2Y/Tz2Vztl77bVX+K+1w3HZtm1zq9wqt8qtcqvcKrfK39ti/L9NwK1yq9wqt8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odAQF0IX2BPYgxs3CTNBV7GLteW1NJqNBMtBfLYPj8uzqPMw72gl89VAKodm24sjaNlZ6Yyko5P1OS1+kUIg6ZFt2LZdoc3n81WiR8kTNaCK7nK5vCj1pCuYHByntLUUCKf0kB6V6UIlv+uGTQcZThGiNOQ6UHFSVjVWOj+lcVFoWrWpgJVuvFUdajpIHxPFT5nFUW0pWSgWi4v6JnkoZUtFGooWBVg2HD9ObanEufZ2Bjs7+fiVK3gX5jil8ulFV2TJJydHpv+vihxLJ95L/i4FCpwMrG745GddDpymAuT9MlsgZVpdo8/763TL8dFlRo63blAln/U+qHrluhe9vqX4Jp2Xzjv9sxMNqsiI0aktHcSo6NDtdpNKpRgZGVk0zSavVVkzn8+Hbc9H12oeXadHybYELDrAknZO2lhVlP7JOiRNiWKRL46OUhcKERsaonpmhovr1iFDLD2CVrYln8872hwnHil7oNLoMjh
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img1 = cv.imread('img/box.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"img2 = cv.imread('img/box_in_scene.png', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"\n",
|
|||
|
"sift = cv.SIFT_create()\n",
|
|||
|
"kp1, des1 = sift.detectAndCompute(img1, None)\n",
|
|||
|
"kp2, des2 = sift.detectAndCompute(img2, None)\n",
|
|||
|
"\n",
|
|||
|
"FLANN_INDEX_KDTREE = 1\n",
|
|||
|
"index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5)\n",
|
|||
|
"search_params = dict(checks=50)\n",
|
|||
|
"flann = cv.FlannBasedMatcher(index_params, search_params)\n",
|
|||
|
"\n",
|
|||
|
"matches = flann.knnMatch(des1, des2, k=2)\n",
|
|||
|
"\n",
|
|||
|
"matchesMask = [[0, 0] for _ in range(len(matches))]\n",
|
|||
|
"for i, (m, n) in enumerate(matches):\n",
|
|||
|
" if m.distance < 0.7 * n.distance:\n",
|
|||
|
" matchesMask[i] = [1, 0]\n",
|
|||
|
"\n",
|
|||
|
"draw_params = dict(matchColor=(0, 255, 0),\n",
|
|||
|
" singlePointColor=(255, 0, 0),\n",
|
|||
|
" matchesMask=matchesMask,\n",
|
|||
|
" flags=cv.DrawMatchesFlags_DEFAULT)\n",
|
|||
|
"\n",
|
|||
|
"img3 = cv.drawMatchesKnn(img1, kp1, img2, kp2, matches, None, **draw_params)\n",
|
|||
|
"plt.imshow(img3)\n",
|
|||
|
"plt.axis('off')\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"Краткое описание методов:\n",
|
|||
|
"\n",
|
|||
|
" Brute-Force Matching с ORB:\n",
|
|||
|
" Используется Hamming Distance для бинарных дескрипторов.\n",
|
|||
|
" Подходит для ORB, BRIEF, BRISK.\n",
|
|||
|
"\n",
|
|||
|
" Brute-Force Matching с SIFT:\n",
|
|||
|
" Используется L2 расстояние для вещественных дескрипторов.\n",
|
|||
|
" Применяется knnMatch и тест отношения Дэвида Лоу (Ratio Test).\n",
|
|||
|
"\n",
|
|||
|
" FLANN Matcher:\n",
|
|||
|
" Быстрее для больших наборов данных.\n",
|
|||
|
" Использует K-D деревья для вещественных дескрипторов (например, SIFT, SURF).\n",
|
|||
|
" Использует LSH для бинарных дескрипторов (например, ORB)."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAD3CAYAAACAR1dxAA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QE6vxeKBSULC0Wiw1Lr1xuSi8ttVe2Q9LIYDCoWDA90CbHiJQPgQdOX26kyf4ajUYkk0nVFz2wJscJANxu9yO8QZ/S88xBkpwDVI8e4JPjz/tCS+J8+ZuXwWNp6Dv32Pl8vgaAwOc+77Oe3JP8wsEj52HOS5z3/od4BkjJy8mqaVqD6wJAg8XHwYBkHKCuaDnxgYcuauo8t6B5Z7ky4oqOl6cX/EK/U+K/80GktlmtVmU9cprQgFK7K5VKAx3kBOODo+e25gyh5x6SVplkKv6/FGwSZOhZiFyQS6CiN1lprCQ9uXAhNE11ErCSwpvKoOUgOSZET+7FobqIF0qlUkPfOA05b5GlQW0hwMJBIo0lL38r97KcyJxOeopM/k6Jj6Ue7Tl9twIFegJWCj7+XfKBtPLk+9xbwHma8sh1f9luPj6SZ6RC4XOR01n2gcrlcS+yvK3oxpWXpJ38rtcGStxi1KtLghiyDk0mE9LpNMLhcMMyG89LXjOr1QpNq1vXtI4u20O8zQGLnsyW4ISPG80/XgZvE81TTjepeKQFTbKlUCjoyhw9GlE95EbnxokeMOD8CeARg0V6PSTA28pgS6fTagz0+A5olA+8TrfbDafT2VC/zC9pS4mPKy+b18n5kt7ZSr4+Ln1mMABARbnyiilR5wmllctl3Lx5Ez6fDwaDQYEIi8WCUqnUgKI8Ho9StkBd8ZbLZaUUuHuX1urNZjOKxWKDECCLkJiUlBEpD03TlPUnhQcRm0AMEZsmDCFyrtgIrFCfuaKWil4KHxooyai
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 640x480 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/d1/de0/tutorial_py_feature_homography.html\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"from matplotlib import pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"MIN_MATCH_COUNT = 10\n",
|
|||
|
"\n",
|
|||
|
"img1 = cv.imread('img/box.png', cv.IMREAD_GRAYSCALE) # queryImage\n",
|
|||
|
"img2 = cv.imread('img/box_in_scene.png', cv.IMREAD_GRAYSCALE) # trainImage\n",
|
|||
|
"\n",
|
|||
|
"sift = cv.SIFT_create()\n",
|
|||
|
"\n",
|
|||
|
"kp1, des1 = sift.detectAndCompute(img1, None)\n",
|
|||
|
"kp2, des2 = sift.detectAndCompute(img2, None)\n",
|
|||
|
"\n",
|
|||
|
"FLANN_INDEX_KDTREE = 1\n",
|
|||
|
"index_params = dict(algorithm=FLANN_INDEX_KDTREE, trees=5)\n",
|
|||
|
"search_params = dict(checks=50)\n",
|
|||
|
"\n",
|
|||
|
"flann = cv.FlannBasedMatcher(index_params, search_params)\n",
|
|||
|
"\n",
|
|||
|
"matches = flann.knnMatch(des1, des2, k=2)\n",
|
|||
|
"\n",
|
|||
|
"good = []\n",
|
|||
|
"for m, n in matches:\n",
|
|||
|
" if m.distance < 0.7 * n.distance:\n",
|
|||
|
" good.append(m)\n",
|
|||
|
"\n",
|
|||
|
"if len(good) > MIN_MATCH_COUNT:\n",
|
|||
|
" src_pts = np.float32([kp1[m.queryIdx].pt for m in good]).reshape(-1, 1, 2)\n",
|
|||
|
" dst_pts = np.float32([kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2)\n",
|
|||
|
"\n",
|
|||
|
" M, mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC, 5.0)\n",
|
|||
|
" matchesMask = mask.ravel().tolist()\n",
|
|||
|
"\n",
|
|||
|
" h, w = img1.shape\n",
|
|||
|
" pts = np.float32([[0, 0], [0, h - 1], [w - 1, h - 1], [w - 1, 0]]).reshape(-1, 1, 2)\n",
|
|||
|
" dst = cv.perspectiveTransform(pts, M)\n",
|
|||
|
"\n",
|
|||
|
" img2 = cv.polylines(img2, [np.int32(dst)], True, 255, 3, cv.LINE_AA)\n",
|
|||
|
"else:\n",
|
|||
|
" print(f\"Not enough matches are found - {len(good)}/{MIN_MATCH_COUNT}\")\n",
|
|||
|
" matchesMask = None\n",
|
|||
|
"\n",
|
|||
|
"draw_params = dict(matchColor=(0, 255, 0),\n",
|
|||
|
" singlePointColor=None,\n",
|
|||
|
" matchesMask=matchesMask,\n",
|
|||
|
" flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)\n",
|
|||
|
"\n",
|
|||
|
"img3 = cv.drawMatches(img1, kp1, img2, kp2, good, None, **draw_params)\n",
|
|||
|
"\n",
|
|||
|
"plt.imshow(img3, 'gray')\n",
|
|||
|
"plt.axis('off')\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"# Лаба 12"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": null,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"ename": "",
|
|||
|
"evalue": "",
|
|||
|
"output_type": "error",
|
|||
|
"traceback": [
|
|||
|
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
|
|||
|
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
|
|||
|
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
|
|||
|
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/db/d28/tutorial_cascade_classifier.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"\n",
|
|||
|
"def detectAndDisplay(frame):\n",
|
|||
|
" frame_gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)\n",
|
|||
|
" frame_gray = cv.equalizeHist(frame_gray)\n",
|
|||
|
"\n",
|
|||
|
" faces = face_cascade.detectMultiScale(frame_gray)\n",
|
|||
|
" for (x, y, w, h) in faces:\n",
|
|||
|
" center = (x + w // 2, y + h // 2)\n",
|
|||
|
" frame = cv.ellipse(frame, center, (w // 2, h // 2), 0, 0, 360, (255, 0, 255), 4)\n",
|
|||
|
"\n",
|
|||
|
" faceROI = frame_gray[y:y + h, x:x + w]\n",
|
|||
|
" eyes = eyes_cascade.detectMultiScale(faceROI)\n",
|
|||
|
" for (x2, y2, w2, h2) in eyes:\n",
|
|||
|
" eye_center = (x + x2 + w2 // 2, y + y2 + h2 // 2)\n",
|
|||
|
" radius = int(round((w2 + h2) * 0.25))\n",
|
|||
|
" frame = cv.circle(frame, eye_center, radius, (255, 0, 0), 4)\n",
|
|||
|
"\n",
|
|||
|
" cv.imshow('Capture - Face detection', frame)\n",
|
|||
|
"\n",
|
|||
|
"face_cascade = cv.CascadeClassifier()\n",
|
|||
|
"eyes_cascade = cv.CascadeClassifier()\n",
|
|||
|
"\n",
|
|||
|
"face_cascade_name = 'data/haarcascade_frontalface_alt.xml'\n",
|
|||
|
"eyes_cascade_name = 'data/haarcascade_eye_tree_eyeglasses.xml'\n",
|
|||
|
"\n",
|
|||
|
"if not face_cascade.load(cv.samples.findFile(face_cascade_name)):\n",
|
|||
|
" print('--(!)Error loading face cascade')\n",
|
|||
|
" exit(0)\n",
|
|||
|
"if not eyes_cascade.load(cv.samples.findFile(eyes_cascade_name)):\n",
|
|||
|
" print('--(!)Error loading eyes cascade')\n",
|
|||
|
" exit(0)\n",
|
|||
|
"\n",
|
|||
|
"cap = cv.VideoCapture(0)\n",
|
|||
|
"if not cap.isOpened():\n",
|
|||
|
" print('--(!)Error opening video capture')\n",
|
|||
|
" exit(0)\n",
|
|||
|
"\n",
|
|||
|
"while True:\n",
|
|||
|
" ret, frame = cap.read()\n",
|
|||
|
" if frame is None:\n",
|
|||
|
" print('--(!) No captured frame -- Break!')\n",
|
|||
|
" break\n",
|
|||
|
"\n",
|
|||
|
" detectAndDisplay(frame)\n",
|
|||
|
"\n",
|
|||
|
" if cv.waitKey(10) & 0xFF == ord('q'): # Нажмите 'q' для выхода\n",
|
|||
|
" break\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"attachments": {
|
|||
|
"image.png": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABA0AAAIICAYAAAAFYBdkAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhe7L0HgGZHdedbPTMdpicHzWgkjbJACCGwjY1BGEcw4HUEAzY48h4YJ7zexcYLfqt9hsVhlzU4YNi1MWt4JtpeB4HBYIKEQSBQRjmOJofu6Zxm3v/3P3W+73arezSjhITumam+91Y4derUqapzKn09RwWlhRZaaKGFFlpooYVvaLjwwgtKz7Kjpaenp+FK0V/9eU7Z/tPPLVv8Lp9l+NZ3R+opY1/7+3LXzh1l4u57KsbF4FvLL//BK8u6L/5CefOHqxfw4jeUP3vijeUX3vyRUp7xy+WtP7uuXP6aNxd9GV70hj8r599U0xD3GcPlL173x+UKfX7ba95afn7j5ZH2PvhfVN7wjovL8F/+evnjL/J+frmxgbcDC3AC8/F2AVouPvjn5dff8aXqMx/m0QpQnheX8v4G7ibcJ75hId35XoMX4hT9bz3p4+X95SfKy8pfV9rum44yZfhi5Vuclocf9u49ULZs2VS/ThS+p5zxyudLNpeG0Rv+zrI5ftfd1WcRWEQGDAv9+T6GrC4G9+V1Qxab+BaBqJNPlPLEUt6sOJ3vZ2wrn1hCpu7bDvj+iVI+XGVhYZmOVY55Yfcviy96w1vLtn/5a+XRyG8R/E1Z431+m1pA73HAth99Q3nD87aXFfW7A7P3lE+8RfnurN/3Aw9KFjf/ZHnSDz+trK6fi8HeL/1F2bd3bxnffbD6LAYN+eAr6/x7F/rBv/up63nfzfcFddmoo3uOJa8LaEtYVp8ttNBCCy200EILLXyDw/y1ong/6udsKUd4413O/yM8vI6Wucm7jm2U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qhcgQ/S1ze8WWmihhRZaaKGFxwksnDh4uCcMckIgHk2FTu8L9LvuvMKCgBZaaKGFFh5XsOikQQ4NX9uzo9wxtKsMzR4qE2WkTPeM2v9onnXTP2DV+tEyuDrCloRb/6l88POvKj9yjAmCj766sdX/1bn9oK52f5RdCs0jAPi/sLyrfL782nkZf+HKevM73l/96ouF49X6EnjnQ+ZZ/R4iWLwswPzjGZ2g46GlEefit91cPSvcJ/1i/FksXsJCuo6Dv/NwNcqS8d726k7YI3dso4UWWmihhRYeW9CcOHhYJwxaaKGFFlpo4QHAopMGebXNRM9o6V05U3oHZsqK/unSK2c42p0wAM4/aXs5d/3Z9esY8KwLynn1dTF4wTtzm/+l5VXvelPD+Jfh+qZS3kPYLX9Yyq/9jMJeUN5JvDweMG/7wlLw+XLdBe8R/neWF2DYnvfB8pI8WnBpKW96QIZtNaoXGM6LlwXD/LzywZfcUsNy18Xx0EKc2KlBnPeUD8qgT1gs/XmL8GepfBaj6/74O58e6uW6FzYnbMSXG36k5vOq8vlf+wOlaKGFFlpo4dEOOZ7dn2uhhRZaaKGFFh4fsPidBhU8WSDX249rTBpIV2huVDt3wzl29wufv6HcUl8XhY/myjQr3E2Q4fqe1xYfpT/3teWNr/p8ueGYiJaCZ5WX/EA9kH/rzeW6psH/wneJvAVIj2f1P43qjrFdvRcrS91t8caFlwIcFy2K86w/LK+r+M997Rtl0Fc4nvTAUvGWoutYYFyNnSP3qRfxJYl9wY8o5nXl5gcyJ9NCCy200MIjCjme3Z9r4aGD5pGE5lGFFlpooYUWWng0wDEnDWLCICYL+nj2xaRBKAupMBwt0zMzZWJisn4vAef+QHnJs95V/m6p5WYM9BeWcqmVkVvKHz6r+t8Hbi03X1dfHzS8quZX3cLVdF/8l+HsTjhOOO6yNOF+
|
|||
|
}
|
|||
|
},
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"![image.png](attachment:image.png)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 3,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAw4AAAMsCAYAAAD9JvVwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9ebBtW1oXCv7GmM1qd7/3Oeee2+TNhgQyeaCZmBZVpCSmPE006vmelFEhUSaEEGCKSIhBBYYGRgAqjYZRgVaIIGBTfxAURBQhQmKJgVi8VB4vwQYw02xu3ua0u139nHOM+uMb3xjfGGuuvde+mfnSJ/PLXHfts9Zcc472a35fM5S11qKjjjrqqKOOOuqoo4466uga0p/rBnTUUUcdddRRRx111FFH//VTZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHXXUUUcdddRRRzdSZzh01FFHHf0uphdffBF/7I/9sc/qM97znvfgPe95z2f1GR111FFHHX32qTMcOuqoo44+g/TjP/7jUErh137t11q/f8973oMv+qIv+t+4VZ89UkrhW77lWz7Xzeioo4466uh/A8o/1w3oqKOOOurov2364Ac/+LluQkcdddRRR58B6gyHjjrqqKOOPqtUluXnugkdddRRRx19BqgLVeqoo446+hxTXdf47u/+brz5zW9Gr9fDiy++iL/8l/8ylstldJ1SCn/tr/21td+/+OKL+Lqv+7ros9/8zd/EV3zFV2AwGOC5557D93zP9+DHfuzHoJTCJz7xibV7/Mqv/Are9a53od/v401vehP+0T/6R5+x/qU5Dv/qX/0rKKXwkz/5k/je7/1ePPfcc+j3+3jve9+Lj370o2u//9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MfxE//9E/DGIO3vOUt+Ht/7+/hz/7ZP/tpPb+jjjrqqKNAyn62s9866qijjjr6r4K+7du+DX//7/99TCaTjYnJHXXUUUcddbSJuhyHjjrqqKP/Bmk+n0f/fvr0Kf7xP/7H+PIv//LOaOioo4466uh1UReq1FFHHXX03yB92Zd9Gd7znvfgC7/wC/Hw4UP86I/+KC4vL/FX/+pf/Vw3raOOOuqoo/+dUmc4dNRRRx39N0hf/dVfjZ/6qZ/CD//wD0MphXe84x340R/9UfyBP/AHPtdN66ijjjrq6H+n1OU4dNRRRx111FFHHXXUUUc3Upfj0FFHHXXUUUcdddRRRx3dSJ3h0FFHHXXUUUcdddRRRx3dSJ3h0FFHHXXUUUcdddRRRx3dSNsnR3+GTxrtqKOOOuqoo4466qijjv4roS3SnjuPQ0cdddRRRx111FFHHXV0I3WGQ0cdddRRRx111FFHHXV0I3WGQ0cdddRRRx111FFHHXV0I3WGQ0cdddRRRx111FFHHXV0I22dHP1rf/L/CgBQUAAUtFYih4ISp7VSUEpBaw1rLaw1/veZzqC1hnJJ1quqgjEGdP6cAqdeW1goZQFlAdCrrms0TYPpdIblcomLi0vMF3PMpjMopaGUxtHRIYbDEY6OT1AUBbTOAGvhz7dTgFYaSivkeQ6tFZqmhjEGdV3zw127LaAA5fqjlIryRaxrmrEG1ljfJ6jQDyjlxgPQWvkxMqaBMRZN08BaG8ZMaWqjDrac5RGx/pY0ViJR3RoLawze/D//Cg5eeXnb6fR0NRzi//ff/XeYWIvLq0tkWYYizzAYDNHr9VCvVmiMgTUGWmuMhoPo+QpAlmXQmYZxffLvruEKgHHjqtw
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x1000 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/d6/d10/tutorial_py_houghlines.html\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/sudoku.png')\n",
|
|||
|
"gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)\n",
|
|||
|
"edges = cv.Canny(gray, 50, 150, apertureSize=3)\n",
|
|||
|
"\n",
|
|||
|
"lines = cv.HoughLines(edges, 1, np.pi / 180, 200)\n",
|
|||
|
"for line in lines:\n",
|
|||
|
" rho, theta = line[0]\n",
|
|||
|
" a = np.cos(theta)\n",
|
|||
|
" b = np.sin(theta)\n",
|
|||
|
" x0 = a * rho\n",
|
|||
|
" y0 = b * rho\n",
|
|||
|
" x1 = int(x0 + 1000 * (-b))\n",
|
|||
|
" y1 = int(y0 + 1000 * (a))\n",
|
|||
|
" x2 = int(x0 - 1000 * (-b))\n",
|
|||
|
" y2 = int(y0 - 1000 * (a))\n",
|
|||
|
" cv.line(img, (x1, y1), (x2, y2), (0, 0, 255), 2)\n",
|
|||
|
"\n",
|
|||
|
"plt.figure(figsize=(10, 10))\n",
|
|||
|
"plt.imshow(cv.cvtColor(img, cv.COLOR_BGR2RGB))\n",
|
|||
|
"plt.title(\"Hough Lines\")\n",
|
|||
|
"plt.axis(\"off\")\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 4,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAw4AAAMsCAYAAAD9JvVwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9edRtWVUfDP/W2nuf/jz9c++tSxVUpaD4JBT4vmgSIgQQhigq9ohfjGBgoCZIHDEZH0ZfBYZKYoeKAWJMClSMvGpMRcWAvIIYxRHbiPqiRVN91e2e9rS7Wev7Y6651tzr7HMbQEHdE5567nPOblY715y/2SlrrUVLLbXUUksttdRSSy211NJVSH+qG9BSSy211FJLLbXUUkstffpTqzi01FJLLbXUUksttdRSS9ekVnFoqaWWWmqppZZaaqmllq5JreLQUksttdRSSy211FJLLV2TWsWhpZZaaqmlllpqqaWWWromtYpDSy211FJLLbXUUksttXRNahWHllpqqaWWWmqppZZaauma1CoOLbXUUksttdRSSy211NI1qVUcWmqppZZaaqmlllpqqaVrUqs4tNRSS38rSCmFV77ylZ+05731rW+FUgq/93u/d81rn/3sZ+PZz362//vee++FUgpvfetb/Wevec1roJT6pLXvpS99KW699dZP2vP+uhCP7Q/8wA/8pb5HKYXXvOY1f6nvaKmlllr6dKNWcWippZY+ZcTCN//0ej3ccccdeOUrX4kLFy58qpv3aU8PP/wwXvOa1+CP/uiP/lLf89KXvhSj0Wjt959spexTSe973/uglMLP//zPf6qb0lJLLbX0aUfpp7oBLbXUUkuve93rcNttt2GxWOB//s//iTe/+c145zvfiT/5kz/BYDD4VDfvE6Z3v/vd17zmO77jO/DqV7/6hp778MMP47WvfS1uvfVWfOZnfmbtu//4H/8jjDE39LyWrp/m8znStD1CW2qppb9d1HK9llpq6VNOX/AFX4DP+qzPAgC8/OUvx+7uLn7oh34Id999N77ma76m8Z7pdIrhcPhX2cyPmzqdzjWvSdP0kyqIZln2SXtWS6vU6/U+1U1oqaWWWvorp9ZVqaWWWvq0o8/93M8FAHzsYx8DEFxlPvKRj+AFL3gBxuMx/vE//scASIH41m/9Vtxyyy3odrt44hOfiB/4gR+Atbbx2W9/+9vxxCc+Eb1eD0972tPw/ve/v/b9fffdh3/2z/4ZnvjEJ6Lf72N3dxdf9VVfhXvvvbfxebPZDN/wDd+A3d1dbGxs4Ou+7utweHhYuyaOcWiiphiHX/u1X8MznvEMbG1tYTQa4YlPfCL+zb/5NwDIpeazP/uzAQBf//Vf7929OG6iKcbBGIMf+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WIuL4k082Xe29GxsbuOeee2CtbVyLQAhqv+222/Av/+W/xA/90A/h7W9/O575zGfihS98Ib72a7+2dVNqqaWWPmXUKg4ttdTSp5z+3t/7e9f0se92ux+XwHyj9M3f/M2466678C3f8i14+tOfjs3NTSil8OIXv/ivNL1pv9/H+9//frz3ve/Fr/zKr+B//I//gXe84x343M/9XLz73e9GkiR/ZW35y6J1lg62/nwitG587Jqg+U8WXeu9xhgopfCrv/qrjddKi8oP/uAP4qUvfSnuvvtuvPvd78arXvUqvP71r8fv/M7vrCjRLbXUUkt/FdQqDi211NJfW3rc4x6H97znPTg9Pa1ZHT70oQ/57yXdc889K8/4i7/4CwwGA+zv7wMAfv7nfx4veclL8IM/+IP+msVigaOjo8Y23HPPPXjOc57j/55MJnjkkUfwghe84OPuF5P
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x1000 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/sudoku.png')\n",
|
|||
|
"gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)\n",
|
|||
|
"edges = cv.Canny(gray, 50, 150, apertureSize=3)\n",
|
|||
|
"\n",
|
|||
|
"lines = cv.HoughLinesP(edges, 1, np.pi / 180, 100, minLineLength=100, maxLineGap=10)\n",
|
|||
|
"for line in lines:\n",
|
|||
|
" x1, y1, x2, y2 = line[0]\n",
|
|||
|
" cv.line(img, (x1, y1), (x2, y2), (0, 255, 0), 2)\n",
|
|||
|
"\n",
|
|||
|
"plt.figure(figsize=(10, 10))\n",
|
|||
|
"plt.imshow(cv.cvtColor(img, cv.COLOR_BGR2RGB))\n",
|
|||
|
"plt.title(\"Probabilistic Hough Lines\")\n",
|
|||
|
"plt.axis(\"off\")\n",
|
|||
|
"plt.show()\n",
|
|||
|
"\n"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 6,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnwAAAKSCAYAAABIowakAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACVU0lEQVR4nOzdd5wkVbk38N+pqo6T88zmwC4L7LJLDgtLFhREkCCgKAYUhavgRX0FE2JGRUQviAG9IFevAgooKJcgBkCWzAZYdpeFDZN3QvfMdKg67x81p6a6p7unJ3Sc33c/89mu6uruMz3dXU+fc57zCCmlBBERERGVLa3QDSAiIiKi3GLAR0RERFTmGPARERERlTkGfERERERljgEfERERUZljwEdERERU5hjwEREREZU5BnxEREREZY4BHxEREVGZY8BHRATg+OOPx/HHHz+j9/nLX/4SQgi88cYbM3J/b7zxBoQQ+OUvfzkj90dEswcDPqJZQgUf6sfv92POnDk49dRT8cMf/hCDg4NTvu+NGzfiK1/5yowFNun861//wle+8hX09fXl9HEmYpombr/9dhx//PGor6+Hz+fDokWL8MEPfhDr168vaNuIiFJhwEc0y3z1q1/FHXfcgVtuuQX/8R//AQC48sorsWrVKrz00ktTus+NGzfiuuuuy0vAd9111xU04BseHsYZZ5yBD33oQ5BS4pprrsEtt9yC97///XjyySdx+OGHY+fOnQCAiy++GMPDw1i4cGHB2ktEBABGoRtARPn19re/HYceeqiz/fnPfx6PPvoozjjjDJx55pnYtGkTAoFAAVtY3D7zmc/goYcewo033ogrr7wy4bovf/nLuPHGG51tXdeh63rG+5NSYmRkhM85EeUUe/iICCeeeCK++MUvYseOHbjzzjsTrtu8eTPOPfdc1NfXw+/349BDD8V9993nXP/LX/4S5513HgDghBNOcIaMH3/8ceeYBx98EMceeywqKipQVVWF008/HRs2bBjXjs2bN+P8889HU1MTAoEA9t13X1x77bUAgK985Sv4zGc+AwBYvHix8zjuXsU777wThxxyCAKBAOrr63HBBRfgrbfeGvc4t912G5YuXYpAIIDDDz8cf//737N6nnbu3Imf/OQnOOWUU8YFe4Ad4F199dWYN2+e89wkt3HRokU444wz8Je//AWHHnooAoEAfvKTnwAA+vr6cNVVV2HRokXw+XyYN28e3v/+96O7uztjuyb6GwFALBbDddddh2XLlsHv96OhoQHHHHMMHn744ax+dyIqbQz4iAiAPfwIAH/961+dfRs2bMCRRx6JTZs24f/9v/+H733ve6ioqMBZZ52Fe++9FwCwbt06fPKTnwQAXHPNNbjjjjtwxx13YL/99gMA3HHHHTj99NNRWVmJb3/72/jiF7+IjRs34phjjkkIhF566SUcccQRePTRR3HppZfipptuwllnnYX7778fAPDud78bF154IQDgxhtvdB6nqakJAPD1r38d73//+7Fs2TJ8//vfx5VXXolHHnkE69atSxgC/vnPf46PfexjaG1txXe+8x2sXbsWZ555ZsrAMNmDDz6IeDzuPFdT9eqrr+LCCy/EKaecgptuuglr1qxBKBTCsccei5tvvhlve9vbcNNNN+Gyyy7D5s2bnSHiVLL5GwF2wHzdddfhhBNOwI9+9CNce+21WLBgAZ577rlp/S5EVCIkEc0Kt99+uwQgn3nmmbTH1NTUyIMOOsjZPumkk+SqVavkyMiIs8+yLHn00UfLZcuWOft+97vfSQDyscceS7i/wcFBWVtbKy+99NKE/e3t7bKmpiZh/7p162RVVZXcsWNHwrGWZTmXb7jhBglAbt++PeGYN954Q+q6Lr/+9a8n7H/55ZelYRjO/mg0Kpubm+WaNWtkJBJxjrvtttskAHncccelfW6klPKqq66SAOTzzz+f8ThFPefu9i5cuFACkA899FDCsV/60pckAHnPPfeMux/1HGzfvl0CkLfffrtzXbZ/o9WrV8vTTz89q3YTUflhDx8ROSorK51s3d7eXjz66KM4//zzMTg4iO7ubnR3d6OnpwennnoqtmzZgl27dmW8v4c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UuWoKOjA08++SR27tyJF198EQCwZs0a6LqOb3/72+jv74fP58OJJ56I5uZm3HLLLbj44otx8MEH44ILLkBTUxPefPNN/OlPf8LatWvxox/9CADwwx/+EMcccwwOPvhgfPSjH8XixYvxxhtv4E9/+hNeeOEFAMAhhxwCALj22mtxwQUXwOPx4J3vfCeWLl2Kr33ta/j85z+PN954A2eddRaqqqqwfft23HvvvfjoRz+Kq6++Gh6PB1/72tfwsY99DCeeeCLe8573YPv27bj99tuzmsMHAN/73vewdetWfPKTn8Q999yDM844A3V1dXjzzTfxu9/9Dps3b8YFF1ww6b/LZz7zGfz+97/Heeedhw996EM45JBD0Nvbi/vuuw+33npr2t7HbP9G+++/P44//ngccsghqK+vx/r16/H73/8eV1xxxaTbSkQlqHAJwkSUT2qJEPXj9Xpla2urPOWUU+RNN90kBwYGUt5u69at8v3vf79sbW2VHo9Hzp07V55xxhny97//fcJxP/3pT+WSJUukruvjlmh57LHH5Kmnnipramqk3++XS5culZdccolcv359wn288sor8uyzz5a1tbXS7/fLfffdV37xi19MOOb666+Xc+fOlZqmjVvy5O6775bHHHOMrKiokBUVFXLFihXy8ssvl6+++mrCffzXf/2XXLx4sfT5fPLQQw+VTzzxhDzuuOMmXJZFicfj8mc/+5k89thjZU1NjfR4PHLhwoXygx/8YMKSLemWZUm3PEpPT4+84oor5Ny5c6XX65Xz5s2TH/jAB2R3d7eUMvWyLFJm9zf62te+Jg8//HBZW1srA4GAXLFihfz6178uo9FoVr8zEZU
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 800x800 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"#https://docs.opencv.org/3.4/da/d53/tutorial_py_houghcircles.html\n",
|
|||
|
"import numpy as np\n",
|
|||
|
"import cv2 as cv\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"img = cv.imread('img/geometric_shapes.jpg', cv.IMREAD_GRAYSCALE)\n",
|
|||
|
"assert img is not None, \"Image could not be read. Check the file path.\"\n",
|
|||
|
"\n",
|
|||
|
"img = cv.medianBlur(img, 5)\n",
|
|||
|
"cimg = cv.cvtColor(img, cv.COLOR_GRAY2BGR)\n",
|
|||
|
"\n",
|
|||
|
"circles = cv.HoughCircles(img, cv.HOUGH_GRADIENT, 1, 20,\n",
|
|||
|
" param1=50, param2=30, minRadius=0, maxRadius=0)\n",
|
|||
|
"\n",
|
|||
|
"if circles is not None:\n",
|
|||
|
" circles = np.uint16(np.around(circles))\n",
|
|||
|
" for i in circles[0, :]:\n",
|
|||
|
" cv.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 2) # Draw the circle\n",
|
|||
|
" cv.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 3) # Draw the center\n",
|
|||
|
"\n",
|
|||
|
"plt.figure(figsize=(8, 8))\n",
|
|||
|
"plt.imshow(cv.cvtColor(cimg, cv.COLOR_BGR2RGB))\n",
|
|||
|
"plt.title(\"Detected Circles\")\n",
|
|||
|
"plt.axis(\"off\")\n",
|
|||
|
"plt.show()\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": ".venv",
|
|||
|
"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.9.13"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 2
|
|||
|
}
|