Update execution counts in find_cute_box_with_image.ipynb and adjust coordinate transformations for OpenGL to Blender compatibility.

This commit is contained in:
2025-04-24 14:23:56 +08:00
parent 801485e6d5
commit 733c6f8670

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 77, "execution_count": 117,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -29,7 +29,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 78, "execution_count": 118,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -42,7 +42,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 79, "execution_count": 119,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -54,7 +54,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 80, "execution_count": 120,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -66,7 +66,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 81, "execution_count": 121,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -88,7 +88,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 82, "execution_count": 122,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -121,7 +121,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 83, "execution_count": 123,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -192,7 +192,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 86, "execution_count": 126,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -298,16 +298,13 @@
"id_to_3d_coords = {marker.id: marker_to_3d_coords(marker, m) for marker in output_markers}\n", "id_to_3d_coords = {marker.id: marker_to_3d_coords(marker, m) for marker in output_markers}\n",
"# note that the glb is Y up\n", "# note that the glb is Y up\n",
"# when visualizing with matplotlib, it's Z up\n", "# when visualizing with matplotlib, it's Z up\n",
"# GLTF → Blender: (X, Y, Z) → (X, -Z, Y)\n",
"OPEN_GL_TO_BLENDER = np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])\n", "OPEN_GL_TO_BLENDER = np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])\n",
"# Blender → GLTF: (X, Y, Z) → (X, Z, -Y)\n",
"BLENDER_TO_OPEN_GL = np.array([[1, 0, 0], [0, 0, 1], [0, -1, 0]])\n",
"display(np.linalg.inv(OPEN_GL_TO_BLENDER)) # should be the same" "display(np.linalg.inv(OPEN_GL_TO_BLENDER)) # should be the same"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 93, "execution_count": 131,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -370,10 +367,10 @@
" assert face is not None\n", " assert face is not None\n",
" color = face.color\n", " color = face.color\n",
" for i in range(4):\n", " for i in range(4):\n",
" p1 = corners[i]\n", " p1 = OPEN_GL_TO_BLENDER @ corners[i]\n",
" p2 = corners[(i + 1) % 4]\n", " p2 = OPEN_GL_TO_BLENDER @ corners[(i + 1) % 4]\n",
" ax.plot(*zip(p1, p2), color=color)\n", " ax.plot(*zip(p1, p2), color=color)\n",
" center = corners.mean(axis=0)\n", " center = OPEN_GL_TO_BLENDER @ corners.mean(axis=0)\n",
" ax.scatter(*center, color=color)\n", " ax.scatter(*center, color=color)\n",
" ax.text(*center, str(tag_id), fontsize=9, color=\"black\") # type: ignore\n", " ax.text(*center, str(tag_id), fontsize=9, color=\"black\") # type: ignore\n",
"\n", "\n",