diff --git a/flake.nix b/flake.nix index 4d63a5e..8a4599a 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,8 @@ poetry python3 python310Packages.numpy + tk + python310Packages.matplotlib (python310Packages.opencv4.override { enableGtk2 = true; gtk2 = pkgs.gtk2; diff --git a/pyproject.toml b/pyproject.toml index 6fff4c6..5ff338e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ python = ">=3.8.1,<4.0" rich = "^12.6.0" opencv-python = "^4.6.0.66" fake-bpy-module-latest = "^20230118" +matplotlib = "^3.6.3" [tool.poetry.group.dev.dependencies] Flake8-pyproject = "^1.1.0" diff --git a/src/main.py b/src/main.py index 38cbf95..5fa6190 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,7 @@ import cv2 import numpy as np from itertools import product import pickle +import matplotlib.pyplot as plt VOXEL_SIZE = 3e-2 X_MIN, X_MAX = -1.5, 1.5 @@ -41,12 +42,6 @@ for k in range(nb_frame): # cv2.circle(frame, (cam_point[0], cam_point[1]), 2, (255*is_in[k], 0, 255*(not is_in[k]))) cv2.circle(frame, (cam_point[0], cam_point[1]), 2, (255, 0, 255)) - print(points.shape) - cv2.imshow('Frame', frame) - cv2.waitKey(0) - -print("result") - for k in range(nb_frame): frame = cv2.imread(f'/tmp/masks/Image{k:04}.png') @@ -63,3 +58,10 @@ for k in range(nb_frame): cv2.imshow('Frame', frame) cv2.waitKey(0) + +# 3D plot the result +fig = plt.figure() +ax = fig.add_subplot(111, projection='3d') +ax.scatter(points[:,0], points[:,1], points[:,2], c='r', marker='o') +plt.axis("equal") +plt.show()