trap/test_homography.ipynb

398 lines
4.2 MiB
Text
Raw Normal View History

2023-12-06 10:21:43 +01:00
{
"cells": [
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 1,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [],
"source": [
"import cv2\n",
"import numpy as np\n",
"from PIL import Image\n",
2024-01-23 15:54:09 +01:00
"import matplotlib.pyplot as plt\n",
"from pathlib import Path"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 2,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-01-23 15:54:09 +01:00
"img_src = \"../DATASETS/hof/webcam20231103-2.png\""
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 3,
2024-01-23 15:54:09 +01:00
"metadata": {},
"outputs": [],
"source": [
"img_path = Path(img_src)\n",
"output_path = img_path.with_stem(img_path.stem + '-homography').with_suffix('.txt')\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Setup"
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 4,
2024-01-23 15:54:09 +01:00
"metadata": {},
"outputs": [],
"source": [
"from os import PathLike\n",
"\n",
"def render_projection(src, dst, img: PathLike, points = []):\n",
2023-12-06 10:21:43 +01:00
" x_min = min(dst[:,0])\n",
" if x_min < 0:\n",
" dst[:,0] += x_min * -1\n",
" y_min = min(dst[:,1])\n",
" if y_min < 0:\n",
" dst[:,1] += y_min * -1\n",
"\n",
2024-04-25 16:31:51 +02:00
" # dst[:,0] += 1500\n",
" # dst[:,1] += 600\n",
2023-12-06 10:21:43 +01:00
"\n",
"\n",
" # print(\"from\", src)\n",
" # print(\"to\", dst)\n",
"\n",
" H, status = cv2.findHomography(src,dst)\n",
" f, axes = plt.subplots(1, 2, figsize=(16,8))\n",
"\n",
2024-01-23 15:54:09 +01:00
" img = cv2.imread(str(img))\n",
2023-12-06 10:21:43 +01:00
" img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n",
"\n",
" for i, p in enumerate(src):\n",
" cv2.circle(img, p, 3, (0,255,0), 0)\n",
" cv2.putText(img, str(i), p, cv2.FONT_HERSHEY_COMPLEX, .5, (0,255,0))\n",
"\n",
" # print (H)\n",
" dst = cv2.warpPerspective(img,H,(2500,1920))\n",
" axes[0].imshow(img)\n",
" axes[1].imshow(dst)\n",
2024-01-23 15:54:09 +01:00
"\n",
" def onclick(event):\n",
" points.append([event.xdata,event.ydata])\n",
" f.canvas.mpl_connect('button_press_event', onclick)\n",
"\n",
2023-12-06 10:21:43 +01:00
" plt.tight_layout()\n",
" plt.show()\n",
" # display(Image.fromarray(img).resize((600,600)), Image.fromarray(dst).resize((600,600)))\n",
" return H"
]
},
{
2024-01-23 15:54:09 +01:00
"cell_type": "markdown",
2023-12-06 10:21:43 +01:00
"metadata": {},
"source": [
2024-01-23 15:54:09 +01:00
"# First recording"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 5,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [
{
"data": {
2024-04-25 16:31:51 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABjYAAAJnCAYAAAA0vWrlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9yY8tWXrdC/6+3ZjZ6dz9ut97IyIjkyIpVkn1gAL1oIbQXIBmNakCNCoIby5NOBInEjTSVAPpj9CoUEANNBALVQ+vxPf0JFVRFBsxGzIzI+L23pzOmt18Ndh2jvtNMthlUhT59i/gcd1Pa7bN/AD+LVtriaoqlUqlUqlUKpVKpVKpVCqVSqVSqVQqfw4wf9YbUKlUKpVKpVKpVCqVSqVSqVQqlUql8kelChuVSqVSqVQqlU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VYa+ffXMiay/HKxSXkrMV1LbZbIK4BYximSNctaZwjxUSIkSFGjDVcbtZ0XYuKsFwuWXRdcceE+fyTIhyuFi05jKSxRzRyuVnz4vkLjvsjzjjGfmT78MD3vvMD3rx6/8f7OKpUKpVKpXKmOjYqlUqlUqlUKpXKXzh+8Rd/kb//9/8+f+Nv/A3+1t/6W/zzf/7PORwO/A//w//wx3qd03X0oGRNdF3L5eUF1haXBpRoG40JnSZs26F6Gk8LORs0O8gCYXZYyDxozpmcEllzie+xHS+ON3S/5jEI6nMZxooU9wAGZxxGDDllpimiqlhb4n/Q2bWQIWfFWksIlMvZTHnPRCZqJgtYa/HWktRAghwj1liMNRhr8V1L2za0bYudh9bizCzUZEiKihJUMdazaJeMEVrrkDxhckalxCLFnFl
2023-12-06 10:21:43 +01:00
"text/plain": [
"<Figure size 1600x800 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
2024-04-25 16:31:51 +02:00
"array([[ 2.14811662e+00, -6.24253612e-01, -1.76917928e+03],\n",
" [-3.00384000e-01, 4.54296024e+00, -2.95121358e+02],\n",
2024-01-23 15:54:09 +01:00
" [-2.89572527e-04, 1.97232411e-03, 1.00000000e+00]])"
2023-12-06 10:21:43 +01:00
]
},
2024-04-25 16:31:51 +02:00
"execution_count": 5,
2023-12-06 10:21:43 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"src = np.array([[924, 341],\n",
" [988, 343],\n",
" [908,125],\n",
" [941, 404],])\n",
"\n",
2024-01-23 15:54:09 +01:00
"dst = np.array([[2,0],\n",
2023-12-06 10:21:43 +01:00
"[100,0],\n",
2024-01-23 15:54:09 +01:00
"[105, -695],\n",
2023-12-06 10:21:43 +01:00
"[0, 130]])\n",
"\n",
"\n",
2024-04-25 16:31:51 +02:00
"render_projection(src, dst, img_path)"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 6,
2023-12-06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lOzxqxe48JjpMPLFixcYnjff/AzvhWG1Xu4rt9xvjrriWe47Ob0iMOhiIIbAarXiwYMHXF9est/uUC/0XQQzTOvrUgXDgyxCWD1otBhaMlPJmBNKTijGMAw4B94Lq80FXhWdCxIdF5crYuzYfdwTH0RevHyJ5sScJzYXG5z33H36xOGwJ8+JLkTyPLPp1nQXPXHlGIY1eVLSsXBztyNPn0jHIx6j80IfAglB1TArrIeezWbNrIWEIV2Hd4Fxt2cVO0IIRO8RF3BWwARvRvSB6wePCd3A9fUl+/0WK4nZOw5x5psPHygGz5895urqApV69vPxyGF7JMSO1WpNLpmbT58Yp5GSMlIS03wH2jFZ4vd+/PMmajQajcafMv6XRMH+0UFVjUaj0Wg0Go1Go/Eto+s6/u1/+9/mr//1v37+mqry1//6X+cv/aW/9M/1WKp63gl+/s8rAXOCAoqgVl0R3tWhfS6ZOWfGUkhmlNNPyrK7XAvTNLI/Hsk5Y1ZIeaJYBozgImpQTBAfMAFdhrcxdjgXyAbFHPgek7pzW9XIqiCLqGGLY4OTsHGPLR4No4oaYOefLJpxXgixQ/V+GKsl12NyHcVAUdTqYP7+t886Sv2HuPMAH7l3i4jdH48DpulI3w+ID+hno+AqHiklT3z88A63CDH1uihZlcM4UkxxTsglV5dHUbxzeO+X62jgPN2wAnHE4NA0M00jqkoMkZwTIiwikifGnsNxYn8cuRce7oUhqZedYdXz5/+Vf4X/4+/8JZ48fszH96+hHOmj8ls//C7fefkFIcb6WkVwsrhn7J8tapyu0NnBYeCz4wfffBdf6usR5/DBU0rieNyRS6pay+l6WEG1LEKTw7mA73pC6HDOk4qSs2DJ4cXjvcf7SMmZPCVKUjQLmCDOowr
2023-12-06 10:21:43 +01:00
"text/plain": [
"<Figure size 1600x800 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
2024-01-23 15:54:09 +01:00
"name": "stdout",
"output_type": "stream",
"text": [
2024-04-25 16:31:51 +02:00
"[[ 2.28441941e+00 -7.25403562e-03 -1.41218482e+03]\n",
" [-2.66305397e-02 3.73547277e+00 -5.09931039e+02]\n",
" [-4.62076533e-05 1.56722238e-03 1.00000000e+00]]\n"
2024-01-23 15:54:09 +01:00
]
2023-12-06 10:21:43 +01:00
}
],
"source": [
"\n",
"src = np.array([[924, 341],\n",
" [988, 343],\n",
2024-01-23 15:54:09 +01:00
" [810, 330],\n",
" [620, 325],\n",
" [908,143],\n",
" [1072,616],\n",
" [941, 404],\n",
" \n",
" ])\n",
2023-12-06 10:21:43 +01:00
"\n",
"dst = np.array([[0,0],\n",
2024-01-23 15:54:09 +01:00
"[97,0],\n",
"[-160,-33],\n",
"[-460,-33],\n",
"[105, -500],\n",
"[87, 420],\n",
"[-2, 112]\n",
2024-04-25 16:31:51 +02:00
"], dtype=np.float64)\n",
2023-12-06 10:21:43 +01:00
"\n",
"\n",
2024-01-23 15:54:09 +01:00
"H = render_projection(src, dst, img_path)\n",
"print(H)\n",
"# np.savetxt(output_path, H, delimiter=\",\")\n",
"# cv2.imwrite(\"/tmp/test.jpg\", dst)"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 7,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [
{
"data": {
2024-04-25 16:31:51 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABjYAAAJnCAYAAAA0vWrlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9aaxt63nQe/7fZowx+9Xuvjmdfc7xsR2b2I7xzSUxkEqAqOpGlw+REJCkpCCQEwlcQsIoSpQgcIkPKB9IgVQl4IqQUlQfKEqBigAXhEoRErBJ4+4cn2af3a619upnO8Z4m/rwvmOufRKLXC6Jj3d4ftb22Xutueaac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OwMgO3t7Xd8/J/8k3/C7u4uH/jAB/jMZz7DYrFYf+5XfuVX+OAHP8iVK1fWH/ue7/kezs/P+dKXvvR1v09d15yfn7/jjxBCCCGEEOKb07uS2Pg7f+fv8MM//MP80A/9EK+88gp//+//fQaDAf/gH/yDd+PhCCGEEEIIIb4JhRD4y3/5L/Pt3/7tfOADH1h//M/8mT/Dz/7sz/Jv/s2/4TOf+Qz/+B//Y/7sn/2z68/v7e29I6kBrP+9t7f3db/XZz/7WTY2NtZ/bt269fvwjIQQQgghhBC/F77hMzaapuHzn/88n/nMZ9Yf01rzXd/1XfzKr/zK1/2auq6p63r97xACx8fH7OzsoJT6fX/MQgghhBBC/Pcuxsh0OuX69eto/Y3ZH/WpT32KL37xi/zyL//yOz7+F/7CX1j//YMf/CDXrl3jj//xP84bb7zBCy+88L/pe33mM5/h05/+9Prf5+fnktwQQgghhBDim9Q3PLFxeHiI9/7r7qD66le/+nW/5rOf/Sw/+ZM/+Y14eEIIIYQQQoj/gnv
2023-12-06 10:21:43 +01:00
"text/plain": [
"<Figure size 1600x800 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
2024-01-23 15:54:09 +01:00
"name": "stdout",
"output_type": "stream",
"text": [
2024-04-25 16:31:51 +02:00
"[[ 2.33261071e-02 -7.18489563e-05 -1.44258091e+01]\n",
" [-1.58777686e-04 3.80969604e-02 -5.30388927e+00]\n",
" [-2.36557580e-05 1.59322903e-03 1.00000000e+00]]\n"
2024-01-23 15:54:09 +01:00
]
2023-12-06 10:21:43 +01:00
}
],
"source": [
2024-04-25 16:31:51 +02:00
"scaled_dst = dst / 100\n",
"H = render_projection(src, scaled_dst, img_path)\n",
2024-01-23 15:54:09 +01:00
"print(H)\n",
2024-04-25 16:31:51 +02:00
"# np.savetxt(output_path, H, delimiter=\",\")\n"
2023-12-06 10:21:43 +01:00
]
},
{
2024-01-23 15:54:09 +01:00
"cell_type": "markdown",
2023-12-06 10:21:43 +01:00
"metadata": {},
"source": [
2024-01-23 15:54:09 +01:00
"# second recording"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 8,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [],
"source": [
2024-01-23 15:54:09 +01:00
"img_src = \"../DATASETS/hof/webcam20240110.png\"\n",
"img_path = Path(img_src)\n",
"output_path = img_path.with_stem(img_path.stem + '-homography').with_suffix('.txt')"
2023-12-06 10:21:43 +01:00
]
},
{
"cell_type": "code",
2024-04-25 16:31:51 +02:00
"execution_count": 9,
2023-12-06 10:21:43 +01:00
"metadata": {},
"outputs": [
{
"data": {
2024-04-25 16:31:51 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABjYAAAJnCAYAAAA0vWrlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9SbMsy3WeDT7L3SMiM3d72tugB0gREqkSy0SRP+BTmb7JZ6aZhjLNqQlHolmVZBppqoH0I1Rm31w1YJmxKVICRVINWwEXF7jt6fbZbTYR4e6rBssjMvdtQABSFQXQH2DjnJM7m2jTDOv1931FVZVKpVKpVCqVSqVSqVQqlUqlUqlUKpWfANxf9QZUKpVKpVKpVCqVSqVSqVQqlUqlUqn8sFRho1KpVCqVSqVSqVQqlUqlUqlUKpXKTwxV2KhUKpVKpVKpVCqVSqVSqVQqlUql8hNDFTYqlUqlUqlUKpVKpVKpVCqVSqVSqfzEUIWNSqVSqVQqlUqlUqlUKpVKpVKpVCo/MVRho1KpVCqVSqVSqVQqlUqlUqlUKpXKTwxV2KhUKpVKpVKpVCqVSqVSqVQqlUql8hNDFTYqlUqlUqlUKpVKpVKpVCqVSqVSqfzEUIWNSqVSqVQqlUqlUqlUKpVKpVKpVCo/MVRho1KpVCqVSqVSqVQqlUqlUqlUKpXKTwxV2K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MrY98ShRzXZa72aU6OIedN1NI4RXxxTwTua4EhpZIwmEh4tGx6fC63bcNMnRlnx8NEb5Ky03YLNbsvLly8tC7zc294HxDm03KPMf0JoPG0T7NxktdfMwoaz88VeoNB7+33o1viMa+dzRI17Lpe
2023-12-06 10:21:43 +01:00
"text/plain": [
"<Figure size 1600x800 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
2024-01-23 15:54:09 +01:00
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2024-04-25 16:31:51 +02:00
"[[ 2.11102794e+00 -9.31080334e-02 -1.32994099e+03]\n",
" [ 6.52086770e-02 3.41420130e+00 -4.80260705e+02]\n",
" [-7.87097747e-05 1.44776415e-03 1.00000000e+00]]\n"
2024-01-23 15:54:09 +01:00
]
2023-12-06 10:21:43 +01:00
}
],
"source": [
"\n",
2024-01-23 15:54:09 +01:00
"src = np.array([\n",
" [954, 326], # 0\n",
" [1010, 320], # 1\n",
" [840, 325], # 2\n",
" [645, 317], # 3\n",
" [930,123], # 4\n",
" [1115,598], # 5\n",
" [970, 390], # 6\n",
2023-12-06 10:21:43 +01:00
" ])\n",
"\n",
"dst = np.array([[0,0],\n",
"[97,0],\n",
"[-160,-33],\n",
"[-460,-33],\n",
"[105, -500],\n",
"[87, 420],\n",
"[-2, 112]\n",
2024-04-25 16:31:51 +02:00
"], dtype=np.float64)\n",
2023-12-06 10:21:43 +01:00
"\n",
2024-04-25 16:31:51 +02:00
"H = render_projection(src, dst, img_path)\n",
"print(H)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABjYAAAJnCAYAAAA0vWrlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/NK7nSAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOz9a6htW1rfjf6e1lrvfdzmZc25bnvtS5XRE2OpUfBSSCAIESURXnzJByEkUT8YEkohKQikgujRkNQ5+ZDjh0gCh5MEYgQ/hYAESVIYQ94IEiUnR8WYKq3at3WZa97nuPRLa+18aK33McZcc+29S6tq19Tnt5l7zTkuffTeeuttjPH/PxeJMUYURVEURVEURVEURVEURVEURVFuAebD3gFFURRFURRFURRFURRFURRFUZQPihobiqIoiqIoiqIoiqIoiqIoiqLcGtTYUBRFURRFURRFURRFURRFURTl1qDGhqIoiqIoiqIoiqIoiqIoiqIotwY1NhRFURRFURRFURRFURRFURRFuTWosaEoiqIoiqIoiqIoiqIoiqIoyq1BjQ1FURRFURRFURRFURRFURRFUW4NamwoiqIoiqIoiqIoiqIoiqIoinJrUGNDURRFURRFURRFURRFURRFUZRbgxobiqIoiqIoiqIoiqIoiqIoiqLcGtTYUBRFURRFURTljyU/93M/x0c/+lFGoxEf//jH+fVf//UPe5cURVEURVEURfkSoMaGoiiKoiiKoih/7PjFX/xFPvnJT/JTP/VT/OZv/ibf8i3fwvd93/fx7NmzD3vXFEVRFEVRFEX5IyIxxvhh74SiKIqiKIqiKMqXko9//ON8x3d8B//0n/5TAEIIvP766/z4j/84f+/v/b0Pee8URVEURVEURfmj4D7sHVAURVEURVEURflS0jQNv/Ebv8GnPvWp4TZjDN/zPd/Dr/3ar934nLquqet6+DuEwMnJCYeHh4jIl32fFUVRFEVRFOVPOjFGLi8vefToEca8d7EpNTYURVEURVEURfljxfPnz/He8+DBg63bHzx4wO/+7u/e+JxPf/rT/PRP//RXYvcURVEURVEURXkP3nrrLV577bX3fIz22FAURVEURVEU5U88n/rUpzg/Px9+3nzzTQA+/f/8f/B//p//x4e8d4qiKIqiKIryJ4ednZ33fYxmbCiKoiiKoiiK8seKu3fv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
"text/plain": [
"<Figure size 1600x800 with 2 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 2.07873681e-02 -9.15620699e-04 -1.30923858e+01]\n",
" [ 5.63969727e-04 3.36566989e-02 -4.66048256e+00]\n",
" [-9.42743714e-05 1.43173299e-03 1.00000000e+00]]\n",
"../DATASETS/hof/webcam20240110-homography.txt\n"
]
}
],
"source": [
"\n",
"scaled_dst = dst / 100\n",
"\n",
"H = render_projection(src, scaled_dst, img_path)\n",
2024-01-23 15:54:09 +01:00
"print(H)\n",
2024-04-25 16:31:51 +02:00
"print(output_path)\n",
"# np.savetxt(output_path, H, delimiter=\",\")"
2024-01-23 15:54:09 +01:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Compare\n",
2023-12-06 10:21:43 +01:00
"\n",
2024-01-23 15:54:09 +01:00
"Compare the different input images and homeographies."
2023-12-06 10:21:43 +01:00
]
2024-04-25 16:31:51 +02:00
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-13.092385786242692 < x < 15.370183792197755\n",
"-4.660482560250155 < y < 10.624264991237176\n"
]
}
],
"source": [
"# cv2.perspectiveTransform(np.array([[[530, 307.56]]]),H)\n",
"coords = cv2.perspectiveTransform(np.array([[[0., 0.], [1280., 0], [0, 720], [1280, 720]]]),H)\n",
"xs = coords[0,:,0]\n",
"ys = coords[0,:,1]\n",
"\n",
"\n",
"minx, maxx = min(xs), max(xs)\n",
"miny, maxy = min(ys), max(ys)\n",
"\n",
"print(f\"{minx} < x < {maxx}\")\n",
"print(f\"{miny} < y < {maxy}\")"
]
2023-12-06 10:21:43 +01:00
}
],
"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.10.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}