add 3D scatter plot

This commit is contained in:
Laureηt 2023-01-20 10:55:00 +01:00
parent 73962d26be
commit 7414fd0eba
Signed by: Laurent
SSH key fingerprint: SHA256:kZEpW8cMJ54PDeCvOhzreNr4FSh6R13CMGH/POoO8DI
3 changed files with 11 additions and 6 deletions

View file

@ -15,6 +15,8 @@
poetry poetry
python3 python3
python310Packages.numpy python310Packages.numpy
tk
python310Packages.matplotlib
(python310Packages.opencv4.override { (python310Packages.opencv4.override {
enableGtk2 = true; enableGtk2 = true;
gtk2 = pkgs.gtk2; gtk2 = pkgs.gtk2;

View file

@ -11,6 +11,7 @@ python = ">=3.8.1,<4.0"
rich = "^12.6.0" rich = "^12.6.0"
opencv-python = "^4.6.0.66" opencv-python = "^4.6.0.66"
fake-bpy-module-latest = "^20230118" fake-bpy-module-latest = "^20230118"
matplotlib = "^3.6.3"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
Flake8-pyproject = "^1.1.0" Flake8-pyproject = "^1.1.0"

View file

@ -2,6 +2,7 @@ import cv2
import numpy as np import numpy as np
from itertools import product from itertools import product
import pickle import pickle
import matplotlib.pyplot as plt
VOXEL_SIZE = 3e-2 VOXEL_SIZE = 3e-2
X_MIN, X_MAX = -1.5, 1.5 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*is_in[k], 0, 255*(not is_in[k])))
cv2.circle(frame, (cam_point[0], cam_point[1]), 2, (255, 0, 255)) 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): for k in range(nb_frame):
frame = cv2.imread(f'/tmp/masks/Image{k:04}.png') 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.imshow('Frame', frame)
cv2.waitKey(0) 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()