mirror of
https://github.com/opencv/opencv.git
synced 2024-12-12 23:49:36 +08:00
f96111ef05
PLY mesh support #24961 **Warning:** The PR changes exising API. Fixes #24960 Connected PR: [#1145@extra](https://github.com/opencv/opencv_extra/pull/1145) ### Changes * Adds faces loading from and saving to PLY files * Fixes incorrect PLY loading (see issue) * Adds per-vertex color loading / saving ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
24 lines
573 B
Python
24 lines
573 B
Python
import numpy as np
|
|
import cv2 as cv
|
|
|
|
vertices, _ = cv.loadPointCloud("../data/teapot.obj")
|
|
vertices = np.squeeze(vertices, axis=1)
|
|
print(vertices)
|
|
|
|
color = [1.0, 1.0, 0.0]
|
|
colors = np.tile(color, (vertices.shape[0], 1))
|
|
obj_pts = np.concatenate((vertices, colors), axis=1)
|
|
obj_pts= np.float32(obj_pts)
|
|
|
|
cv.viz3d.showPoints("window", "points", obj_pts)
|
|
cv.viz3d.setGridVisible("window", True)
|
|
|
|
cv.waitKey(0)
|
|
|
|
vertices, indices = cv.loadMesh("../data/teapot.obj")
|
|
vertices = np.squeeze(vertices, axis=1)
|
|
|
|
cv.viz3d.showMesh("window", "mesh", vertices, indices)
|
|
|
|
cv.waitKey(0)
|