mirror of
https://github.com/opencv/opencv.git
synced 2026-07-26 22:03:04 +04:00
fc3803c67b
Dedicated pointcloud module #29224 OpenCV contrib: https://github.com/opencv/opencv_contrib/pull/4134 ### 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 - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
32 lines
956 B
Python
32 lines
956 B
Python
#!/usr/bin/env python
|
|
|
|
import os
|
|
import numpy as np
|
|
import math
|
|
import unittest
|
|
import cv2 as cv
|
|
|
|
from tests_common import NewOpenCVTests
|
|
|
|
class octree_test(NewOpenCVTests):
|
|
def test_octree_basic_test(self):
|
|
pointCloudSize = 1000
|
|
resolution = 0.0001
|
|
scale = 1 << 20
|
|
|
|
pointCloud = np.random.randint(-scale, scale, size=(pointCloudSize, 3)) * (10.0 / scale)
|
|
pointCloud = pointCloud.astype(np.float32)
|
|
|
|
octree = cv.Octree_createWithResolution(resolution, pointCloud)
|
|
|
|
restPoint = np.random.randint(-scale, scale, size=(1, 3)) * (10.0 / scale)
|
|
restPoint = [restPoint[0, 0], restPoint[0, 1], restPoint[0, 2]]
|
|
|
|
self.assertTrue(octree.isPointInBound(restPoint))
|
|
self.assertFalse(octree.deletePoint(restPoint))
|
|
self.assertTrue(octree.insertPoint(restPoint))
|
|
self.assertTrue(octree.deletePoint(restPoint))
|
|
|
|
if __name__ == '__main__':
|
|
NewOpenCVTests.bootstrap()
|