2021-11-28 20:35:20 +01:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-11-28 23:19:14 +01:00
|
|
|
"execution_count": 17,
|
2021-11-28 20:35:20 +01:00
|
|
|
"id": "eba0bc77",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2021-11-28 23:19:14 +01:00
|
|
|
"source": [
|
|
|
|
"import cv2 as cv\n",
|
|
|
|
"import numpy as np\n",
|
|
|
|
"import math\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"%matplotlib inline"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 3,
|
|
|
|
"id": "0277975c",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"road = cv.imread(\"img/road-lanes.jpg\", cv.IMREAD_COLOR)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 6,
|
|
|
|
"id": "7a47faa3",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"Text(0.5, 1.0, 'Image')"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 6,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABB8AAAJqCAYAAABjB+jgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9W6htz/bvB31aVfU+xlxr//b/f3JRk5MQBc+Doo8m4IsPKhhDSB6TqNGHEFDi7U0Qg4pC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ERH4fPmYhHCteVBMTPgmcQrp6jb70wxVydP2s7WGuBIRPe4/NcLp6zbs7Rmm9eVy9pR0FmX99VAzse2luXcsGzfwpIot78zt2n1tMDsnq18xhr9TEnq9yFjBn8++xYqp/W8uGe+cyNr4v7azd48986tyX2WLw2eKbYsHzJelzaUo7d3nkiE/J/Xb0NLBI0oqFBQySESAithUCyMBBrMdZijAUxmd0wmYMwOW+L1UShWWmJjgBRiRqITUNTVTR1DUBRFJRlSRSHpSU52hEthKCEGIhRaaLHe582ygVcUWBtgXUOEy1gaDkEMRY0jMm3riNnm3cNGBWQiGgkdjEIUq0ZY9M4ijERLsahHSVCtpAIyWNAbGYVstfAwKrjzFKX1sahhaGlJMzUGnbYvTVZc0QR1FhMofjmhEQ4vP1+tU88hHxQVS8i/wTwvyEdtfk/U9W/uvg8AuUbKDRq8G1LMsMgz253Xz75nE8e95m8brc4kNuL0prrzOAiq4Tpbu7SIi3tEMr8Xe7YP+MUfE9T1Xvjj0GonH7DbfV8j/q4j4B1j3F/cyk2driXynjWBp+gEM31g6Ei8Bl
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 2880x3600 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"plt.figure(figsize=(40,50))\n",
|
|
|
|
"plt.subplot(121)\n",
|
|
|
|
"plt.imshow(road[:,:,::-1])\n",
|
|
|
|
"plt.title(\"Image\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 35,
|
|
|
|
"id": "ddc3511e",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"Text(0.5, 1.0, 'Binary')"
|
|
|
|
]
|
|
|
|
},
|
|
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|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"road_gray = cv.cvtColor(park, cv.COLOR_BGR2GRAY)\n",
|
|
|
|
"\n",
|
|
|
|
"_, img_bin = cv.threshold(road_gray, 230, 255, cv.THRESH_BINARY)\n",
|
|
|
|
"\n",
|
|
|
|
"plt.figure(figsize=(40,50))\n",
|
|
|
|
"plt.subplot(121)\n",
|
|
|
|
"plt.imshow(road_gray, cmap='gray')\n",
|
|
|
|
"plt.title(\"Image\")\n",
|
|
|
|
"plt.subplot(122)\n",
|
|
|
|
"plt.imshow(img_bin, cmap='gray')\n",
|
|
|
|
"plt.title(\"Binary\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 54,
|
|
|
|
"id": "6fe434f8",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"Text(0.5, 1.0, 'Image')"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 54,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABB8AAAJqCAYAAABjB+jgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9W6htz/bvB31aVfU+xlxr//b/f3JRk5MQBc+Doo8m4IsPKhhDSB6TqNGHEFDi7U0Qg4pCHgQVvBHExyBREHwIKPooCHlQlKMoMSaexJDEnPPfv99ac47ee1U1H6r6dfTbuM011t7ju/dvzTn7pap6XVv7VmutRFV54YUXXnjhhRdeeOGFF1544YUXXngUzI8uwAsvvPDCC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W8uGe+cyNr4v7azd48986tyX2WLw2eKbYsHzJelzaUo7d3nkiE/J/Xb0NLBI0oqFBQySESAithUCyMBBrMdZijAUxmd0wmYMwOW+L1UShWWmJjgBRiRqITUNTVTR1DUBRFJRlSRSHpSU52hEthKCEGIhRaaLHe582ygVcUWBtgXUOEy1gaDkEMRY0jMm3riNnm3cNGBWQiGgkdjEIUq0ZY9M4ijERLsahHSVCtpAIyWNAbGYVstfAwKrjzFKX1sahhaGlJMzUGnbYvTVZc0QR1FhMofjmhEQ4vP1+tU88hHxQVS8i/wTwvyEdtfk/U9W/uvg8AuUbKDRq8G1LMsMgz253Xz75nE8e95m8brc4kNuL0prrzOAiq4Tpbu7SIi3tEMr8Xe7YP+MUfE9T1Xvjj0GonH7DbfV8j/q4j4B1j3F/cyk2driXynjWBp+gEM31g6Ei8Bl
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 2880x3600 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# lines = cv.HoughLines(img_bin, 1, np.pi / 180, 150, None, 0, 0)\n",
|
|
|
|
"final = road.copy()\n",
|
|
|
|
"linesP = cv.HoughLinesP(img_bin, 1, np.pi / 180, 50, None, 30, 10)\n",
|
|
|
|
"higher_point = final.shape[0]\n",
|
|
|
|
"lower_point = 350\n",
|
|
|
|
" \n",
|
|
|
|
"if linesP is not None:\n",
|
|
|
|
" for i in range(0, len(linesP)):\n",
|
|
|
|
" l = linesP[i][0]\n",
|
|
|
|
"\n",
|
|
|
|
" a = (l[3] - l[1]) / (l[2] - l[0])\n",
|
|
|
|
" b = l[3] - ( ((l[3] - l[1]) * l[2]) / (l[2] - l[0]) )\n",
|
|
|
|
" \n",
|
|
|
|
" \n",
|
|
|
|
" higher_x = int((higher_point - b) / a)\n",
|
|
|
|
" \n",
|
|
|
|
" lower_x = int((lower_point - b) / a)\n",
|
|
|
|
" \n",
|
|
|
|
" cv.line(final, (higher_x, higher_point), (lower_x, lower_point), (0,0,255), 3, cv.LINE_AA)\n",
|
|
|
|
"\n",
|
|
|
|
"alpha = 0.5\n",
|
|
|
|
"result = cv.addWeighted(final, alpha, road, 1 - alpha, 0)\n",
|
|
|
|
" \n",
|
|
|
|
"\n",
|
|
|
|
"plt.figure(figsize=(40,50))\n",
|
|
|
|
"plt.subplot(121)\n",
|
|
|
|
"plt.imshow(result[:,:,::-1])\n",
|
|
|
|
"plt.title(\"Image\")"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"id": "399d6a41",
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
2021-11-28 20:35:20 +01:00
|
|
|
"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
|
|
|
|
}
|