Skip to content

Commit

Permalink
docs: update the jupiter notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanchristopheruel committed Aug 22, 2024
1 parent 8596c5c commit 664e45f
Showing 1 changed file with 79 additions and 81 deletions.
160 changes: 79 additions & 81 deletions notebooks/pose_extimation_example.ipynb
Original file line number Diff line number Diff line change
@@ -1,66 +1,53 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"source": [
"# Copyright (c) Innoptech"
],
"execution_count": null,
"metadata": {
"id": "ericuX_zTMmu"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"# Copyright (c) Innoptech"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "qP7Z5v82SqKM"
},
"source": [
"# **OpenFDCM: Fast Template Matching for Object Pose Estimation**\n",
"\n",
"### **Overview**\n",
"**OpenFDCM** (Fast Directional Chamfer Matching) is a high-performance, production-ready, fast template matching library designed to **enable object pose estimation**, particularly in industrial and manufacturing environments. This library excels at matching templates while remaining invariant to **translation** and **rotation** in the image plane.\n",
"\n",
"The library is very extensible. One could easily implement a CUDA module for example."
],
"metadata": {
"id": "qP7Z5v82SqKM"
}
"**OpenFDCM** (Fast Directional Chamfer Matching) is a high-performance, production-ready, fast template matching library designed to **enable object pose estimation**, particularly in industrial and manufacturing environments. This library excels at matching templates while remaining invariant to **translation** and **rotation** in the image plane."
]
},
{
"cell_type": "markdown",
"source": [
"This Jupyter notebook focuses solely on documenting the fast template matching algorithms provided by OpenFDCM. For complete 6-DOF pose estimation, please refer to the repository's [README.md](https://github.com/Innoptech/OpenFDCM/blob/main/README.md). It is important to note that the output of OpenFDCM generates a comprehensive list of match candidates, which should be refined using the multiview techniques discussed."
],
"metadata": {
"id": "SEANPaPYq1bx"
}
},
"source": [
"This Jupyter notebook focuses solely on documenting the fast template matching algorithms provided by OpenFDCM. For complete 6-DOF pose estimation, please refer to the repository's [README.md](https://github.com/Innoptech/OpenFDCM/blob/main/README.md). It is important to note that the output of OpenFDCM generates a comprehensive list of match candidates, which should be refined using the multiview techniques discussed."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Xz-qbxAxU87F"
},
"source": [
"<a target=\"_blank\" href=\"https://colab.research.google.com/drive/1AtXjSrxsd42BVli3xbOR2b8pRkfyrb0m?usp=sharing\">\n",
"<img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\">\n",
"</a>"
],
"metadata": {
"id": "Xz-qbxAxU87F"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "dg-eqlAScYdS"
},
"source": [
"\n",
"### Environment Set-up\n",
Expand All @@ -69,21 +56,18 @@
"\n",
"* If running from Google Colab, set using_colab=True below and run the cell.\n",
"\n"
],
"metadata": {
"id": "dg-eqlAScYdS"
}
]
},
{
"cell_type": "code",
"source": [
"using_colab = True"
],
"execution_count": null,
"metadata": {
"id": "yvNJf9AldYcf"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"using_colab = True"
]
},
{
"cell_type": "code",
Expand All @@ -104,15 +88,20 @@
},
{
"cell_type": "markdown",
"source": [
"### Set-up"
],
"metadata": {
"id": "BRRooNI7XBHd"
}
},
"source": [
"### Set-up"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Weudi63Cd7eE"
},
"outputs": [],
"source": [
"import time\n",
"import cv2\n",
Expand All @@ -121,15 +110,15 @@
"import matplotlib.pyplot as plt\n",
"import openfdcm\n",
"print(\"OpenFDCM version:\", openfdcm.__version__)"
],
"metadata": {
"id": "Weudi63Cd7eE"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "KGKOy8-LW_fJ"
},
"outputs": [],
"source": [
"def apply_transform(template: np.ndarray, transform: np.ndarray):\n",
" num_lines = template.shape[1]\n",
Expand Down Expand Up @@ -161,15 +150,13 @@
"\n",
"def find_files_recursive(directory, extension):\n",
" return list(Path(directory).rglob(f\"*{extension}\"))"
],
"metadata": {
"id": "KGKOy8-LW_fJ"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Z_ykbvfVf7Bp"
},
"source": [
"### Templates sampling\n",
"The template sampling consists in a fast OpenGL sythetic-rendered multiflash depth edge extraction. Further details can be seen in my master thesis (Ref to come).\n",
Expand All @@ -179,37 +166,39 @@
"</p>\n",
"\n",
"For the sake of simplification, the templates have already been generated in this example."
],
"metadata": {
"id": "Z_ykbvfVf7Bp"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UXA0Q0sRywyb"
},
"source": [
"### Template matching\n",
"**Please note that Google Colab CPUs are quite slow.** \n",
"**Also note that the shown matches should be refined using the multiview techniques discussed.**"
],
"metadata": {
"id": "UXA0Q0sRywyb"
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "caD6EIBOy6K_"
},
"outputs": [],
"source": [
"from psutil import *\n",
"# This line will return the CPU info\n",
"!cat /proc/cpuinfo"
],
"metadata": {
"id": "caD6EIBOy6K_"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "92OBUa4pgUX3"
},
"outputs": [],
"source": [
"for imagepth in find_files_recursive(\"./OpenFDCM/examples/assets\", \".jpg\"):\n",
" scene_dir: Path = imagepth.parent\n",
Expand Down Expand Up @@ -251,12 +240,21 @@
" if sorted_matches:\n",
" best_matches = sorted_matches[:10]\n",
" display_best_match(scene_image, best_matches, templates)"
],
"metadata": {
"id": "92OBUa4pgUX3"
},
"execution_count": null,
"outputs": []
]
}
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 664e45f

Please sign in to comment.