├── .github
├── FUNDING.yml
└── workflows
│ └── build.yml
├── .gitignore
├── .swiftpm
└── xcode
│ └── package.xcworkspace
│ └── contents.xcworkspacedata
├── Example
├── Example.xcodeproj
│ ├── project.pbxproj
│ └── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── swiftpm
│ │ └── Package.resolved
└── Example
│ ├── Assets.xcassets
│ ├── AccentColor.colorset
│ │ └── Contents.json
│ ├── AppIcon.appiconset
│ │ └── Contents.json
│ └── Contents.json
│ ├── ContentView.swift
│ ├── ExampleApp.swift
│ ├── Info.plist
│ ├── Preview Content
│ └── Preview Assets.xcassets
│ │ └── Contents.json
│ └── fragment.ply
├── LICENSE
├── Package.resolved
├── Package.swift
├── Package.swift.in
├── README.md
├── Scripts
├── ci.sh
├── package.sh
└── toolchain.sh
├── Sources
├── LinkOpen3D
│ └── Link.m
└── Open3DSupport
│ ├── Open3DSupport.swift
│ └── site-packages
│ └── open3d
│ ├── __init__.py
│ ├── _build_config.py
│ ├── core.py
│ ├── cpu
│ └── pybind.cpython-38-darwin.so
│ ├── ml
│ ├── __init__.py
│ ├── configs.py
│ ├── contrib
│ │ └── __init__.py
│ ├── datasets.py
│ ├── tf
│ │ ├── __init__.py
│ │ ├── configs.py
│ │ ├── dataloaders.py
│ │ ├── datasets.py
│ │ ├── layers
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── modules.py
│ │ ├── ops
│ │ │ └── __init__.py
│ │ ├── pipelines.py
│ │ ├── python
│ │ │ ├── layers
│ │ │ │ ├── convolutions.py
│ │ │ │ ├── neighbor_search.py
│ │ │ │ └── voxel_pooling.py
│ │ │ └── ops
│ │ │ │ ├── gradients.py
│ │ │ │ ├── lib.py
│ │ │ │ └── ops.py.in
│ │ └── vis.py
│ ├── torch
│ │ ├── __init__.py
│ │ ├── classes
│ │ │ ├── __init__.py
│ │ │ └── ragged_tensor.py
│ │ ├── configs.py
│ │ ├── dataloaders.py
│ │ ├── datasets.py
│ │ ├── layers
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── modules.py
│ │ ├── ops
│ │ │ └── __init__.py
│ │ ├── pipelines.py
│ │ ├── python
│ │ │ ├── layers
│ │ │ │ ├── convolutions.py
│ │ │ │ ├── neighbor_search.py
│ │ │ │ └── voxel_pooling.py
│ │ │ ├── ops.py.in
│ │ │ └── return_types.py.in
│ │ └── vis.py
│ ├── utils.py
│ └── vis.py
│ ├── visualization
│ ├── __init__.py
│ ├── __main__.py
│ ├── _external_visualizer.py
│ ├── async_event_loop.py
│ ├── draw.py
│ ├── gui
│ │ └── __init__.py
│ ├── rendering
│ │ └── __init__.py
│ └── tensorboard_plugin
│ │ ├── frontend
│ │ ├── index.js
│ │ └── style.css
│ │ ├── metadata.py
│ │ ├── plugin.py
│ │ ├── plugin_data.proto
│ │ ├── plugin_data_pb2.py
│ │ ├── summary.py
│ │ └── util.py
│ └── web_visualizer.py
└── Tests
├── LinuxMain.swift
└── Open3D-iOSTests
├── Open3D_iOSTests.swift
└── XCTestManifests.swift
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [kewlbear]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: macos-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 | - run: python --version
17 | - uses: actions/setup-python@v2
18 | with:
19 | python-version: '3.8'
20 | - run: python --version
21 | - run: sh Scripts/ci.sh
22 | id: script
23 | - name: Commit
24 | uses: EndBug/add-and-commit@v7
25 | with:
26 | add: 'Package.swift Sources'
27 | message: "add ${{ steps.script.outputs.tag }}"
28 | - name: Release
29 | uses: "marvinpinto/action-automatic-releases@latest"
30 | with:
31 | repo_token: "${{ secrets.GITHUB_TOKEN }}"
32 | automatic_release_tag: "${{ steps.script.outputs.tag }}"
33 | files: 'Open3D/*.xcframework.zip'
34 | prerelease: false
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 | xcuserdata/
6 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 52;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 4C888FCD25EDC040005BE18A /* PythonKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4C888FCC25EDC040005BE18A /* PythonKit */; };
11 | 4C888FD025EDC879005BE18A /* fragment.ply in Resources */ = {isa = PBXBuildFile; fileRef = 4C888FCF25EDC879005BE18A /* fragment.ply */; };
12 | 4C8B335B261552B800643DC2 /* Open3D-iOS in Frameworks */ = {isa = PBXBuildFile; productRef = 4C8B335A261552B800643DC2 /* Open3D-iOS */; };
13 | 4CD3A25225E8DD5C0013D42E /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CD3A25125E8DD5C0013D42E /* ExampleApp.swift */; };
14 | 4CD3A25425E8DD5C0013D42E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CD3A25325E8DD5C0013D42E /* ContentView.swift */; };
15 | 4CD3A25625E8DD5D0013D42E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4CD3A25525E8DD5D0013D42E /* Assets.xcassets */; };
16 | 4CD3A25925E8DD5D0013D42E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4CD3A25825E8DD5D0013D42E /* Preview Assets.xcassets */; };
17 | /* End PBXBuildFile section */
18 |
19 | /* Begin PBXFileReference section */
20 | 4C888FCF25EDC879005BE18A /* fragment.ply */ = {isa = PBXFileReference; lastKnownFileType = file; path = fragment.ply; sourceTree = ""; };
21 | 4CD3A24E25E8DD5C0013D42E /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
22 | 4CD3A25125E8DD5C0013D42E /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = ""; };
23 | 4CD3A25325E8DD5C0013D42E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
24 | 4CD3A25525E8DD5D0013D42E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
25 | 4CD3A25825E8DD5D0013D42E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
26 | 4CD3A25A25E8DD5D0013D42E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
27 | /* End PBXFileReference section */
28 |
29 | /* Begin PBXFrameworksBuildPhase section */
30 | 4CD3A24B25E8DD5C0013D42E /* Frameworks */ = {
31 | isa = PBXFrameworksBuildPhase;
32 | buildActionMask = 2147483647;
33 | files = (
34 | 4C888FCD25EDC040005BE18A /* PythonKit in Frameworks */,
35 | 4C8B335B261552B800643DC2 /* Open3D-iOS in Frameworks */,
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 4CD3A24525E8DD5C0013D42E = {
43 | isa = PBXGroup;
44 | children = (
45 | 4CD3A25025E8DD5C0013D42E /* Example */,
46 | 4CD3A24F25E8DD5C0013D42E /* Products */,
47 | );
48 | sourceTree = "";
49 | };
50 | 4CD3A24F25E8DD5C0013D42E /* Products */ = {
51 | isa = PBXGroup;
52 | children = (
53 | 4CD3A24E25E8DD5C0013D42E /* Example.app */,
54 | );
55 | name = Products;
56 | sourceTree = "";
57 | };
58 | 4CD3A25025E8DD5C0013D42E /* Example */ = {
59 | isa = PBXGroup;
60 | children = (
61 | 4CD3A25125E8DD5C0013D42E /* ExampleApp.swift */,
62 | 4CD3A25325E8DD5C0013D42E /* ContentView.swift */,
63 | 4CD3A25525E8DD5D0013D42E /* Assets.xcassets */,
64 | 4CD3A25A25E8DD5D0013D42E /* Info.plist */,
65 | 4C888FCF25EDC879005BE18A /* fragment.ply */,
66 | 4CD3A25725E8DD5D0013D42E /* Preview Content */,
67 | );
68 | path = Example;
69 | sourceTree = "";
70 | };
71 | 4CD3A25725E8DD5D0013D42E /* Preview Content */ = {
72 | isa = PBXGroup;
73 | children = (
74 | 4CD3A25825E8DD5D0013D42E /* Preview Assets.xcassets */,
75 | );
76 | path = "Preview Content";
77 | sourceTree = "";
78 | };
79 | /* End PBXGroup section */
80 |
81 | /* Begin PBXNativeTarget section */
82 | 4CD3A24D25E8DD5C0013D42E /* Example */ = {
83 | isa = PBXNativeTarget;
84 | buildConfigurationList = 4CD3A25D25E8DD5D0013D42E /* Build configuration list for PBXNativeTarget "Example" */;
85 | buildPhases = (
86 | 4CD3A24A25E8DD5C0013D42E /* Sources */,
87 | 4CD3A24B25E8DD5C0013D42E /* Frameworks */,
88 | 4CD3A24C25E8DD5C0013D42E /* Resources */,
89 | );
90 | buildRules = (
91 | );
92 | dependencies = (
93 | );
94 | name = Example;
95 | packageProductDependencies = (
96 | 4C888FCC25EDC040005BE18A /* PythonKit */,
97 | 4C8B335A261552B800643DC2 /* Open3D-iOS */,
98 | );
99 | productName = Example;
100 | productReference = 4CD3A24E25E8DD5C0013D42E /* Example.app */;
101 | productType = "com.apple.product-type.application";
102 | };
103 | /* End PBXNativeTarget section */
104 |
105 | /* Begin PBXProject section */
106 | 4CD3A24625E8DD5C0013D42E /* Project object */ = {
107 | isa = PBXProject;
108 | attributes = {
109 | LastSwiftUpdateCheck = 1240;
110 | LastUpgradeCheck = 1240;
111 | TargetAttributes = {
112 | 4CD3A24D25E8DD5C0013D42E = {
113 | CreatedOnToolsVersion = 12.4;
114 | };
115 | };
116 | };
117 | buildConfigurationList = 4CD3A24925E8DD5C0013D42E /* Build configuration list for PBXProject "Example" */;
118 | compatibilityVersion = "Xcode 9.3";
119 | developmentRegion = en;
120 | hasScannedForEncodings = 0;
121 | knownRegions = (
122 | en,
123 | Base,
124 | );
125 | mainGroup = 4CD3A24525E8DD5C0013D42E;
126 | packageReferences = (
127 | 4C888FCB25EDC040005BE18A /* XCRemoteSwiftPackageReference "PythonKit" */,
128 | 4C8B3359261552B800643DC2 /* XCRemoteSwiftPackageReference "Open3D-iOS" */,
129 | );
130 | productRefGroup = 4CD3A24F25E8DD5C0013D42E /* Products */;
131 | projectDirPath = "";
132 | projectRoot = "";
133 | targets = (
134 | 4CD3A24D25E8DD5C0013D42E /* Example */,
135 | );
136 | };
137 | /* End PBXProject section */
138 |
139 | /* Begin PBXResourcesBuildPhase section */
140 | 4CD3A24C25E8DD5C0013D42E /* Resources */ = {
141 | isa = PBXResourcesBuildPhase;
142 | buildActionMask = 2147483647;
143 | files = (
144 | 4C888FD025EDC879005BE18A /* fragment.ply in Resources */,
145 | 4CD3A25925E8DD5D0013D42E /* Preview Assets.xcassets in Resources */,
146 | 4CD3A25625E8DD5D0013D42E /* Assets.xcassets in Resources */,
147 | );
148 | runOnlyForDeploymentPostprocessing = 0;
149 | };
150 | /* End PBXResourcesBuildPhase section */
151 |
152 | /* Begin PBXSourcesBuildPhase section */
153 | 4CD3A24A25E8DD5C0013D42E /* Sources */ = {
154 | isa = PBXSourcesBuildPhase;
155 | buildActionMask = 2147483647;
156 | files = (
157 | 4CD3A25425E8DD5C0013D42E /* ContentView.swift in Sources */,
158 | 4CD3A25225E8DD5C0013D42E /* ExampleApp.swift in Sources */,
159 | );
160 | runOnlyForDeploymentPostprocessing = 0;
161 | };
162 | /* End PBXSourcesBuildPhase section */
163 |
164 | /* Begin XCBuildConfiguration section */
165 | 4CD3A25B25E8DD5D0013D42E /* Debug */ = {
166 | isa = XCBuildConfiguration;
167 | buildSettings = {
168 | ALWAYS_SEARCH_USER_PATHS = NO;
169 | CLANG_ANALYZER_NONNULL = YES;
170 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
171 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
172 | CLANG_CXX_LIBRARY = "libc++";
173 | CLANG_ENABLE_MODULES = YES;
174 | CLANG_ENABLE_OBJC_ARC = YES;
175 | CLANG_ENABLE_OBJC_WEAK = YES;
176 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
177 | CLANG_WARN_BOOL_CONVERSION = YES;
178 | CLANG_WARN_COMMA = YES;
179 | CLANG_WARN_CONSTANT_CONVERSION = YES;
180 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
181 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
182 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
183 | CLANG_WARN_EMPTY_BODY = YES;
184 | CLANG_WARN_ENUM_CONVERSION = YES;
185 | CLANG_WARN_INFINITE_RECURSION = YES;
186 | CLANG_WARN_INT_CONVERSION = YES;
187 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
188 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
189 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
190 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
191 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
192 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
193 | CLANG_WARN_STRICT_PROTOTYPES = YES;
194 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
195 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
196 | CLANG_WARN_UNREACHABLE_CODE = YES;
197 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
198 | COPY_PHASE_STRIP = NO;
199 | DEBUG_INFORMATION_FORMAT = dwarf;
200 | ENABLE_BITCODE = NO;
201 | ENABLE_STRICT_OBJC_MSGSEND = YES;
202 | ENABLE_TESTABILITY = YES;
203 | GCC_C_LANGUAGE_STANDARD = gnu11;
204 | GCC_DYNAMIC_NO_PIC = NO;
205 | GCC_NO_COMMON_BLOCKS = YES;
206 | GCC_OPTIMIZATION_LEVEL = 0;
207 | GCC_PREPROCESSOR_DEFINITIONS = (
208 | "DEBUG=1",
209 | "$(inherited)",
210 | );
211 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
212 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
213 | GCC_WARN_UNDECLARED_SELECTOR = YES;
214 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
215 | GCC_WARN_UNUSED_FUNCTION = YES;
216 | GCC_WARN_UNUSED_VARIABLE = YES;
217 | IPHONEOS_DEPLOYMENT_TARGET = 14.4;
218 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
219 | MTL_FAST_MATH = YES;
220 | ONLY_ACTIVE_ARCH = YES;
221 | SDKROOT = iphoneos;
222 | STRIP_INSTALLED_PRODUCT = NO;
223 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
224 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
225 | };
226 | name = Debug;
227 | };
228 | 4CD3A25C25E8DD5D0013D42E /* Release */ = {
229 | isa = XCBuildConfiguration;
230 | buildSettings = {
231 | ALWAYS_SEARCH_USER_PATHS = NO;
232 | CLANG_ANALYZER_NONNULL = YES;
233 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
235 | CLANG_CXX_LIBRARY = "libc++";
236 | CLANG_ENABLE_MODULES = YES;
237 | CLANG_ENABLE_OBJC_ARC = YES;
238 | CLANG_ENABLE_OBJC_WEAK = YES;
239 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
240 | CLANG_WARN_BOOL_CONVERSION = YES;
241 | CLANG_WARN_COMMA = YES;
242 | CLANG_WARN_CONSTANT_CONVERSION = YES;
243 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
244 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
245 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
246 | CLANG_WARN_EMPTY_BODY = YES;
247 | CLANG_WARN_ENUM_CONVERSION = YES;
248 | CLANG_WARN_INFINITE_RECURSION = YES;
249 | CLANG_WARN_INT_CONVERSION = YES;
250 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
251 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
252 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
253 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
254 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
255 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
256 | CLANG_WARN_STRICT_PROTOTYPES = YES;
257 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
258 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
259 | CLANG_WARN_UNREACHABLE_CODE = YES;
260 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
261 | COPY_PHASE_STRIP = NO;
262 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
263 | ENABLE_BITCODE = NO;
264 | ENABLE_NS_ASSERTIONS = NO;
265 | ENABLE_STRICT_OBJC_MSGSEND = YES;
266 | GCC_C_LANGUAGE_STANDARD = gnu11;
267 | GCC_NO_COMMON_BLOCKS = YES;
268 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
269 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
270 | GCC_WARN_UNDECLARED_SELECTOR = YES;
271 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
272 | GCC_WARN_UNUSED_FUNCTION = YES;
273 | GCC_WARN_UNUSED_VARIABLE = YES;
274 | IPHONEOS_DEPLOYMENT_TARGET = 14.4;
275 | MTL_ENABLE_DEBUG_INFO = NO;
276 | MTL_FAST_MATH = YES;
277 | SDKROOT = iphoneos;
278 | STRIP_INSTALLED_PRODUCT = NO;
279 | SWIFT_COMPILATION_MODE = wholemodule;
280 | SWIFT_OPTIMIZATION_LEVEL = "-O";
281 | VALIDATE_PRODUCT = YES;
282 | };
283 | name = Release;
284 | };
285 | 4CD3A25E25E8DD5D0013D42E /* Debug */ = {
286 | isa = XCBuildConfiguration;
287 | buildSettings = {
288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
289 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
290 | CODE_SIGN_STYLE = Manual;
291 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
292 | DEVELOPMENT_TEAM = "";
293 | ENABLE_PREVIEWS = YES;
294 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
295 | INFOPLIST_FILE = Example/Info.plist;
296 | IPHONEOS_DEPLOYMENT_TARGET = 14.0;
297 | LD_RUNPATH_SEARCH_PATHS = (
298 | "$(inherited)",
299 | "@executable_path/Frameworks",
300 | );
301 | PRODUCT_BUNDLE_IDENTIFIER = io.github.kewlbear.open3d.Example;
302 | PRODUCT_NAME = "$(TARGET_NAME)";
303 | PROVISIONING_PROFILE_SPECIFIER = "";
304 | STRIP_STYLE = debugging;
305 | SWIFT_VERSION = 5.0;
306 | TARGETED_DEVICE_FAMILY = "1,2";
307 | };
308 | name = Debug;
309 | };
310 | 4CD3A25F25E8DD5D0013D42E /* Release */ = {
311 | isa = XCBuildConfiguration;
312 | buildSettings = {
313 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
314 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
315 | CODE_SIGN_STYLE = Manual;
316 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\"";
317 | DEVELOPMENT_TEAM = "";
318 | ENABLE_PREVIEWS = YES;
319 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
320 | INFOPLIST_FILE = Example/Info.plist;
321 | IPHONEOS_DEPLOYMENT_TARGET = 14.0;
322 | LD_RUNPATH_SEARCH_PATHS = (
323 | "$(inherited)",
324 | "@executable_path/Frameworks",
325 | );
326 | PRODUCT_BUNDLE_IDENTIFIER = io.github.kewlbear.open3d.Example;
327 | PRODUCT_NAME = "$(TARGET_NAME)";
328 | PROVISIONING_PROFILE_SPECIFIER = "";
329 | STRIP_STYLE = debugging;
330 | SWIFT_VERSION = 5.0;
331 | TARGETED_DEVICE_FAMILY = "1,2";
332 | };
333 | name = Release;
334 | };
335 | /* End XCBuildConfiguration section */
336 |
337 | /* Begin XCConfigurationList section */
338 | 4CD3A24925E8DD5C0013D42E /* Build configuration list for PBXProject "Example" */ = {
339 | isa = XCConfigurationList;
340 | buildConfigurations = (
341 | 4CD3A25B25E8DD5D0013D42E /* Debug */,
342 | 4CD3A25C25E8DD5D0013D42E /* Release */,
343 | );
344 | defaultConfigurationIsVisible = 0;
345 | defaultConfigurationName = Release;
346 | };
347 | 4CD3A25D25E8DD5D0013D42E /* Build configuration list for PBXNativeTarget "Example" */ = {
348 | isa = XCConfigurationList;
349 | buildConfigurations = (
350 | 4CD3A25E25E8DD5D0013D42E /* Debug */,
351 | 4CD3A25F25E8DD5D0013D42E /* Release */,
352 | );
353 | defaultConfigurationIsVisible = 0;
354 | defaultConfigurationName = Release;
355 | };
356 | /* End XCConfigurationList section */
357 |
358 | /* Begin XCRemoteSwiftPackageReference section */
359 | 4C888FCB25EDC040005BE18A /* XCRemoteSwiftPackageReference "PythonKit" */ = {
360 | isa = XCRemoteSwiftPackageReference;
361 | repositoryURL = "https://github.com/pvieito/PythonKit.git";
362 | requirement = {
363 | branch = master;
364 | kind = branch;
365 | };
366 | };
367 | 4C8B3359261552B800643DC2 /* XCRemoteSwiftPackageReference "Open3D-iOS" */ = {
368 | isa = XCRemoteSwiftPackageReference;
369 | repositoryURL = "https://github.com/kewlbear/Open3D-iOS.git";
370 | requirement = {
371 | branch = main;
372 | kind = branch;
373 | };
374 | };
375 | /* End XCRemoteSwiftPackageReference section */
376 |
377 | /* Begin XCSwiftPackageProductDependency section */
378 | 4C888FCC25EDC040005BE18A /* PythonKit */ = {
379 | isa = XCSwiftPackageProductDependency;
380 | package = 4C888FCB25EDC040005BE18A /* XCRemoteSwiftPackageReference "PythonKit" */;
381 | productName = PythonKit;
382 | };
383 | 4C8B335A261552B800643DC2 /* Open3D-iOS */ = {
384 | isa = XCSwiftPackageProductDependency;
385 | package = 4C8B3359261552B800643DC2 /* XCRemoteSwiftPackageReference "Open3D-iOS" */;
386 | productName = "Open3D-iOS";
387 | };
388 | /* End XCSwiftPackageProductDependency section */
389 | };
390 | rootObject = 4CD3A24625E8DD5C0013D42E /* Project object */;
391 | }
392 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "object": {
3 | "pins": [
4 | {
5 | "package": "BLAS-LAPACK-AppStore-Workaround",
6 | "repositoryURL": "https://github.com/kewlbear/BLAS-LAPACK-AppStore-Workaround.git",
7 | "state": {
8 | "branch": "main",
9 | "revision": "dc78ff05b3c8c1c39d83aab9bdbaef59dc6c87f5",
10 | "version": null
11 | }
12 | },
13 | {
14 | "package": "LAPACKE-iOS",
15 | "repositoryURL": "https://github.com/kewlbear/LAPACKE-iOS.git",
16 | "state": {
17 | "branch": "main",
18 | "revision": "6fbd386ff1cbde8ee6cbf83d2d398d21f8e4474d",
19 | "version": null
20 | }
21 | },
22 | {
23 | "package": "NumPy-iOS",
24 | "repositoryURL": "https://github.com/kewlbear/NumPy-iOS.git",
25 | "state": {
26 | "branch": "main",
27 | "revision": "a686cef91109c46957551e1a79256a900872b1c8",
28 | "version": null
29 | }
30 | },
31 | {
32 | "package": "Open3D-iOS",
33 | "repositoryURL": "https://github.com/kewlbear/Open3D-iOS.git",
34 | "state": {
35 | "branch": "main",
36 | "revision": "8baf17c4158ef047bed638fec523e8e515efc38d",
37 | "version": null
38 | }
39 | },
40 | {
41 | "package": "Python-iOS",
42 | "repositoryURL": "https://github.com/kewlbear/Python-iOS.git",
43 | "state": {
44 | "branch": "kivy-ios",
45 | "revision": "f5333228b625560a90c17d9e2d3a9b2aac6967a9",
46 | "version": null
47 | }
48 | },
49 | {
50 | "package": "PythonKit",
51 | "repositoryURL": "https://github.com/pvieito/PythonKit.git",
52 | "state": {
53 | "branch": "master",
54 | "revision": "c77231820148515a77e9bba5016a57e5a88ef007",
55 | "version": null
56 | }
57 | }
58 | ]
59 | },
60 | "version": 1
61 | }
62 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "scale" : "1x",
46 | "size" : "20x20"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "scale" : "2x",
51 | "size" : "20x20"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "29x29"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "29x29"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "76x76"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "76x76"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "scale" : "2x",
86 | "size" : "83.5x83.5"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "scale" : "1x",
91 | "size" : "1024x1024"
92 | }
93 | ],
94 | "info" : {
95 | "author" : "xcode",
96 | "version" : 1
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Example/Example/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Example/ContentView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContentView.swift
3 | // Example
4 | //
5 | // Created by 안창범 on 2021/02/26.
6 | //
7 |
8 | import SwiftUI
9 |
10 | struct ContentView: View {
11 | var body: some View {
12 | Text("Hello, world!")
13 | .padding()
14 | }
15 | }
16 |
17 | struct ContentView_Previews: PreviewProvider {
18 | static var previews: some View {
19 | ContentView()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Example/Example/ExampleApp.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ExampleApp.swift
3 | // Example
4 | //
5 | // Created by 안창범 on 2021/02/26.
6 | //
7 |
8 | import SwiftUI
9 | import Open3DSupport
10 | import NumPySupport
11 | import PythonSupport
12 | import PythonKit
13 | import SceneKit
14 | import LinkPython
15 |
16 | @main
17 | struct ExampleApp: App {
18 | @StateObject var model = Model()
19 |
20 | var body: some Scene {
21 | WindowGroup {
22 | SceneView(scene: model.scene, options: [.allowsCameraControl])
23 | .onAppear(perform: {
24 | model.doIt()
25 | })
26 | }
27 | }
28 |
29 | init() {
30 | PythonSupport.initialize()
31 | Open3DSupport.sitePackagesURL.insertPythonPath()
32 | NumPySupport.sitePackagesURL.insertPythonPath()
33 | }
34 | }
35 |
36 | class Model: ObservableObject {
37 | var scene: SCNScene? = makeScene()
38 |
39 | var pcd: PythonObject?
40 |
41 | var tstate: UnsafeMutableRawPointer?
42 |
43 | func doIt() {
44 | let o3d = Python.import("open3d")
45 | let np = Python.import("numpy")
46 |
47 | DispatchQueue.global(qos: .userInitiated).async {
48 | let gstate = PyGILState_Ensure()
49 | defer {
50 | DispatchQueue.main.async {
51 | guard let tstate = self.tstate else { fatalError() }
52 | PyEval_RestoreThread(tstate)
53 | self.tstate = nil
54 | }
55 | PyGILState_Release(gstate)
56 | }
57 |
58 | let url = Bundle.main.url(forResource: "fragment", withExtension: "ply")!
59 | let pcd = o3d.io.read_point_cloud(url.path)
60 | self.pcd = pcd
61 | print(pcd)
62 | print(np.asarray(pcd.points))
63 |
64 | let points = np.asarray(pcd.points)
65 | print(points, pcd.get_max_bound(), pcd.get_min_bound())
66 |
67 | let vertices = points.map { point in
68 | SCNVector3(Float(point[0])!, Float(point[1])!, Float(point[2])!) }
69 | let geometrySource = SCNGeometrySource(vertices: vertices)
70 | let indices: [CInt] = Array(0.. SCNScene {
99 | let scene = SCNScene()
100 |
101 | // create and add a light to the scene
102 | let lightNode = SCNNode()
103 | lightNode.light = SCNLight()
104 | lightNode.light!.type = .omni
105 | lightNode.position = SCNVector3(x: 0, y: 10, z: 10)
106 | scene.rootNode.addChildNode(lightNode)
107 |
108 | // create and add an ambient light to the scene
109 | let ambientLightNode = SCNNode()
110 | ambientLightNode.light = SCNLight()
111 | ambientLightNode.light!.type = .ambient
112 | ambientLightNode.light!.color = UIColor.darkGray
113 | scene.rootNode.addChildNode(ambientLightNode)
114 |
115 | return scene
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/Example/Example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UIApplicationSceneManifest
24 |
25 | UIApplicationSupportsMultipleScenes
26 |
27 |
28 | UIApplicationSupportsIndirectInputEvents
29 |
30 | UILaunchScreen
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Example/Example/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/Example/Example/fragment.ply:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kewlbear/Open3D-iOS/e856ef9adc75251247081808ed48135ab68ffb0c/Example/Example/fragment.ply
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021 Changbeom Ahn
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "object": {
3 | "pins": [
4 | {
5 | "package": "NumPy-iOS",
6 | "repositoryURL": "https://github.com/kewlbear/NumPy-iOS.git",
7 | "state": {
8 | "branch": "main",
9 | "revision": "0f5d909f2353fad05deb8c3b6256ebbbb60453c2",
10 | "version": null
11 | }
12 | },
13 | {
14 | "package": "Python-iOS",
15 | "repositoryURL": "https://github.com/kewlbear/Python-iOS.git",
16 | "state": {
17 | "branch": "kivy-ios",
18 | "revision": "d5964d0bac4839a5f095550786626979945ebf04",
19 | "version": null
20 | }
21 | }
22 | ]
23 | },
24 | "version": 1
25 | }
26 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.3
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "Open3D-iOS",
7 | products: [
8 | .library(
9 | name: "Open3D-iOS",
10 | targets: [
11 | "LinkOpen3D",
12 | "Open3DSupport",
13 | "Assimp",
14 | "Faiss",
15 | "IrrXML",
16 | "JPEG",
17 | "jsoncpp",
18 | "libOpen3D_3rdparty_liblzf.a",
19 | "libOpen3D_3rdparty_qhull_r.a",
20 | "libOpen3D_3rdparty_qhullcpp.a",
21 | "libOpen3D_3rdparty_rply.a",
22 | "libOpen3D.a",
23 | "png",
24 | "pybind.a",
25 | "TBB",
26 | ]),
27 | ],
28 | dependencies: [
29 | .package(url: "https://github.com/kewlbear/NumPy-iOS.git", .branch("main")),
30 | .package(url: "https://github.com/kewlbear/LAPACKE-iOS.git", .branch("main")),
31 | .package(url: "https://github.com/kewlbear/BLAS-LAPACK-AppStore-Workaround.git", .branch("main")),
32 | ],
33 | targets: [
34 | .binaryTarget(name: "Assimp", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/Assimp.xcframework.zip", checksum: "2a80268fc3ee5501f0491778f8fb1d053097c5504fec6d056c2a1ffc82deb2bf"),
35 | .binaryTarget(name: "Faiss", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/Faiss.xcframework.zip", checksum: "a6520e9a7ec211570f39bc9906d53c801a67189745f0ce72fc3634bb5913e4d5"),
36 | .binaryTarget(name: "IrrXML", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/IrrXML.xcframework.zip", checksum: "7e948d42956a3880e61fa0c98d121fa31fde6b729d3074d0516dd04154efbb11"),
37 | .binaryTarget(name: "JPEG", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/JPEG.xcframework.zip", checksum: "96ffddd5ec78d390beb04de7f4fb896d3603fe201455b0716a074deb90cdc259"),
38 | .binaryTarget(name: "jsoncpp", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/jsoncpp.xcframework.zip", checksum: "feed1295ceffe288fc9bf7f7e287384d19cc763b5931f653dd8f6ca715006af0"),
39 | .binaryTarget(name: "libOpen3D_3rdparty_liblzf.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/libOpen3D_3rdparty_liblzf.a.xcframework.zip", checksum: "libOpen3D_3rdparty_liblzf.a.xcframework_CHECKSUM"),
40 | .binaryTarget(name: "libOpen3D_3rdparty_qhull_r.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/libOpen3D_3rdparty_qhull_r.a.xcframework.zip", checksum: "libOpen3D_3rdparty_qhull_r.a.xcframework_CHECKSUM"),
41 | .binaryTarget(name: "libOpen3D_3rdparty_qhullcpp.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/libOpen3D_3rdparty_qhullcpp.a.xcframework.zip", checksum: "libOpen3D_3rdparty_qhullcpp.a.xcframework_CHECKSUM"),
42 | .binaryTarget(name: "libOpen3D_3rdparty_rply.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/libOpen3D_3rdparty_rply.a.xcframework.zip", checksum: "libOpen3D_3rdparty_rply.a.xcframework_CHECKSUM"),
43 | .binaryTarget(name: "libOpen3D.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/libOpen3D.a.xcframework.zip", checksum: "libOpen3D.a.xcframework_CHECKSUM"),
44 | .binaryTarget(name: "png", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/png.xcframework.zip", checksum: "104ec4ad4deaae609d7ce7458d808ca8516cc0ea8a80a76c0712fcd0517e3186"),
45 | .binaryTarget(name: "pybind.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/pybind.a.xcframework.zip", checksum: "pybind.a.xcframework_CHECKSUM"),
46 | .binaryTarget(name: "TBB", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/0.0.20221129003814/TBB.xcframework.zip", checksum: "d427d9f65bcfd7bfb8d93d63ba8f1c2c5732429f31374d464efbcd4a1347e417"),
47 | .target(
48 | name: "LinkOpen3D",
49 | dependencies: [
50 | "NumPy-iOS",
51 | "LAPACKE-iOS",
52 | "Assimp",
53 | "Faiss",
54 | "IrrXML",
55 | "JPEG",
56 | "jsoncpp",
57 | "libOpen3D_3rdparty_liblzf.a",
58 | "libOpen3D_3rdparty_qhull_r.a",
59 | "libOpen3D_3rdparty_qhullcpp.a",
60 | "libOpen3D_3rdparty_rply.a",
61 | "libOpen3D.a",
62 | "png",
63 | "pybind.a",
64 | "TBB",
65 | "BLAS-LAPACK-AppStore-Workaround",
66 | ],
67 | linkerSettings: [
68 | .linkedLibrary("stdc++"),
69 | ]
70 | ),
71 | .target(
72 | name: "Open3DSupport",
73 | resources: [.copy("site-packages")]),
74 | .testTarget(
75 | name: "Open3D-iOSTests",
76 | dependencies: ["Open3DSupport"]),
77 | ]
78 | )
79 |
--------------------------------------------------------------------------------
/Package.swift.in:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.3
2 |
3 | import PackageDescription
4 |
5 | let package = Package(
6 | name: "Open3D-iOS",
7 | products: [
8 | .library(
9 | name: "Open3D-iOS",
10 | targets: [
11 | "LinkOpen3D",
12 | "Open3DSupport",
13 | "Assimp",
14 | "Faiss",
15 | "IrrXML",
16 | "JPEG",
17 | "jsoncpp",
18 | "libOpen3D_3rdparty_liblzf.a",
19 | "libOpen3D_3rdparty_qhull_r.a",
20 | "libOpen3D_3rdparty_qhullcpp.a",
21 | "libOpen3D_3rdparty_rply.a",
22 | "libOpen3D.a",
23 | "png",
24 | "pybind.a",
25 | "TBB",
26 | ]),
27 | ],
28 | dependencies: [
29 | .package(url: "https://github.com/kewlbear/NumPy-iOS.git", .branch("main")),
30 | .package(url: "https://github.com/kewlbear/LAPACKE-iOS.git", .branch("main")),
31 | .package(url: "https://github.com/kewlbear/BLAS-LAPACK-AppStore-Workaround.git", .branch("main")),
32 | ],
33 | targets: [
34 | .binaryTarget(name: "Assimp", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/Assimp.xcframework.zip", checksum: "Assimp.xcframework_CHECKSUM"),
35 | .binaryTarget(name: "Faiss", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/Faiss.xcframework.zip", checksum: "Faiss.xcframework_CHECKSUM"),
36 | .binaryTarget(name: "IrrXML", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/IrrXML.xcframework.zip", checksum: "IrrXML.xcframework_CHECKSUM"),
37 | .binaryTarget(name: "JPEG", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/JPEG.xcframework.zip", checksum: "JPEG.xcframework_CHECKSUM"),
38 | .binaryTarget(name: "jsoncpp", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/jsoncpp.xcframework.zip", checksum: "jsoncpp.xcframework_CHECKSUM"),
39 | .binaryTarget(name: "libOpen3D_3rdparty_liblzf.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/libOpen3D_3rdparty_liblzf.a.xcframework.zip", checksum: "libOpen3D_3rdparty_liblzf.a.xcframework_CHECKSUM"),
40 | .binaryTarget(name: "libOpen3D_3rdparty_qhull_r.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/libOpen3D_3rdparty_qhull_r.a.xcframework.zip", checksum: "libOpen3D_3rdparty_qhull_r.a.xcframework_CHECKSUM"),
41 | .binaryTarget(name: "libOpen3D_3rdparty_qhullcpp.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/libOpen3D_3rdparty_qhullcpp.a.xcframework.zip", checksum: "libOpen3D_3rdparty_qhullcpp.a.xcframework_CHECKSUM"),
42 | .binaryTarget(name: "libOpen3D_3rdparty_rply.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/libOpen3D_3rdparty_rply.a.xcframework.zip", checksum: "libOpen3D_3rdparty_rply.a.xcframework_CHECKSUM"),
43 | .binaryTarget(name: "libOpen3D.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/libOpen3D.a.xcframework.zip", checksum: "libOpen3D.a.xcframework_CHECKSUM"),
44 | .binaryTarget(name: "png", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/png.xcframework.zip", checksum: "png.xcframework_CHECKSUM"),
45 | .binaryTarget(name: "pybind.a", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/pybind.a.xcframework.zip", checksum: "pybind.a.xcframework_CHECKSUM"),
46 | .binaryTarget(name: "TBB", url: "https://github.com/kewlbear/Open3D-iOS/releases/download/TAG/TBB.xcframework.zip", checksum: "TBB.xcframework_CHECKSUM"),
47 | .target(
48 | name: "LinkOpen3D",
49 | dependencies: [
50 | "NumPy-iOS",
51 | "LAPACKE-iOS",
52 | "Assimp",
53 | "Faiss",
54 | "IrrXML",
55 | "JPEG",
56 | "jsoncpp",
57 | "libOpen3D_3rdparty_liblzf.a",
58 | "libOpen3D_3rdparty_qhull_r.a",
59 | "libOpen3D_3rdparty_qhullcpp.a",
60 | "libOpen3D_3rdparty_rply.a",
61 | "libOpen3D.a",
62 | "png",
63 | "pybind.a",
64 | "TBB",
65 | "BLAS-LAPACK-AppStore-Workaround",
66 | ],
67 | linkerSettings: [
68 | .linkedLibrary("stdc++"),
69 | ]
70 | ),
71 | .target(
72 | name: "Open3DSupport",
73 | resources: [.copy("site-packages")]),
74 | .testTarget(
75 | name: "Open3D-iOSTests",
76 | dependencies: ["Open3DSupport"]),
77 | ]
78 | )
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Open3D-iOS
2 |
3 | Swift package to use Open3D in iOS apps.
4 |
5 | ## Installation
6 |
7 | ```
8 | .package(url: "https://github.com/kewlbear/Open3D-iOS.git", .branch("main"))
9 | ```
10 |
11 | ## Usage
12 |
13 | ```
14 | import Open3DSupport
15 | import NumPySupport
16 | import PythonSupport
17 | import PythonKit
18 |
19 | PythonSupport.initialize()
20 | Open3DSupport.sitePackagesURL.insertPythonPath()
21 | NumPySupport.sitePackagesURL.insertPythonPath()
22 | let o3d = Python.import("open3d")
23 | ...
24 | ```
25 |
26 | Above code requires `https://github.com/pvieito/PythonKit.git` package.
27 |
28 | See Example directory for more.
29 |
30 | If you want to build XCFrameworks yourself, see https://github.com/kewlbear/Open3D.
31 |
32 | ## License
33 |
34 | MIT
35 |
36 |
--------------------------------------------------------------------------------
/Scripts/ci.sh:
--------------------------------------------------------------------------------
1 | sh Scripts/toolchain.sh
2 |
3 | TAG=0.0.`date +%Y%m%d%H%M%S`
4 |
5 | sh Scripts/package.sh $TAG
6 |
7 | echo "::set-output name=tag::$TAG"
8 |
--------------------------------------------------------------------------------
/Scripts/package.sh:
--------------------------------------------------------------------------------
1 | TAG=$1
2 |
3 | cd Open3D
4 |
5 | sed s/TAG/$TAG/g ../Package.swift.in > Package.swift
6 |
7 | rm *.zip
8 |
9 | for f in *.xcframework
10 | do
11 | zip -r $f.zip $f
12 | rm Package.swift.in
13 | mv Package.swift Package.swift.in
14 | sed s/"$f"_CHECKSUM/`swift package compute-checksum $f.zip`/ Package.swift.in > Package.swift
15 | done
16 |
17 | rm ../Package.swift
18 | mv Package.swift ..
19 |
--------------------------------------------------------------------------------
/Scripts/toolchain.sh:
--------------------------------------------------------------------------------
1 | git clone --depth 1 --shallow-submodules --recursive https://github.com/kewlbear/Open3D.git
2 | cd Open3D
3 |
4 | sh ios/all.sh
5 |
6 | mv `find . -name \*.xcframework` .
7 |
--------------------------------------------------------------------------------
/Sources/LinkOpen3D/Link.m:
--------------------------------------------------------------------------------
1 | //
2 | // Link.m
3 | //
4 | // Copyright (c) 2021 Changbeom Ahn
5 | //
6 | // Permission is hereby granted, free of charge, to any person obtaining a copy
7 | // of this software and associated documentation files (the "Software"), to deal
8 | // in the Software without restriction, including without limitation the rights
9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the Software is
11 | // furnished to do so, subject to the following conditions:
12 | //
13 | // The above copyright notice and this permission notice shall be included in
14 | // all copies or substantial portions of the Software.
15 | //
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | // THE SOFTWARE.
23 | //
24 |
25 | #import
26 | #import
27 |
28 | PyMODINIT_FUNC PyInit_pybind(void);
29 |
30 | ForceLink(Open3D, PyInit_pybind())
31 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/Open3DSupport.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Open3DSupport.swift
3 | //
4 | // Copyright (c) 2021 Changbeom Ahn
5 | //
6 | // Permission is hereby granted, free of charge, to any person obtaining a copy
7 | // of this software and associated documentation files (the "Software"), to deal
8 | // in the Software without restriction, including without limitation the rights
9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | // copies of the Software, and to permit persons to whom the Software is
11 | // furnished to do so, subject to the following conditions:
12 | //
13 | // The above copyright notice and this permission notice shall be included in
14 | // all copies or substantial portions of the Software.
15 | //
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | // THE SOFTWARE.
23 | //
24 |
25 | import Foundation
26 |
27 | public let sitePackagesURL = Bundle.module.bundleURL.appendingPathComponent("site-packages")
28 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | # Workaround when multiple copies of the OpenMP runtime have been linked to
28 | # the program, which happens when PyTorch loads OpenMP runtime first. Not that
29 | # this method is "unsafe, unsupported, undocumented", but we found it to be
30 | # generally safe to use. This should be deprecated once we found a way to
31 | # "ensure that only a single OpenMP runtime is linked into the process".
32 | #
33 | # https://github.com/llvm-mirror/openmp/blob/8453ca8594e1a5dd8a250c39bf8fcfbfb1760e60/runtime/src/i18n/en_US.txt#L449
34 | # https://github.com/dmlc/xgboost/issues/1715
35 | import os
36 | import sys
37 | os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
38 | from ctypes import CDLL as _CDLL
39 | from ctypes.util import find_library as _find_library
40 | from pathlib import Path as _Path
41 | import warnings
42 |
43 | from open3d._build_config import _build_config
44 | if _build_config["BUILD_GUI"] and not (_find_library('c++abi') or
45 | _find_library('c++')):
46 | try: # Preload libc++.so and libc++abi.so (required by filament)
47 | _CDLL(str(next((_Path(__file__).parent).glob('*c++abi.*'))))
48 | _CDLL(str(next((_Path(__file__).parent).glob('*c++.*'))))
49 | except StopIteration: # Not found: check system paths while loading
50 | pass
51 |
52 | __DEVICE_API__ = 'cpu'
53 | if _build_config["BUILD_CUDA_MODULE"]:
54 | # Load CPU pybind dll gracefully without introducing new python variable.
55 | # Do this before loading the CUDA pybind dll to correctly resolve symbols
56 | try: # StopIteration if cpu version not available
57 | _CDLL(str(next((_Path(__file__).parent / 'cpu').glob('pybind*'))))
58 | except StopIteration:
59 | warnings.warn(
60 | "Open3D was built with CUDA support, but Open3D CPU Python "
61 | "bindings were not found. Open3D will not work on systems without"
62 | " CUDA devices.", ImportWarning)
63 | try:
64 | # Check CUDA availability without importing CUDA pybind symbols to
65 | # prevent "symbol already registered" errors if first import fails.
66 | _pybind_cuda = _CDLL(
67 | str(next((_Path(__file__).parent / 'cuda').glob('pybind*'))))
68 | if _pybind_cuda.open3d_core_cuda_device_count() > 0:
69 | from open3d.cuda.pybind import (camera, geometry, io, pipelines,
70 | utility, t)
71 | from open3d.cuda import pybind
72 | __DEVICE_API__ = 'cuda'
73 | else:
74 | warnings.warn(
75 | "Open3D was built with CUDA support, but no suitable CUDA "
76 | "devices found. If your system has CUDA devices, check your "
77 | "CUDA drivers and runtime.", ImportWarning)
78 | except OSError:
79 | warnings.warn(
80 | "Open3D was built with CUDA support, but CUDA libraries could "
81 | "not be found! Check your CUDA installation. Falling back to the "
82 | "CPU pybind library.", ImportWarning)
83 | except StopIteration:
84 | warnings.warn(
85 | "Open3D was built with CUDA support, but Open3D CUDA Python "
86 | "binding library not found! Falling back to the CPU Python "
87 | "binding library.", ImportWarning)
88 |
89 | if __DEVICE_API__ == 'cpu':
90 | from open3d.cpu.pybind import (camera, geometry, io, pipelines, utility)
91 | from open3d.cpu import pybind
92 |
93 | import open3d.core
94 |
95 | __version__ = "0.14.1+69d3cc5"
96 |
97 | if int(sys.version_info[0]) < 3:
98 | raise Exception("Open3D only supports Python 3.")
99 |
100 | if _build_config["BUILD_JUPYTER_EXTENSION"]:
101 | import platform
102 | if not (platform.machine().startswith("arm") or
103 | platform.machine().startswith("aarch")):
104 | try:
105 | shell = get_ipython().__class__.__name__
106 | if shell == 'ZMQInteractiveShell':
107 | print("Jupyter environment detected. "
108 | "Enabling Open3D WebVisualizer.")
109 | # Set default window system.
110 | open3d.visualization.webrtc_server.enable_webrtc()
111 | # HTTP handshake server is needed when Open3D is serving the
112 | # visualizer webpage. Disable since Jupyter is serving.
113 | open3d.visualization.webrtc_server.disable_http_handshake()
114 | except NameError:
115 | pass
116 | else:
117 | warnings.warn("Open3D WebVisualizer is not supported on ARM for now.",
118 | RuntimeWarning)
119 |
120 | # OPEN3D_ML_ROOT points to the root of the Open3D-ML repo.
121 | # If set this will override the integrated Open3D-ML.
122 | if 'OPEN3D_ML_ROOT' in os.environ:
123 | print('Using external Open3D-ML in {}'.format(os.environ['OPEN3D_ML_ROOT']))
124 | sys.path.append(os.environ['OPEN3D_ML_ROOT'])
125 | import open3d.ml
126 |
127 |
128 | def _jupyter_labextension_paths():
129 | """Called by Jupyter Lab Server to detect if it is a valid labextension and
130 | to install the widget.
131 |
132 | Returns:
133 | src: Source directory name to copy files from. Webpack outputs generated
134 | files into this directory and Jupyter Lab copies from this directory
135 | during widget installation.
136 | dest: Destination directory name to install widget files to. Jupyter Lab
137 | copies from `src` directory into /labextensions/
138 | directory during widget installation.
139 | """
140 | return [{
141 | 'src': 'labextension',
142 | 'dest': 'open3d',
143 | }]
144 |
145 |
146 | def _jupyter_nbextension_paths():
147 | """Called by Jupyter Notebook Server to detect if it is a valid nbextension
148 | and to install the widget.
149 |
150 | Returns:
151 | section: The section of the Jupyter Notebook Server to change.
152 | Must be 'notebook' for widget extensions.
153 | src: Source directory name to copy files from. Webpack outputs generated
154 | files into this directory and Jupyter Notebook copies from this
155 | directory during widget installation.
156 | dest: Destination directory name to install widget files to. Jupyter
157 | Notebook copies from `src` directory into
158 | /nbextensions/ directory during widget
159 | installation.
160 | require: Path to importable AMD Javascript module inside the
161 | /nbextensions/ directory.
162 | """
163 | return [{
164 | 'section': 'notebook',
165 | 'src': 'nbextension',
166 | 'dest': 'open3d',
167 | 'require': 'open3d/extension'
168 | }]
169 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/_build_config.py:
--------------------------------------------------------------------------------
1 | _build_config = {
2 | "BUILD_TENSORFLOW_OPS" : False,
3 | "BUILD_PYTORCH_OPS" : False,
4 | "BUILD_CUDA_MODULE" : False,
5 | "BUILD_AZURE_KINECT" : False,
6 | "BUILD_LIBREALSENSE" : False,
7 | "BUILD_SHARED_LIBS" : False,
8 | "BUILD_GUI" : False,
9 | "ENABLE_HEADLESS_RENDERING" : False,
10 | "BUILD_JUPYTER_EXTENSION" : False,
11 | "BUNDLE_OPEN3D_ML" : False,
12 | "GLIBCXX_USE_CXX11_ABI" : False,
13 | "CMAKE_BUILD_TYPE" : "Release",
14 | "CUDA_VERSION" : "",
15 | "CUDA_GENCODES" : "",
16 | "Tensorflow_VERSION" : "",
17 | "Pytorch_VERSION" : "",
18 | "WITH_OPENMP" : True,
19 | "WITH_FAISS" : True
20 | }
21 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/core.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import open3d as o3d
28 |
29 | if o3d.__DEVICE_API__ == 'cuda':
30 | from open3d.cuda.pybind.core import *
31 | else:
32 | from open3d.cpu.pybind.core import *
33 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/cpu/pybind.cpython-38-darwin.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kewlbear/Open3D-iOS/e856ef9adc75251247081808ed48135ab68ffb0c/Sources/Open3DSupport/site-packages/open3d/cpu/pybind.cpython-38-darwin.so
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import os as _os
28 | import open3d as _open3d
29 | if _open3d.__DEVICE_API__ == 'cuda':
30 | from open3d.cuda.pybind.ml import *
31 | else:
32 | from open3d.cpu.pybind.ml import *
33 |
34 | from . import configs
35 | from . import datasets
36 | from . import vis
37 | from . import utils
38 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/configs.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import os as _os
28 | from open3d import _build_config
29 |
30 | if _build_config['BUNDLE_OPEN3D_ML']:
31 | if 'OPEN3D_ML_ROOT' in _os.environ:
32 | from ml3d.configs import *
33 | else:
34 | from open3d._ml3d.configs import *
35 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/contrib/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import open3d as _open3d
28 | if _open3d.__DEVICE_API__ == 'cuda':
29 | from open3d.cuda.pybind.ml.contrib import *
30 | else:
31 | from open3d.cpu.pybind.ml.contrib import *
32 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/datasets.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import os as _os
28 | from open3d import _build_config
29 |
30 | if _build_config['BUNDLE_OPEN3D_ML']:
31 | if 'OPEN3D_ML_ROOT' in _os.environ:
32 | from ml3d.datasets import *
33 | else:
34 | from open3d._ml3d.datasets import *
35 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """TensorFlow specific machine learning functions."""
27 |
28 | import os as _os
29 | from tensorflow import __version__ as _tf_version
30 | from open3d import _build_config
31 |
32 | if not _build_config["Tensorflow_VERSION"]:
33 | raise Exception('Open3D was not built with TensorFlow support!')
34 |
35 | _o3d_tf_version = _build_config["Tensorflow_VERSION"].split('.')
36 | if _tf_version.split('.')[:2] != _o3d_tf_version[:2]:
37 | _o3d_tf_version[2] = '*' # Any patch level is OK
38 | match_tf_ver = '.'.join(_o3d_tf_version)
39 | raise Exception('Version mismatch: Open3D needs TensorFlow version {}, but'
40 | ' version {} is installed!'.format(match_tf_ver,
41 | _tf_version))
42 |
43 | from . import layers
44 | from . import ops
45 |
46 | # put framework independent modules here for convenience
47 | from . import configs
48 | from . import datasets
49 | from . import vis
50 |
51 | # framework specific modules from open3d-ml
52 | from . import models
53 | from . import modules
54 | from . import pipelines
55 | from . import dataloaders
56 |
57 | # put contrib at the same level
58 | from open3d.ml import contrib
59 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/configs.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Config files for ml3d."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.configs import *
34 | else:
35 | from open3d._ml3d.configs import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/dataloaders.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Dataloader for TensorFlow."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.tf.dataloaders import *
34 | else:
35 | from open3d._ml3d.tf.dataloaders import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/datasets.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """I/O, attributes, and processing for different datasets."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.datasets import *
34 | else:
35 | from open3d._ml3d.datasets import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/layers/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """High level layer API for building networks.
27 |
28 | This module contains layers for processing 3D data.
29 | All layers subclass tf.keras.layers.Layer.
30 | """
31 | from ..python.layers.neighbor_search import *
32 | from ..python.layers.convolutions import *
33 | from ..python.layers.voxel_pooling import *
34 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/models.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """TensorFlow network models."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.tf.models import *
34 | else:
35 | from open3d._ml3d.tf.models import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/modules.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Loss and Metric modules for TensorFlow."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.tf.modules import losses
34 | from ml3d.tf.modules import metrics
35 | else:
36 | from open3d._ml3d.tf.modules import losses
37 | from open3d._ml3d.tf.modules import metrics
38 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/ops/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Functional API with operators.
27 |
28 | These are the building blocks for the layers. See The layer API for an easy to
29 | use high level interface.
30 | """
31 | from ..python.ops.ops import *
32 | from ..python.ops.gradients import *
33 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/pipelines.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """3D ML pipelines for TensorFlow."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.tf.pipelines import *
34 | else:
35 | from open3d._ml3d.tf.pipelines import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/python/layers/voxel_pooling.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | from ...python.ops import ops
28 | import tensorflow as tf
29 |
30 | __all__ = ['VoxelPooling']
31 |
32 |
33 | class VoxelPooling(tf.keras.layers.Layer):
34 | """Voxel pooling for 3D point clouds.
35 |
36 | Spatial pooling for point clouds by combining points that fall into the same voxel bin.
37 |
38 | The voxel grid used for pooling is always aligned to the origin (0,0,0) to
39 | simplify building voxel grid hierarchies. The order of the returned voxels is
40 | not defined as can be seen in the following example::
41 |
42 | import open3d.ml.tf as ml3d
43 |
44 | positions = [
45 | [0.1,0.1,0.1],
46 | [0.5,0.5,0.5],
47 | [1.7,1.7,1.7],
48 | [1.8,1.8,1.8],
49 | [0.3,2.4,1.4]]
50 |
51 | features = [[1.0,2.0],
52 | [1.1,2.3],
53 | [4.2,0.1],
54 | [1.3,3.4],
55 | [2.3,1.9]]
56 |
57 | voxel_pooling = ml3d.layers.VoxelPooling(position_fn='center', feature_fn='max')
58 |
59 | ans = voxel_pooling(positions, features, 1.0)
60 |
61 | # returns the voxel centers in
62 | # ans.pooled_positions = [[0.5, 2.5, 1.5],
63 | # [1.5, 1.5, 1.5],
64 | # [0.5, 0.5, 0.5]]
65 | #
66 | # and the max pooled features for each voxel in
67 | # ans.pooled_features = [[2.3, 1.9],
68 | # [4.2, 3.4],
69 | # [1.1, 2.3]]
70 |
71 | Arguments:
72 | position_fn: Defines how the new point positions will be computed.
73 | The options are
74 | * "average" computes the center of gravity for the points within one voxel.
75 | * "nearest_neighbor" selects the point closest to the voxel center.
76 | * "center" uses the voxel center for the position of the generated point.
77 |
78 | feature_fn: Defines how the pooled features will be computed.
79 | The options are
80 | * "average" computes the average feature vector.
81 | * "nearest_neighbor" selects the feature vector of the point closest to the voxel center.
82 | * "max" uses the maximum feature among all points within the voxel.
83 | """
84 |
85 | def __init__(self, position_fn='center', feature_fn='max', **kwargs):
86 | self.position_fn = position_fn
87 | self.feature_fn = feature_fn
88 | super().__init__(autocast=False, **kwargs)
89 |
90 | def build(self, inp_shape):
91 | super().build(inp_shape)
92 |
93 | def call(self, positions, features, voxel_size):
94 | """This function computes the pooled positions and features.
95 |
96 | Arguments:
97 |
98 | positions: The point positions with shape [N,3] with N as the number of points.
99 | *This argument must be given as a positional argument!*
100 |
101 | features: The feature vector with shape [N,channels].
102 |
103 | voxel_size: The voxel size.
104 |
105 | Returns:
106 | 2 Tensors in the following order
107 |
108 | pooled_positions
109 | The output point positions with shape [M,3] and M <= N.
110 |
111 | pooled_features:
112 | The output point features with shape [M,channnels] and M <= N.
113 | """
114 | result = ops.voxel_pooling(positions,
115 | features,
116 | voxel_size,
117 | position_fn=self.position_fn,
118 | feature_fn=self.feature_fn)
119 | return result
120 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/python/ops/gradients.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | from .lib import _lib
28 | import tensorflow as _tf
29 | from tensorflow.python.framework import ops as _ops
30 |
31 |
32 | @_ops.RegisterGradient("Open3DVoxelPooling")
33 | def _voxel_pooling_grad(op, grad_pos, grad_feat):
34 | features_grad = _lib.open3d_voxel_pooling_grad(
35 | positions=op.inputs[0],
36 | features=op.inputs[1],
37 | voxel_size=op.inputs[2],
38 | pooled_positions=op.outputs[0],
39 | pooled_features_gradient=grad_feat,
40 | position_fn=op.get_attr('position_fn'),
41 | feature_fn=op.get_attr('feature_fn'),
42 | )
43 | return [None, features_grad, None]
44 |
45 |
46 | @_ops.RegisterGradient("Open3DContinuousConv")
47 | def _continuous_conv_grad(op, grad):
48 |
49 | filters = op.inputs[0]
50 | out_positions = op.inputs[1]
51 | extents = op.inputs[2]
52 | offset = op.inputs[3]
53 | inp_positions = op.inputs[4]
54 | inp_features = op.inputs[5]
55 | inp_importance = op.inputs[6]
56 | neighbors_index = op.inputs[7]
57 | neighbors_importance = op.inputs[8]
58 | neighbors_row_splits = op.inputs[9]
59 |
60 | filter_grad = _lib.open3d_continuous_conv_backprop_filter(
61 | align_corners=op.get_attr('align_corners'),
62 | interpolation=op.get_attr('interpolation'),
63 | coordinate_mapping=op.get_attr('coordinate_mapping'),
64 | normalize=op.get_attr('normalize'),
65 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
66 | filters=filters,
67 | out_positions=out_positions,
68 | extents=extents,
69 | offset=offset,
70 | inp_positions=inp_positions,
71 | inp_features=inp_features,
72 | inp_importance=inp_importance,
73 | neighbors_index=neighbors_index,
74 | neighbors_importance=neighbors_importance,
75 | neighbors_row_splits=neighbors_row_splits,
76 | out_features_gradient=grad,
77 | )
78 |
79 | # invert the neighbors list
80 | num_points = _tf.shape(inp_positions, out_type=_tf.int64)[0]
81 | inv_neighbors_index, inv_neighbors_row_splits, inv_neighbors_importance = _lib.open3d_invert_neighbors_list(
82 | num_points, neighbors_index, neighbors_row_splits, neighbors_importance)
83 |
84 | neighbors_importance_sum = _lib.open3d_reduce_subarrays_sum(
85 | neighbors_importance, neighbors_row_splits)
86 |
87 | inp_features_grad = _lib.open3d_continuous_conv_transpose(
88 | align_corners=op.get_attr('align_corners'),
89 | interpolation=op.get_attr('interpolation'),
90 | coordinate_mapping=op.get_attr('coordinate_mapping'),
91 | normalize=op.get_attr('normalize'),
92 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
93 | filters=_tf.transpose(filters, [0, 1, 2, 4, 3]),
94 | out_positions=inp_positions,
95 | out_importance=inp_importance,
96 | extents=extents,
97 | offset=offset,
98 | inp_positions=out_positions,
99 | inp_features=grad,
100 | inp_neighbors_importance_sum=neighbors_importance_sum,
101 | inp_neighbors_index=neighbors_index,
102 | inp_neighbors_row_splits=neighbors_row_splits,
103 | neighbors_index=inv_neighbors_index,
104 | neighbors_importance=inv_neighbors_importance,
105 | neighbors_row_splits=inv_neighbors_row_splits,
106 | )
107 |
108 | return [filter_grad] + [None] * 4 + [inp_features_grad] + [None] * 4
109 |
110 |
111 | @_ops.RegisterGradient("Open3DContinuousConvTranspose")
112 | def _continuous_conv_transpose_grad(op, grad):
113 |
114 | filters = op.inputs[0]
115 | out_positions = op.inputs[1]
116 | out_importance = op.inputs[2]
117 | extents = op.inputs[3]
118 | offset = op.inputs[4]
119 | inp_positions = op.inputs[5]
120 | inp_features = op.inputs[6]
121 | # unused inp_neighbors_index = op.inputs[7]
122 | inp_neighbors_importance_sum = op.inputs[8]
123 | inp_neighbors_row_splits = op.inputs[9]
124 | neighbors_index = op.inputs[10]
125 | neighbors_importance = op.inputs[11]
126 | neighbors_row_splits = op.inputs[12]
127 |
128 | filter_grad = _lib.open3d_continuous_conv_transpose_backprop_filter(
129 | align_corners=op.get_attr('align_corners'),
130 | interpolation=op.get_attr('interpolation'),
131 | coordinate_mapping=op.get_attr('coordinate_mapping'),
132 | normalize=op.get_attr('normalize'),
133 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
134 | filters=filters,
135 | out_positions=out_positions,
136 | out_importance=out_importance,
137 | extents=extents,
138 | offset=offset,
139 | inp_positions=inp_positions,
140 | inp_features=inp_features,
141 | inp_neighbors_importance_sum=inp_neighbors_importance_sum,
142 | inp_neighbors_row_splits=inp_neighbors_row_splits,
143 | neighbors_index=neighbors_index,
144 | neighbors_importance=neighbors_importance,
145 | neighbors_row_splits=neighbors_row_splits,
146 | out_features_gradient=grad,
147 | )
148 |
149 | # invert the neighbors list
150 | num_points = _tf.shape(inp_positions, out_type=_tf.int64)[0]
151 | inv_neighbors_index, _, inv_neighbors_importance = _lib.open3d_invert_neighbors_list(
152 | num_points, neighbors_index, neighbors_row_splits, neighbors_importance)
153 |
154 | inp_features_grad = _lib.open3d_continuous_conv(
155 | align_corners=op.get_attr('align_corners'),
156 | interpolation=op.get_attr('interpolation'),
157 | coordinate_mapping=op.get_attr('coordinate_mapping'),
158 | normalize=op.get_attr('normalize'),
159 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
160 | filters=_tf.transpose(filters, [0, 1, 2, 4, 3]),
161 | out_positions=inp_positions,
162 | extents=extents,
163 | offset=offset,
164 | inp_positions=out_positions,
165 | inp_features=grad,
166 | inp_importance=out_importance,
167 | neighbors_index=inv_neighbors_index,
168 | neighbors_importance=inv_neighbors_importance,
169 | neighbors_row_splits=inp_neighbors_row_splits,
170 | )
171 |
172 | return [filter_grad] + [None] * 5 + [inp_features_grad] + [None] * 6
173 |
174 |
175 | @_ops.RegisterGradient("Open3DSparseConv")
176 | def _sparse_conv_grad(op, grad):
177 |
178 | filters = op.inputs[0]
179 | inp_features = op.inputs[1]
180 | inp_importance = op.inputs[2]
181 | neighbors_index = op.inputs[3]
182 | neighbors_kernel_index = op.inputs[4]
183 | neighbors_importance = op.inputs[5]
184 | neighbors_row_splits = op.inputs[6]
185 |
186 | filter_grad = _lib.open3d_sparse_conv_backprop_filter(
187 | normalize=op.get_attr('normalize'),
188 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
189 | filters=filters,
190 | inp_features=inp_features,
191 | inp_importance=inp_importance,
192 | neighbors_index=neighbors_index,
193 | neighbors_kernel_index=neighbors_kernel_index,
194 | neighbors_importance=neighbors_importance,
195 | neighbors_row_splits=neighbors_row_splits,
196 | out_features_gradient=grad,
197 | )
198 |
199 | # invert the neighbors list
200 | num_points = _tf.shape(inp_features, out_type=_tf.int64)[0]
201 | arange = _tf.range(0, _tf.shape(neighbors_index)[0])
202 | inv_neighbors_index, inv_neighbors_row_splits, inv_arange = _lib.open3d_invert_neighbors_list(
203 | num_points, neighbors_index, neighbors_row_splits, arange)
204 |
205 | inv_neighbors_kernel_index = _tf.gather(neighbors_kernel_index, inv_arange)
206 | inv_neighbors_importance = _tf.cond(
207 | _tf.shape(neighbors_importance)[0] > 0,
208 | true_fn=lambda: _tf.gather(neighbors_importance, inv_arange),
209 | false_fn=lambda: _tf.ones((0,), dtype=_tf.float32))
210 |
211 | neighbors_importance_sum = _lib.open3d_reduce_subarrays_sum(
212 | neighbors_importance, neighbors_row_splits)
213 |
214 | inp_features_grad = _lib.open3d_sparse_conv_transpose(
215 | normalize=op.get_attr('normalize'),
216 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
217 | filters=_tf.transpose(filters, [0, 2, 1]),
218 | out_importance=inp_importance,
219 | inp_features=grad,
220 | inp_neighbors_importance_sum=neighbors_importance_sum,
221 | inp_neighbors_index=neighbors_index,
222 | inp_neighbors_row_splits=neighbors_row_splits,
223 | neighbors_index=inv_neighbors_index,
224 | neighbors_kernel_index=inv_neighbors_kernel_index,
225 | neighbors_importance=inv_neighbors_importance,
226 | neighbors_row_splits=inv_neighbors_row_splits,
227 | )
228 |
229 | return [filter_grad, inp_features_grad] + [None] * 5
230 |
231 |
232 | @_ops.RegisterGradient("Open3DSparseConvTranspose")
233 | def _sparse_conv_transpose_grad(op, grad):
234 |
235 | filters = op.inputs[0]
236 | out_importance = op.inputs[1]
237 | inp_features = op.inputs[2]
238 | inp_neighbors_importance_sum = op.inputs[4]
239 | inp_neighbors_row_splits = op.inputs[5]
240 | neighbors_index = op.inputs[6]
241 | neighbors_kernel_index = op.inputs[7]
242 | neighbors_importance = op.inputs[8]
243 | neighbors_row_splits = op.inputs[9]
244 |
245 | filter_grad = _lib.open3d_sparse_conv_transpose_backprop_filter(
246 | normalize=op.get_attr('normalize'),
247 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
248 | filters=filters,
249 | out_importance=out_importance,
250 | inp_features=inp_features,
251 | inp_neighbors_importance_sum=inp_neighbors_importance_sum,
252 | inp_neighbors_row_splits=inp_neighbors_row_splits,
253 | neighbors_index=neighbors_index,
254 | neighbors_kernel_index=neighbors_kernel_index,
255 | neighbors_importance=neighbors_importance,
256 | neighbors_row_splits=neighbors_row_splits,
257 | out_features_gradient=grad,
258 | )
259 |
260 | # invert the neighbors list
261 | num_points = _tf.shape(inp_features, out_type=_tf.int64)[0]
262 | arange = _tf.range(0, _tf.shape(neighbors_index)[0])
263 | inv_neighbors_index, _, inv_arange = _lib.open3d_invert_neighbors_list(
264 | num_points, neighbors_index, neighbors_row_splits, arange)
265 |
266 | inv_neighbors_kernel_index = _tf.gather(neighbors_kernel_index, inv_arange)
267 | if _tf.shape(neighbors_importance)[0] > 0:
268 | inv_neighbors_importance = _tf.gather(neighbors_importance, inv_arange)
269 | else:
270 | inv_neighbors_importance = _tf.ones((0,), dtype=_tf.float32)
271 |
272 | inp_features_grad = _lib.open3d_sparse_conv(
273 | normalize=op.get_attr('normalize'),
274 | max_temp_mem_MB=op.get_attr('max_temp_mem_MB'),
275 | filters=_tf.transpose(filters, [0, 2, 1]),
276 | inp_features=grad,
277 | inp_importance=out_importance,
278 | neighbors_index=inv_neighbors_index,
279 | neighbors_kernel_index=inv_neighbors_kernel_index,
280 | neighbors_importance=inv_neighbors_importance,
281 | neighbors_row_splits=inp_neighbors_row_splits,
282 | )
283 |
284 | return [filter_grad] + [None] + [inp_features_grad] + [None] * 7
285 |
286 |
287 | @_ops.RegisterGradient("Open3DTrilinearDevoxelize")
288 | def _trilinear_devoxelize_gradient(op, grad_out, grad_inds, grad_wgts):
289 |
290 | inds = op.outputs[1]
291 | wgts = op.outputs[2]
292 | r = op.attrs[1]
293 |
294 | grad_input = _lib.trilinear_devoxelize_grad(grad_out, inds, wgts, r)
295 |
296 | return None, grad_input
297 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/python/ops/lib.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """This module loads the op library."""
27 |
28 | import os as _os
29 | import sys as _sys
30 | import tensorflow as _tf
31 | from open3d import _build_config
32 |
33 | _lib_path = []
34 | # allow overriding the path to the op library with an env var.
35 | if 'OPEN3D_TF_OP_LIB' in _os.environ:
36 | _lib_path.append(_os.environ['OPEN3D_TF_OP_LIB'])
37 |
38 | _this_dir = _os.path.dirname(__file__)
39 | _package_root = _os.path.join(_this_dir, '..', '..', '..', '..')
40 | _lib_ext = {'linux': '.so', 'darwin': '.dylib', 'win32': '.dll'}[_sys.platform]
41 | _lib_suffix = '_debug' if _build_config['CMAKE_BUILD_TYPE'] == 'Debug' else ''
42 | _lib_arch = ('cuda', 'cpu') if _build_config["BUILD_CUDA_MODULE"] else ('cpu',)
43 | _lib_path.extend([
44 | _os.path.join(_package_root, la, 'open3d_tf_ops' + _lib_suffix + _lib_ext)
45 | for la in _lib_arch
46 | ])
47 |
48 | _load_except = None
49 | _loaded = False
50 | for _lp in _lib_path:
51 | try:
52 | _lib = _tf.load_op_library(_lp)
53 | _loaded = True
54 | break
55 | except Exception as ex:
56 | _load_except = ex
57 | if not _os.path.isfile(_lp):
58 | print('The op library at "{}" was not found. Make sure that '
59 | 'BUILD_TENSORFLOW_OPS was enabled.'.format(
60 | _os.path.realpath(_lp)))
61 |
62 | if not _loaded:
63 | raise _load_except
64 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/python/ops/ops.py.in:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | # This file is machine generated. Do not modify.
28 | import tensorflow as _tf
29 | from .lib import _lib
30 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/tf/vis.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Visualizer for 3D ML."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.vis import *
34 | else:
35 | from open3d._ml3d.vis import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Torch specific machine learning functions."""
27 | import os as _os
28 | import sys as _sys
29 | import torch as _torch
30 | from open3d import _build_config
31 |
32 | if not _build_config["Pytorch_VERSION"]:
33 | raise Exception('Open3D was not built with PyTorch support!')
34 |
35 | _o3d_torch_version = _build_config["Pytorch_VERSION"].split('.')
36 | if _torch.__version__.split('.')[:2] != _o3d_torch_version[:2]:
37 | _o3d_torch_version[2] = '*' # Any patch level is OK
38 | match_torch_ver = '.'.join(_o3d_torch_version)
39 | raise Exception('Version mismatch: Open3D needs PyTorch version {}, but '
40 | 'version {} is installed!'.format(match_torch_ver,
41 | _torch.__version__))
42 |
43 | # Precompiled wheels at
44 | # https://github.com/isl-org/open3d_downloads/releases/tag/torch1.8.2
45 | # have been compiled with '-Xcompiler -fno-gnu-unique' and have an additional
46 | # attribute that we test here. Print a warning if the attribute is missing.
47 | if _build_config["BUILD_CUDA_MODULE"] and not hasattr(_torch,
48 | "_TORCH_NVCC_FLAGS"):
49 | print("""
50 | --------------------------------------------------------------------------------
51 |
52 | Using the Open3D PyTorch ops with CUDA 11 may have stability issues!
53 |
54 | We recommend to compile PyTorch from source with compile flags
55 | '-Xcompiler -fno-gnu-unique'
56 |
57 | or use the PyTorch wheels at
58 | https://github.com/isl-org/open3d_downloads/releases/tag/torch1.8.2
59 |
60 |
61 | Ignore this message if PyTorch has been compiled with the aforementioned
62 | flags.
63 |
64 | See https://github.com/isl-org/Open3D/issues/3324 and
65 | https://github.com/pytorch/pytorch/issues/52663 for more information on this
66 | problem.
67 |
68 | --------------------------------------------------------------------------------
69 | """)
70 |
71 | _lib_path = []
72 | # allow overriding the path to the op library with an env var.
73 | if 'OPEN3D_TORCH_OP_LIB' in _os.environ:
74 | _lib_path.append(_os.environ['OPEN3D_TORCH_OP_LIB'])
75 |
76 | _this_dir = _os.path.dirname(__file__)
77 | _package_root = _os.path.join(_this_dir, '..', '..')
78 | _lib_ext = {'linux': '.so', 'darwin': '.dylib', 'win32': '.dll'}[_sys.platform]
79 | _lib_suffix = '_debug' if _build_config['CMAKE_BUILD_TYPE'] == 'Debug' else ''
80 | _lib_arch = ('cpu',)
81 | if _build_config["BUILD_CUDA_MODULE"] and _torch.cuda.is_available():
82 | if _torch.version.cuda == _build_config["CUDA_VERSION"]:
83 | _lib_arch = ('cuda', 'cpu')
84 | else:
85 | print("Warning: Open3D was built with CUDA {} but"
86 | "PyTorch was built with CUDA {}. Falling back to CPU for now."
87 | "Otherwise, install PyTorch with CUDA {}.".format(
88 | _build_config["CUDA_VERSION"], _torch.version.cuda,
89 | _build_config["CUDA_VERSION"]))
90 | _lib_path.extend([
91 | _os.path.join(_package_root, la,
92 | 'open3d_torch_ops' + _lib_suffix + _lib_ext)
93 | for la in _lib_arch
94 | ])
95 |
96 | _load_except = None
97 | _loaded = False
98 | for _lp in _lib_path:
99 | try:
100 | _torch.ops.load_library(_lp)
101 | _torch.classes.load_library(_lp)
102 | _loaded = True
103 | break
104 | except Exception as ex:
105 | _load_except = ex
106 | if not _os.path.isfile(_lp):
107 | print('The op library at "{}" was not found. Make sure that '
108 | 'BUILD_PYTORCH_OPS was enabled.'.format(
109 | _os.path.realpath(_lp)))
110 |
111 | if not _loaded:
112 | raise _load_except
113 |
114 | from . import layers
115 | from . import ops
116 | from . import classes
117 |
118 | # put framework independent modules here for convenience
119 | from . import configs
120 | from . import datasets
121 | from . import vis
122 |
123 | # framework specific modules from open3d-ml
124 | from . import models
125 | from . import modules
126 | from . import pipelines
127 | from . import dataloaders
128 |
129 | # put contrib at the same level
130 | from open3d.ml import contrib
131 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/classes/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Torch specific machine learning classes."""
27 | from .ragged_tensor import *
28 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/classes/ragged_tensor.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import torch
28 | import numpy as np
29 |
30 | __all__ = ['RaggedTensor']
31 |
32 |
33 | class RaggedTensor:
34 | """RaggedTensor.
35 |
36 | A RaggedTensor is a tensor with ragged dimension, whose slice may
37 | have different lengths. We define a container for ragged tensor to
38 | support operations involving batches whose elements may have different
39 | shape.
40 |
41 | """
42 |
43 | def __init__(self, r_tensor, internal=False):
44 | """Creates a `RaggedTensor` with specified torch script object.
45 |
46 | This constructor is private -- please use one of the following ops
47 | to build `RaggedTensor`'s:
48 |
49 | * `ml3d.classes.RaggedTensor.from_row_splits`
50 |
51 | Raises:
52 | ValueError: If internal = False. This method is intented for internal use.
53 |
54 | """
55 | if not internal:
56 | raise ValueError(
57 | "RaggedTensor constructor is private, please use one of the factory method instead(e.g. RaggedTensor.from_row_splits())"
58 | )
59 | self.r_tensor = r_tensor
60 |
61 | @classmethod
62 | def from_row_splits(cls, values, row_splits, validate=True, copy=True):
63 | """Creates a RaggedTensor with rows partitioned by row_splits.
64 |
65 | The returned `RaggedTensor` corresponds with the python list defined by::
66 |
67 | result = [values[row_splits[i]:row_splits[i + 1]]
68 | for i in range(len(row_splits) - 1)]
69 |
70 | Args:
71 | values: A Tensor with shape [N, None].
72 | row_splits: A 1-D integer tensor with shape `[N+1]`. Must not be
73 | empty, and must be stored in ascending order. `row_splits[0]` must
74 | be zero and `row_splits[-1]` must be `N`.
75 | validate: Verify that `row_splits` are compatible with `values`.
76 | Set it to False to avoid expensive checks.
77 | copy: Whether to do a deep copy for `values` and `row_splits`.
78 | Set it to False to save memory for short term usage.
79 |
80 | Returns:
81 | A `RaggedTensor` container.
82 |
83 | Example:
84 |
85 | >>> print(ml3d.classes.RaggedTensor.from_row_splits(
86 | ... values=[3, 1, 4, 1, 5, 9, 2, 6],
87 | ... row_splits=[0, 4, 4, 7, 8, 8]))
88 |
89 |
90 | """
91 | if isinstance(values, list):
92 | values = torch.tensor(values, dtype=torch.float64)
93 | elif isinstance(values, np.ndarray):
94 | values = torch.from_numpy(values)
95 | elif isinstance(values, torch.Tensor) and copy:
96 | values = values.clone()
97 |
98 | if isinstance(row_splits, list):
99 | row_splits = torch.tensor(row_splits, dtype=torch.int64)
100 | elif isinstance(row_splits, np.ndarray):
101 | row_splits = torch.from_numpy(row_splits)
102 | elif isinstance(row_splits, torch.Tensor) and copy:
103 | row_splits = row_splits.clone()
104 |
105 | r_tensor = torch.classes.my_classes.RaggedTensor().from_row_splits(
106 | values, row_splits, validate)
107 | return cls(r_tensor, internal=True)
108 |
109 | @property
110 | def values(self):
111 | """The concatenated rows for this ragged tensor."""
112 | return self.r_tensor.get_values()
113 |
114 | @property
115 | def row_splits(self):
116 | """The row-split indices for this ragged tensor's `values`."""
117 | return self.r_tensor.get_row_splits()
118 |
119 | @property
120 | def dtype(self):
121 | """The `DType` of values in this ragged tensor."""
122 | return self.values.dtype
123 |
124 | @property
125 | def device(self):
126 | """The device of values in this ragged tensor."""
127 | return self.values.device
128 |
129 | @property
130 | def shape(self):
131 | """The statically known shape of this ragged tensor."""
132 | return [len(self.r_tensor), None, *self.values.shape[1:]]
133 |
134 | @property
135 | def requires_grad(self):
136 | """Read/writeble `requires_grad` for values."""
137 | return self.values.requires_grad
138 |
139 | @requires_grad.setter
140 | def requires_grad(self, value):
141 | self.values.requires_grad = value
142 |
143 | def clone(self):
144 | """Returns a clone of object."""
145 | return RaggedTensor(self.r_tensor.clone(), True)
146 |
147 | def to_list(self):
148 | """Returns a list of tensors"""
149 | return [tensor for tensor in self.r_tensor]
150 |
151 | def __getitem__(self, idx):
152 | return self.r_tensor[idx]
153 |
154 | def __repr__(self):
155 | return f"RaggedTensor(values={self.values}, row_splits={self.row_splits})"
156 |
157 | def __len__(self):
158 | return len(self.r_tensor)
159 |
160 | def __add__(self, other):
161 | return RaggedTensor(self.r_tensor + self.__convert_to_tensor(other),
162 | True)
163 |
164 | def __iadd__(self, other):
165 | self.r_tensor += self.__convert_to_tensor(other)
166 | return self
167 |
168 | def __sub__(self, other):
169 | return RaggedTensor(self.r_tensor - self.__convert_to_tensor(other),
170 | True)
171 |
172 | def __isub__(self, other):
173 | self.r_tensor -= self.__convert_to_tensor(other)
174 | return self
175 |
176 | def __mul__(self, other):
177 | return RaggedTensor(self.r_tensor * self.__convert_to_tensor(other),
178 | True)
179 |
180 | def __imul__(self, other):
181 | self.r_tensor *= self.__convert_to_tensor(other)
182 | return self
183 |
184 | def __truediv__(self, other):
185 | return RaggedTensor(self.r_tensor / self.__convert_to_tensor(other),
186 | True)
187 |
188 | def __itruediv__(self, other):
189 | self.r_tensor /= self.__convert_to_tensor(other)
190 | return self
191 |
192 | def __floordiv__(self, other):
193 | return RaggedTensor(self.r_tensor // self.__convert_to_tensor(other),
194 | True)
195 |
196 | def __ifloordiv__(self, other):
197 | self.r_tensor //= self.__convert_to_tensor(other)
198 | return self
199 |
200 | def __convert_to_tensor(self, value):
201 | """Converts scalar/tensor/RaggedTensor to torch.Tensor"""
202 | if isinstance(value, RaggedTensor):
203 | if self.row_splits.shape != value.row_splits.shape or torch.any(
204 | self.row_splits != value.row_splits).item():
205 | raise ValueError(
206 | f"Incompatible shape : {self.row_splits} and {value.row_splits}"
207 | )
208 | return value.values
209 | elif isinstance(value, torch.Tensor):
210 | return value
211 | elif isinstance(value, (int, float, bool)):
212 | return torch.Tensor([value]).to(type(value))
213 | else:
214 | raise ValueError(f"Unknown type : {type(value)}")
215 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/configs.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Config files for ml3d."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.configs import *
34 | else:
35 | from open3d._ml3d.configs import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/dataloaders.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Dataloader for PyTorch."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.torch.dataloaders import *
34 | else:
35 | from open3d._ml3d.torch.dataloaders import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/datasets.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """I/O, attributes, and processing for different datasets."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.datasets import *
34 | else:
35 | from open3d._ml3d.datasets import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/layers/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """High level layer API for building networks.
27 |
28 | This module contains layers for processing 3D data.
29 | All layers subclass torch.nn.Module
30 | """
31 | from ..python.layers.neighbor_search import *
32 | from ..python.layers.convolutions import *
33 | from ..python.layers.voxel_pooling import *
34 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/models.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """PyTorch network models."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.torch.models import *
34 | else:
35 | from open3d._ml3d.torch.models import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/modules.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Loss and Metric modules for PyTorch."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.torch.modules import losses
34 | from ml3d.torch.modules import metrics
35 | else:
36 | from open3d._ml3d.torch.modules import losses
37 | from open3d._ml3d.torch.modules import metrics
38 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/ops/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Functional API with operators.
27 |
28 | These are the building blocks for the layers. See The layer API for an easy to
29 | use high level interface.
30 | """
31 | from ..python.ops import *
32 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/pipelines.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """3D ML pipelines for PyTorch."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.torch.pipelines import *
34 | else:
35 | from open3d._ml3d.torch.pipelines import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/python/layers/voxel_pooling.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | from ...python import ops
28 | import torch
29 |
30 | __all__ = ['VoxelPooling']
31 |
32 |
33 | class VoxelPooling(torch.nn.Module):
34 | """Voxel pooling for 3D point clouds.
35 |
36 | Spatial pooling for point clouds by combining points that fall into the same voxel bin.
37 |
38 | The voxel grid used for pooling is always aligned to the origin (0,0,0) to
39 | simplify building voxel grid hierarchies. The order of the returned voxels is
40 | not defined as can be seen in the following example::
41 |
42 | import torch
43 | import open3d.ml.torch as ml3d
44 |
45 | positions = torch.Tensor([
46 | [0.1,0.1,0.1],
47 | [0.5,0.5,0.5],
48 | [1.7,1.7,1.7],
49 | [1.8,1.8,1.8],
50 | [0.3,2.4,1.4]])
51 |
52 | features = torch.Tensor([
53 | [1.0,2.0],
54 | [1.1,2.3],
55 | [4.2,0.1],
56 | [1.3,3.4],
57 | [2.3,1.9]])
58 |
59 | voxel_pooling = ml3d.layers.VoxelPooling(position_fn='center', feature_fn='max')
60 |
61 | ans = voxel_pooling(positions, features, 1.0)
62 |
63 | # returns the voxel centers in
64 | # ans.pooled_positions = [[0.5, 2.5, 1.5],
65 | # [1.5, 1.5, 1.5],
66 | # [0.5, 0.5, 0.5]]
67 | #
68 | # and the max pooled features for each voxel in
69 | # ans.pooled_features = [[2.3, 1.9],
70 | # [4.2, 3.4],
71 | # [1.1, 2.3]]
72 |
73 | Arguments:
74 | position_fn: Defines how the new point positions will be computed.
75 | The options are
76 | * "average" computes the center of gravity for the points within one voxel.
77 | * "nearest_neighbor" selects the point closest to the voxel center.
78 | * "center" uses the voxel center for the position of the generated point.
79 |
80 | feature_fn: Defines how the pooled features will be computed.
81 | The options are
82 | * "average" computes the average feature vector.
83 | * "nearest_neighbor" selects the feature vector of the point closest to the voxel center.
84 | * "max" uses the maximum feature among all points within the voxel.
85 | """
86 |
87 | def __init__(self, position_fn='center', feature_fn='max', **kwargs):
88 | super().__init__()
89 | self.position_fn = position_fn
90 | self.feature_fn = feature_fn
91 |
92 | def forward(self, positions, features, voxel_size):
93 | """This function computes the pooled positions and features.
94 |
95 | Arguments:
96 | positions: The point positions with shape [N,3] with N as the number of points.
97 | *This argument must be given as a positional argument!*
98 |
99 | features: The feature vector with shape [N,channels].
100 |
101 | voxel_size: The voxel size.
102 |
103 | Returns:
104 | 2 Tensors in the following order:
105 |
106 | pooled_positions
107 | The output point positions with shape [M,3] and M <= N.
108 |
109 | pooled_features:
110 | The output point features with shape [M,channnels] and M <= N.
111 | """
112 | if isinstance(voxel_size, (float, int)):
113 | voxel_size = torch.tensor(voxel_size, dtype=positions.dtype)
114 | result = ops.voxel_pooling(positions,
115 | features,
116 | voxel_size,
117 | position_fn=self.position_fn,
118 | feature_fn=self.feature_fn)
119 | return result
120 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/python/ops.py.in:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | # This file is machine generated. Do not modify.
28 | import torch as _torch
29 | from . import return_types
30 |
31 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/python/return_types.py.in:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | # This file is machine generated. Do not modify.
28 | from collections import namedtuple as _namedtuple
29 |
30 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/torch/vis.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Visualizer for 3D ML."""
27 |
28 | import os as _os
29 | from open3d import _build_config
30 |
31 | if _build_config['BUNDLE_OPEN3D_ML']:
32 | if 'OPEN3D_ML_ROOT' in _os.environ:
33 | from ml3d.vis import *
34 | else:
35 | from open3d._ml3d.vis import *
36 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/utils.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import os as _os
28 | from open3d import _build_config
29 |
30 | if _build_config['BUNDLE_OPEN3D_ML']:
31 | if 'OPEN3D_ML_ROOT' in _os.environ:
32 | from ml3d.utils import *
33 | else:
34 | from open3d._ml3d.utils import *
35 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/ml/vis.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import os as _os
28 | from open3d import _build_config
29 |
30 | if _build_config['BUNDLE_OPEN3D_ML']:
31 | if 'OPEN3D_ML_ROOT' in _os.environ:
32 | from ml3d.vis import *
33 | else:
34 | from open3d._ml3d.vis import *
35 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import open3d
28 | if open3d.__DEVICE_API__ == 'cuda':
29 | if "OFF" == "ON":
30 | from open3d.cuda.pybind.visualization import gui
31 | from open3d.cuda.pybind.visualization import *
32 | else:
33 | if "OFF" == "ON":
34 | from open3d.cpu.pybind.visualization import gui
35 | from open3d.cpu.pybind.visualization import *
36 |
37 | from ._external_visualizer import *
38 |
39 | if "OFF" == "ON":
40 | from .draw import draw
41 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/__main__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import sys
28 | import argparse
29 | import open3d
30 |
31 | parser = argparse.ArgumentParser(
32 | description=
33 | "This module can be run from the command line to start an external visualizer window.",
34 | formatter_class=argparse.ArgumentDefaultsHelpFormatter)
35 | parser.add_argument(
36 | "--external-vis",
37 | action="store_true",
38 | help="Starts the external visualizer with the RPC interface")
39 |
40 | if len(sys.argv) == 1:
41 | parser.print_help(sys.stderr)
42 | sys.exit(1)
43 |
44 | args = parser.parse_args()
45 |
46 | if args.external_vis:
47 | if open3d._build_config['BUILD_GUI']:
48 | from .draw import draw
49 | draw(show_ui=True, rpc_interface=True)
50 | else:
51 | print(
52 | "Open3D must be build with BUILD_GUI=ON to start an external visualizer."
53 | )
54 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/_external_visualizer.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import open3d as o3d
28 |
29 | __all__ = ['ExternalVisualizer', 'EV']
30 |
31 |
32 | class ExternalVisualizer:
33 | """This class allows to send data to an external Visualizer
34 |
35 | Example:
36 | This example sends a point cloud to the visualizer::
37 |
38 | import open3d as o3d
39 | import numpy as np
40 | ev = o3d.visualization.ExternalVisualizer()
41 | pcd = o3d.geometry.PointCloud(o3d.utility.Vector3dVector(np.random.rand(100,3)))
42 | ev.set(pcd)
43 |
44 | Args:
45 | address: The address where the visualizer is running.
46 | The default is localhost.
47 | timeout: The timeout for sending data in milliseconds.
48 | """
49 |
50 | def __init__(self, address='tcp://127.0.0.1:51454', timeout=10000):
51 | self.address = address
52 | self.timeout = timeout
53 |
54 | def set(self, obj=None, path='', time=0, layer='', connection=None):
55 | """Send Open3D objects for visualization to the visualizer.
56 |
57 | Example:
58 | To quickly send a single object just write::
59 | ev.set(point_cloud)
60 |
61 | To place the object at a specific location in the scene tree do::
62 | ev.set(point_cloud, path='group/mypoints', time=42, layer='')
63 | Note that depending on the visualizer some arguments like time or
64 | layer may not be supported and will be ignored.
65 |
66 | To set multiple objects use a list to pass multiple objects::
67 | ev.set([point_cloud, mesh, camera])
68 | Each entry in the list can be a tuple specifying all or some of the
69 | location parameters::
70 | ev.set(objs=[(point_cloud,'group/mypoints', 1, 'layer1'),
71 | (mesh, 'group/mymesh'),
72 | camera
73 | ]
74 |
75 | Args:
76 | obj: A geometry or camera object or a list of objects. See the
77 | example seection for usage instructions.
78 |
79 | path: A path describing a location in the scene tree.
80 |
81 | time: An integer time value associated with the object.
82 |
83 | layer: The layer associated with the object.
84 |
85 | connection: A connection object to use for sending data. This
86 | parameter can be used to override the default object.
87 | """
88 | if connection is None:
89 | connection = o3d.io.rpc.Connection(address=self.address,
90 | timeout=self.timeout)
91 | result = []
92 | if isinstance(obj, (tuple, list)):
93 | # item can be just an object or a tuple with path, time, layer, e.g.,
94 | # set(obj=[point_cloud, mesh, camera])
95 | # set(obj=[(point_cloud,'group/mypoints', 1, 'layer1'),
96 | # (mesh, 'group/mymesh'),
97 | # camera
98 | # ]
99 | for item in obj:
100 | if isinstance(item, (tuple, list)):
101 | if len(item) in range(1, 5):
102 | result.append(self.set(*item, connection=connection))
103 | else:
104 | result.append(self.set(item, connection=connection))
105 | elif isinstance(obj, o3d.geometry.PointCloud):
106 | status = o3d.io.rpc.set_point_cloud(obj,
107 | path=path,
108 | time=time,
109 | layer=layer,
110 | connection=connection)
111 | result.append(status)
112 | elif isinstance(obj, o3d.geometry.TriangleMesh):
113 | status = o3d.io.rpc.set_triangle_mesh(obj,
114 | path=path,
115 | time=time,
116 | layer=layer,
117 | connection=connection)
118 | result.append(status)
119 | elif isinstance(obj, o3d.camera.PinholeCameraParameters):
120 | status = o3d.io.rpc.set_legacy_camera(obj,
121 | path=path,
122 | time=time,
123 | layer=layer,
124 | connection=connection)
125 | result.append(status)
126 | else:
127 | raise Exception("Unsupported object type '{}'".format(str(
128 | type(obj))))
129 |
130 | return all(result)
131 |
132 | def set_time(self, time):
133 | """Sets the time in the external visualizer
134 |
135 | Note that this function is a placeholder for future functionality and
136 | not yet supported by the receiving visualizer.
137 |
138 | Args:
139 | time: The time value
140 | """
141 | connection = o3d.io.rpc.Connection(address=self.address,
142 | timeout=self.timeout)
143 | return o3d.io.rpc.set_time(time, connection)
144 |
145 | def set_active_camera(self, path):
146 | """Sets the active camera in the external visualizer
147 |
148 | Note that this function is a placeholder for future functionality and
149 | not yet supported by the receiving visualizer.
150 |
151 | Args:
152 | path: A path describing a location in the scene tree.
153 | """
154 | connection = o3d.io.rpc.Connection(address=self.address,
155 | timeout=self.timeout)
156 | return o3d.io.rpc.set_active_camera(path, connection)
157 |
158 | def draw(self, geometry=None, *args, **kwargs):
159 | """This function has the same functionality as 'set'.
160 |
161 | This function is compatible with the standalone 'draw' function and can
162 | be used to redirect calls to the external visualizer. Note that only
163 | the geometry argument is supported, all other arguments will be
164 | ignored.
165 |
166 | Example:
167 | Here we use draw with the default external visualizer::
168 | import open3d as o3d
169 |
170 | torus = o3d.geometry.TriangleMesh.create_torus()
171 | sphere = o3d.geometry.TriangleMesh.create_sphere()
172 |
173 | draw = o3d.visualization.EV.draw
174 | draw([ {'geometry': sphere, 'name': 'sphere'},
175 | {'geometry': torus, 'name': 'torus', 'time': 1} ])
176 |
177 | # now use the standard draw function as comparison
178 | draw = o3d.visualization.draw
179 | draw([ {'geometry': sphere, 'name': 'sphere'},
180 | {'geometry': torus, 'name': 'torus', 'time': 1} ])
181 |
182 | Args:
183 | geometry: The geometry to draw. This can be a geometry object, a
184 | list of geometries. To pass additional information along with the
185 | geometry we can use a dictionary. Supported keys for the dictionary
186 | are 'geometry', 'name', and 'time'.
187 | """
188 | if args or kwargs:
189 | import warnings
190 | warnings.warn(
191 | "ExternalVisualizer.draw() does only support the 'geometry' argument",
192 | Warning)
193 |
194 | def add(g):
195 | if isinstance(g, dict):
196 | obj = g['geometry']
197 | path = g.get('name', '')
198 | time = g.get('time', 0)
199 | self.set(obj=obj, path=path, time=time)
200 | else:
201 | self.set(g)
202 |
203 | if isinstance(geometry, (tuple, list)):
204 | for g in geometry:
205 | add(g)
206 | elif geometry is not None:
207 | add(geometry)
208 |
209 |
210 | # convenience default external visualizer
211 | EV = ExternalVisualizer()
212 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/async_event_loop.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Run the GUI event loop in a non-main thread. This allows using the
27 | GUI from plugins to other apps (e.g.: Jupyter or Tensorboard) where the GUI
28 | cannot be started in the main thread. Currently does not work in macOS.
29 |
30 | .. note:: This is a singleton class implemented with this module as a
31 | holder. The ``async_event_loop`` singleton is started whenever this
32 | module is imported. If you are using remote visualization with WebRTC,
33 | you must call ``enable_webrtc()`` before importing this module.
34 | """
35 | import threading
36 | from collections import deque
37 | import open3d as o3d
38 |
39 |
40 | class _AsyncEventLoop:
41 |
42 | class _Task:
43 | _g_next_id = 0
44 |
45 | def __init__(self, func, *args, **kwargs):
46 | self.task_id = self._g_next_id
47 | self.func = func, args, kwargs
48 | _AsyncEventLoop._Task._g_next_id += 1
49 |
50 | def __init__(self):
51 | # TODO (yixing): find a better solution. Currently py::print acquires
52 | # GIL which causes deadlock when AsyncEventLoop is used. By calling
53 | # reset_print_function(), all C++ prints will be directed to the
54 | # terminal while python print will still remain in the cell.
55 | o3d.utility.reset_print_function()
56 | self._lock = threading.Lock()
57 | self._cv = threading.Condition(self._lock)
58 | self._run_queue = deque()
59 | self._return_vals = {}
60 | self._started = False
61 | self._start()
62 |
63 | def _start(self):
64 | if not self._started:
65 | self._thread = threading.Thread(name="GUIMain",
66 | target=self._thread_main)
67 | self._thread.start()
68 | self._started = True
69 |
70 | def run_sync(self, func, *args, **kwargs):
71 | """Enqueue task, wait for completion and return result. Can run in any
72 | thread.
73 | """
74 | from open3d.visualization.tensorboard_plugin.util import _log
75 | if not self._started:
76 | raise RuntimeError("GUI thread has exited.")
77 |
78 | with self._lock:
79 | task = _AsyncEventLoop._Task(func, *args, **kwargs)
80 | self._run_queue.append(task)
81 |
82 | while True:
83 | with self._cv:
84 | self._cv.wait_for(lambda: task.task_id in self._return_vals)
85 | with self._lock:
86 | return self._return_vals.pop(task.task_id)
87 |
88 | def _thread_main(self):
89 | """Main GUI thread event loop"""
90 | app = o3d.visualization.gui.Application.instance
91 | app.initialize()
92 |
93 | done = False
94 | while not done:
95 | while len(self._run_queue) > 0:
96 | with self._lock:
97 | task = self._run_queue.popleft()
98 | func, args, kwargs = task.func
99 | retval = func(*args, **kwargs)
100 | with self._cv:
101 | self._return_vals[task.task_id] = retval
102 | self._cv.notify_all()
103 |
104 | done = not app.run_one_tick()
105 |
106 | self._started = False # Main GUI thread has exited
107 |
108 |
109 | # The _AsyncEventLoop class shall only be used to create a singleton instance.
110 | # There are different ways to achieve this, here we use the module as a holder
111 | # for singleton variables, see: https://stackoverflow.com/a/31887/1255535.
112 | async_event_loop = _AsyncEventLoop()
113 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/draw.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | from . import gui
28 | from . import O3DVisualizer
29 |
30 |
31 | def draw(geometry=None,
32 | title="Open3D",
33 | width=1024,
34 | height=768,
35 | actions=None,
36 | lookat=None,
37 | eye=None,
38 | up=None,
39 | field_of_view=60.0,
40 | bg_color=(1.0, 1.0, 1.0, 1.0),
41 | bg_image=None,
42 | ibl=None,
43 | ibl_intensity=None,
44 | show_skybox=None,
45 | show_ui=None,
46 | point_size=None,
47 | line_width=None,
48 | animation_time_step=1.0,
49 | animation_duration=None,
50 | rpc_interface=False,
51 | on_init=None,
52 | on_animation_frame=None,
53 | on_animation_tick=None,
54 | non_blocking_and_return_uid=False):
55 | gui.Application.instance.initialize()
56 | w = O3DVisualizer(title, width, height)
57 | w.set_background(bg_color, bg_image)
58 |
59 | if actions is not None:
60 | for a in actions:
61 | w.add_action(a[0], a[1])
62 |
63 | if point_size is not None:
64 | w.point_size = point_size
65 |
66 | if line_width is not None:
67 | w.line_width = line_width
68 |
69 | def add(g, n):
70 | if isinstance(g, dict):
71 | w.add_geometry(g)
72 | else:
73 | w.add_geometry("Object " + str(n), g)
74 |
75 | n = 1
76 | if isinstance(geometry, list):
77 | for g in geometry:
78 | add(g, n)
79 | n += 1
80 | elif geometry is not None:
81 | add(geometry, n)
82 |
83 | w.reset_camera_to_default() # make sure far/near get setup nicely
84 | if lookat is not None and eye is not None and up is not None:
85 | w.setup_camera(field_of_view, lookat, eye, up)
86 |
87 | w.animation_time_step = animation_time_step
88 | if animation_duration is not None:
89 | w.animation_duration = animation_duration
90 |
91 | if show_ui is not None:
92 | w.show_settings = show_ui
93 |
94 | if ibl is not None:
95 | w.set_ibl(ibl)
96 |
97 | if ibl_intensity is not None:
98 | w.set_ibl_intensity(ibl_intensity)
99 |
100 | if show_skybox is not None:
101 | w.show_skybox(show_skybox)
102 |
103 | if rpc_interface:
104 | w.start_rpc_interface(address="tcp://127.0.0.1:51454", timeout=10000)
105 |
106 | def stop_rpc():
107 | w.stop_rpc_interface()
108 | return True
109 |
110 | w.set_on_close(stop_rpc)
111 |
112 | if on_init is not None:
113 | on_init(w)
114 | if on_animation_frame is not None:
115 | w.set_on_animation_frame(on_animation_frame)
116 | if on_animation_tick is not None:
117 | w.set_on_animation_tick(on_animation_tick)
118 |
119 | gui.Application.instance.add_window(w)
120 | if non_blocking_and_return_uid:
121 | return w.uid
122 | else:
123 | gui.Application.instance.run()
124 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/gui/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Functionality for quickly building Graphical User Interfaces."""
27 |
28 | if "OFF" == "ON":
29 | import open3d
30 | if open3d.__DEVICE_API__ == 'cuda':
31 | from open3d.cuda.pybind.visualization.gui import *
32 | else:
33 | from open3d.cpu.pybind.visualization.gui import *
34 | else:
35 | print("Open3D was not compiled with BUILD_GUI, but script is importing "
36 | "open3d.visualization.gui")
37 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/rendering/__init__.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Functionality for Physically Based Rendering."""
27 |
28 | if "OFF" == "ON":
29 | import open3d
30 | if open3d.__DEVICE_API__ == 'cuda':
31 | from open3d.cuda.pybind.visualization.rendering import *
32 | else:
33 | from open3d.cpu.pybind.visualization.rendering import *
34 | else:
35 | print("Open3D was not compiled with BUILD_GUI, but script is importing "
36 | "open3d.visualization.rendering")
37 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/tensorboard_plugin/frontend/style.css:
--------------------------------------------------------------------------------
1 | /* ----------------------------------------------------------------------------
2 | // - Open3D: www.open3d.org -
3 | // ----------------------------------------------------------------------------
4 | // The MIT License (MIT)
5 | //
6 | // Copyright (c) 2018-2021 www.open3d.org
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | // IN THE SOFTWARE.
25 | // ----------------------------------------------------------------------------
26 | */
27 |
28 | /* Code style: With config stylelint-config-standard do stylelint --fix filename.css */
29 |
30 | /* Styles for the Open3D Tensorboard plugin */
31 |
32 | @import url('https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,500italic,700,700italic');
33 | @import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,700');
34 |
35 | /* tensorboardColorBlindAssist (standard) palette from tensorboard/components/tf_color_scale/palettes.ts */
36 | :root {
37 | --paper-grey-800: #424242;
38 | --tb-ui-dark-accent: #757575;
39 | --primary-background-color: #fff;
40 | --tb-run-color-0: #ff7043; /* orange */
41 | --tb-run-color-1: #0077bb; /* blue */
42 | --tb-run-color-2: #cc3311; /* red */
43 | --tb-run-color-3: #33bbee; /* cyan */
44 | --tb-run-color-4: #ee3377; /* magenta*/
45 | --tb-run-color-5: #009988; /* teal */
46 | --tb-run-color-6: #bbbbbb; /* grey */
47 | }
48 |
49 | html,
50 | body {
51 | font-family: Roboto, sans-serif;
52 |
53 | /* color: #212121; /1* TB: --paper-gray-900 *1/
54 | background-color: #f5f5f5; /1* --tb-layout-background-color *1/ */
55 | }
56 |
57 | #open3d-dashboard {
58 | /* Layout children as flex */
59 | display: flex;
60 | flex-direction: row;
61 | padding: 1em;
62 | }
63 |
64 | /* Options for the whole plugin, runs and tag selection */
65 | #options-selector {
66 | /* Layout children as flex */
67 | display: flex;
68 | flex-direction: column;
69 | height: 100%;
70 | min-width: 20em;
71 | overflow-wrap: break-word;
72 | word-break: break-all;
73 | padding: 5px;
74 | color: var(--paper-grey-800);
75 | }
76 |
77 | #run-selector,
78 | #tag-selector {
79 | height: 40%;
80 | padding: 5px;
81 | }
82 |
83 | #logdir {
84 | color: var(--tb-ui-dark-accent);
85 | }
86 |
87 | /* Container for all runs */
88 |
89 | /* width is 6x left selctor, min-width=576px */
90 | #widget-view {
91 | background-color: var(--primary-background-color);
92 |
93 | /* parent is flex container. Most of the width increase goes here. */
94 | flex: 16 576;
95 |
96 | /* Layout children as flex */
97 | display: flex;
98 | flex-flow: row wrap;
99 | }
100 |
101 | /* Container for a single run */
102 | .webrtc {
103 | z-index: 1000;
104 |
105 | /* Layout children as flex */
106 | display: flex;
107 | flex-direction: column;
108 | padding: 1em;
109 | }
110 |
111 | .webrtc td {
112 | text-align: center;
113 | }
114 |
115 | .webrtc td:first-child {
116 | text-align: left;
117 | }
118 |
119 | .webrtc td:last-child {
120 | text-align: right;
121 | }
122 |
123 | .webrtc button {
124 | width: 3em;
125 | height: 3em;
126 | display: inline;
127 | }
128 |
129 | .webrtc button svg {
130 | height: 100%;
131 | margin: -35%;
132 | }
133 |
134 | .batchidx-step-selector {
135 | display: flex;
136 | flex-direction: column;
137 | padding: 5px;
138 | color: var(--paper-grey-800);
139 | }
140 |
141 | .batchidx-step-selector input {
142 | vertical-align: middle;
143 | width: 50%;
144 | }
145 |
146 | .batchidx-step-selector label {
147 | font-weight: bold;
148 | }
149 |
150 | .batchidx-step-selector label span {
151 | width: 10em;
152 | text-align: right;
153 | display: inline-block;
154 | }
155 |
156 | .batchidx-step-selector output {
157 | width: 4em;
158 | text-indent: 2em;
159 | font-weight: bold;
160 | display: inline-block;
161 | }
162 |
163 | select {
164 | font-size: inherit; /* Dont make options smaller */
165 | }
166 |
167 | /* Add color accent to match run widget to tun table */
168 | .webrtc:nth-child(7n+1) tbody {
169 | border-bottom: solid 4px var(--tb-run-color-0);
170 | }
171 |
172 | .webrtc:nth-child(7n+2) tbody {
173 | border-bottom: solid 4px var(--tb-run-color-1);
174 | }
175 |
176 | .webrtc:nth-child(7n+3) tbody {
177 | border-bottom: solid 4px var(--tb-run-color-2);
178 | }
179 |
180 | .webrtc:nth-child(7n+4) tbody {
181 | border-bottom: solid 4px var(--tb-run-color-3);
182 | }
183 |
184 | .webrtc:nth-child(7n+5) tbody {
185 | border-bottom: solid 4px var(--tb-run-color-4);
186 | }
187 |
188 | .webrtc:nth-child(7n+6) tbody {
189 | border-bottom: solid 4px var(--tb-run-color-5);
190 | }
191 |
192 | .webrtc:nth-child(7n) tbody {
193 | border-bottom: solid 4px var(--tb-run-color-6);
194 | }
195 |
196 | .selector {
197 | display: grid;
198 | position: relative;
199 | align-items: center;
200 | text-transform: capitalize;
201 | }
202 |
203 | .sel-1button div {
204 | grid-template-columns: 2em auto;
205 | }
206 |
207 | .sel-2button div {
208 | grid-template-columns: 2em 2em auto;
209 | }
210 |
211 | .selector > * {
212 | margin: 0.3em 1em;
213 | }
214 |
215 | .selector button {
216 | width: 2em;
217 | height: 2em;
218 | }
219 |
220 | /* Hide disabled button */
221 | .selector button:disabled {
222 | opacity: 0;
223 | }
224 |
225 | .selector button svg {
226 | width: 150%;
227 | height: 150%;
228 | margin: -35%;
229 | }
230 |
231 | .selector input[type="checkbox"] {
232 | width: 1.5em;
233 | height: 1.5em;
234 | accent-color: var(--tb-ui-dark-accent);
235 | }
236 |
237 | .property-ui {
238 | display: block;
239 | position: relative;
240 | margin: 1em;
241 | cursor: pointer;
242 | font-size: inherit;
243 | }
244 |
245 | .property-ui label {
246 | padding-left: 2em;
247 | font-size: inherit;
248 | }
249 |
250 | .property-ui input {
251 | font-size: inherit;
252 | }
253 |
254 | .property-ui input[type="number"] {
255 | width: 5em;
256 | }
257 |
258 | .property-ui option {
259 | text-transform: capitalize;
260 | }
261 |
262 | .property-ui-colormap {
263 | align-items: center;
264 | display: grid;
265 | padding: 0.1em;
266 | grid-template-columns: 3.5em 6.5em 2em;
267 | column-gap: 1em;
268 | }
269 |
270 | .property-ui-colormap input[type="text"] {
271 | border-width: 0;
272 | font-size: inherit;
273 | }
274 |
275 | .property-ui-colormap input[type="checkbox"] {
276 | width: 20px;
277 | height: 20px;
278 | accent-color: var(--tb-ui-dark-accent);
279 | }
280 |
281 | /* Add color accent to match run widget to tun table */
282 | #run-selector .selector:nth-child(7n+1) input[type="checkbox"],
283 | .webrtc:nth-child(7n+1) input[type="range"] {
284 | accent-color: var(--tb-run-color-0);
285 | }
286 |
287 | #run-selector .selector:nth-child(7n+2) input[type="checkbox"],
288 | .webrtc:nth-child(7n+2) input[type="range"] {
289 | accent-color: var(--tb-run-color-1);
290 | }
291 |
292 | #run-selector .selector:nth-child(7n+3) input[type="checkbox"],
293 | .webrtc:nth-child(7n+3) input[type="range"] {
294 | accent-color: var(--tb-run-color-2);
295 | }
296 |
297 | #run-selector .selector:nth-child(7n+4) input[type="checkbox"],
298 | .webrtc:nth-child(7n+4) input[type="range"] {
299 | accent-color: var(--tb-run-color-3);
300 | }
301 |
302 | #run-selector .selector:nth-child(7n+5) input[type="checkbox"],
303 | .webrtc:nth-child(7n+5) input[type="range"] {
304 | accent-color: var(--tb-run-color-4);
305 | }
306 |
307 | #run-selector .selector:nth-child(7n+6) input[type="checkbox"],
308 | .webrtc:nth-child(7n+6) input[type="range"] {
309 | accent-color: var(--tb-run-color-5);
310 | }
311 |
312 | #run-selector .selector:nth-child(7n) input[type="checkbox"],
313 | .webrtc:nth-child(7n) input[type="range"] {
314 | accent-color: var(--tb-run-color-6);
315 | }
316 |
317 | .property-ui-colormap input[type="color"] {
318 | border-radius: 50%;
319 | border: 1px solid white;
320 | height: 32px;
321 | width: 32px;
322 | outline: none;
323 | }
324 |
325 | /* Busy indicator while loading
326 | * From: https://www.w3schools.com/howto/howto_css_loader.asp
327 | */
328 | .loader {
329 | position: fixed;
330 | width: 120px;
331 | height: 120px;
332 | top: 50%;
333 | left: 50%;
334 | border: 16px solid whitesmoke;
335 | border-top: 16px solid darkgray;
336 | border-bottom: 16px solid darkgray;
337 | border-radius: 50%;
338 | animation: spin 2s linear infinite;
339 | z-index: 2000; /* Higher than for .webrtc */
340 | opacity: 50%;
341 | }
342 |
343 | @keyframes spin {
344 | 0% { transform: rotate(0deg); }
345 | 100% { transform: rotate(360deg); }
346 | }
347 |
348 | /* Error message when network connection is lost */
349 | .no-webrtc {
350 | padding: 8px;
351 | position: fixed;
352 | width: 25em;
353 | top: 20em;
354 | left: 40em;
355 | background-color: black;
356 | color: white;
357 | border-radius: 1em;
358 | }
359 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/tensorboard_plugin/metadata.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 | """Internal information about the Open3D plugin."""
27 |
28 | from tensorboard.compat.proto.summary_pb2 import SummaryMetadata
29 | from .plugin_data_pb2 import LabelToNames
30 |
31 | PLUGIN_NAME = "Open3D"
32 |
33 | # The most recent value for the `version` field of the
34 | # `Open3DPluginData` proto. Sync with Open3D version (MAJOR*100 + MINOR)
35 | _VERSION = 14
36 |
37 | SUPPORTED_FILEFORMAT_VERSIONS = [14]
38 |
39 | GEOMETRY_PROPERTY_DIMS = {
40 | 'vertex_positions': (3,),
41 | 'vertex_normals': (3,),
42 | 'vertex_colors': (3,),
43 | 'vertex_texture_uvs': (2,),
44 | 'triangle_indices': (3,),
45 | 'triangle_normals': (3,),
46 | 'triangle_colors': (3,),
47 | 'triangle_texture_uvs': (3, 2),
48 | 'line_indices': (2,),
49 | 'line_colors': (3,)
50 | }
51 | VERTEX_PROPERTIES = ('vertex_normals', 'vertex_colors', 'vertex_texture_uvs')
52 | TRIANGLE_PROPERTIES = ('triangle_normals', 'triangle_colors',
53 | 'triangle_texture_uvs')
54 | LINE_PROPERTIES = ('line_colors',)
55 | MATERIAL_SCALAR_PROPERTIES = (
56 | 'point_size',
57 | 'line_width',
58 | 'metallic',
59 | 'roughness',
60 | 'reflectance',
61 | # 'sheen_roughness',
62 | 'clear_coat',
63 | 'clear_coat_roughness',
64 | 'anisotropy',
65 | 'ambient_occlusion',
66 | # 'ior',
67 | 'transmission',
68 | # 'micro_thickness',
69 | 'thickness',
70 | 'absorption_distance',
71 | )
72 | MATERIAL_VECTOR_PROPERTIES = (
73 | 'base_color',
74 | # 'sheen_color',
75 | # 'anisotropy_direction',
76 | 'normal',
77 | # 'bent_normal',
78 | # 'clear_coat_normal',
79 | # 'emissive',
80 | # 'post_lighting_color',
81 | 'absorption_color',
82 | )
83 | MATERIAL_TEXTURE_MAPS = (
84 | 'albedo', # same as base_color
85 | # Ambient occlusion, roughness, and metallic maps in a single 3 channel
86 | # texture. Commonly used in glTF models.
87 | 'ao_rough_metal',
88 | )
89 |
90 | SUPPORTED_PROPERTIES = set(
91 | tuple(GEOMETRY_PROPERTY_DIMS.keys()) + ("material_name",) +
92 | tuple("material_scalar_" + p for p in MATERIAL_SCALAR_PROPERTIES) +
93 | tuple("material_vector_" + p for p in MATERIAL_VECTOR_PROPERTIES) +
94 | tuple("material_texture_map_" + p for p in
95 | (MATERIAL_SCALAR_PROPERTIES[2:] + # skip point_size, line_width
96 | MATERIAL_VECTOR_PROPERTIES[1:] + # skip base_color
97 | MATERIAL_TEXTURE_MAPS)))
98 |
99 |
100 | def create_summary_metadata(description, metadata):
101 | """Creates summary metadata. Reserved for future use. Required by
102 | TensorBoard.
103 |
104 | Args:
105 | description: The description to show in TensorBoard.
106 |
107 | Returns:
108 | A `SummaryMetadata` protobuf object.
109 | """
110 | ln_proto = LabelToNames()
111 | if 'label_to_names' in metadata:
112 | ln_proto.label_to_names.update(metadata['label_to_names'])
113 | return SummaryMetadata(
114 | summary_description=description,
115 | plugin_data=SummaryMetadata.PluginData(
116 | plugin_name=PLUGIN_NAME, content=ln_proto.SerializeToString()),
117 | )
118 |
119 |
120 | def parse_plugin_metadata(content):
121 | """Parse summary metadata to a Python object. Reserved for future use.
122 |
123 | Arguments:
124 | content: The `content` field of a `SummaryMetadata` proto
125 | corresponding to the Open3D plugin.
126 | """
127 | ln_proto = LabelToNames()
128 | ln_proto.ParseFromString(content)
129 | return ln_proto.label_to_names
130 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/visualization/tensorboard_plugin/plugin_data.proto:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | // - Open3D: www.open3d.org -
3 | // ----------------------------------------------------------------------------
4 | // The MIT License (MIT)
5 | //
6 | // Copyright (c) 2018-2021 www.open3d.org
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | // IN THE SOFTWARE.
25 | // ----------------------------------------------------------------------------
26 |
27 | // To generate plugin_data_pb2.py, use this command:
28 | // protoc -I=. --python_out=. plugin_data.proto
29 | // copy over license and use make apply-style to correct formatting.
30 |
31 | syntax = "proto3";
32 |
33 | package tensorboard.open3d;
34 |
35 | // A Open3DPluginData encapsulates information on which plugins are able to make
36 | // use of a certain summary value.
37 | message Open3DPluginData {
38 | // Version 14 is the only supported version.
39 | int32 version = 1;
40 |
41 | enum GeometryProperty {
42 | /* Reserved: [0..64) */
43 | vertex_positions = 0;
44 | vertex_normals = 1;
45 | vertex_colors = 2;
46 | vertex_texture_uvs = 3;
47 | triangle_indices = 4;
48 | triangle_colors = 5;
49 | triangle_normals = 6;
50 | triangle_texture_uvs = 7;
51 | line_indices = 8;
52 | line_colors = 9;
53 |
54 | /* Reserved: [64..80) */
55 | material_scalar_metallic = 64;
56 | material_scalar_roughness = 65;
57 | material_scalar_reflectance = 66;
58 | /* material_scalar_sheen_roughness = 67; */
59 | material_scalar_clear_coat = 68;
60 | material_scalar_clear_coat_roughness = 69;
61 | material_scalar_anisotropy = 70;
62 | material_scalar_ambient_occlusion = 71;
63 | /* material_scalar_ior = 72; */
64 | material_scalar_transmission = 73;
65 | /* material_scalar_micro_thickness = 74; */
66 | material_scalar_thickness = 75;
67 | material_scalar_absorption_distance = 76;
68 |
69 | /* Reserved: [80..96) */
70 | material_vector_base_color = 80;
71 | /* material_vector_sheen_color = 81; */
72 | /* material_vector_anisotropy_direction = 82; */
73 | material_vector_normal = 83;
74 | /* material_vector_bent_normal = 84; */
75 | /* material_vector_clear_coat_normal = 85; */
76 | /* material_vector_emissive = 86; */
77 | /* material_vector_post_lighting_color = 87; */
78 | material_vector_absorption_color = 88;
79 |
80 | /* Reserved: [96..128) */
81 | material_texture_map_metallic = 96;
82 | material_texture_map_roughness = 97;
83 | material_texture_map_reflectance = 98;
84 | /* material_texture_map_sheen_roughness = 99; */
85 | material_texture_map_clear_coat = 100;
86 | material_texture_map_clear_coat_roughness = 101;
87 | material_texture_map_anisotropy = 102;
88 | material_texture_map_ambient_occlusion = 103;
89 | /* material_texture_map_ior = 104; */
90 | material_texture_map_transmission = 105;
91 | /* material_texture_map_micro_thickness = 106; */
92 | material_texture_map_thickness = 107;
93 | material_texture_map_albedo = 108; // same as *_base_color
94 | /* material_texture_map_sheen_color = 109; */
95 | /* material_texture_map_anisotropy_direction = 110; */
96 | material_texture_map_normal = 111;
97 | /* material_texture_map_bent_normal = 112; */
98 | /* material_texture_map_clear_coat_normal = 113; */
99 | /* material_texture_map_emissive = 114; */
100 | /* material_texture_map_post_lighting_color = 115; */
101 | material_texture_map_absorption_color = 116;
102 | material_texture_map_ao_rough_metal = 117; // ao + roughness + metallic
103 | }
104 |
105 | // Pick up the tensor for a property (geometry_property) from a previous
106 | // step (step_ref)
107 | message PropertyReference {
108 | GeometryProperty geometry_property = 1;
109 | uint64 step_ref = 2;
110 | }
111 |
112 | // Data start and data size for a single geometry msgpack
113 | message StartSize {
114 | uint64 start = 1;
115 | uint64 size = 2;
116 | uint32 masked_crc32c = 3;
117 | uint64 aux_start = 4;
118 | uint64 aux_size = 5;
119 | uint32 aux_masked_crc32c = 6;
120 | }
121 |
122 | // Index for a batch of geometry data
123 | message BatchIndex {
124 | string filename = 1;
125 | repeated StartSize start_size = 2;
126 | }
127 |
128 | repeated PropertyReference property_references = 2;
129 | BatchIndex batch_index = 3;
130 | }
131 |
132 | message InferenceData {
133 | message InferenceResult {
134 | int32 label = 1;
135 | float confidence = 2;
136 | }
137 | repeated InferenceResult inference_result = 1;
138 | }
139 |
140 | message LabelToNames {
141 | map label_to_names = 1;
142 | }
143 |
--------------------------------------------------------------------------------
/Sources/Open3DSupport/site-packages/open3d/web_visualizer.py:
--------------------------------------------------------------------------------
1 | # ----------------------------------------------------------------------------
2 | # - Open3D: www.open3d.org -
3 | # ----------------------------------------------------------------------------
4 | # The MIT License (MIT)
5 | #
6 | # Copyright (c) 2018-2021 www.open3d.org
7 | #
8 | # Permission is hereby granted, free of charge, to any person obtaining a copy
9 | # of this software and associated documentation files (the "Software"), to deal
10 | # in the Software without restriction, including without limitation the rights
11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | # copies of the Software, and to permit persons to whom the Software is
13 | # furnished to do so, subject to the following conditions:
14 | #
15 | # The above copyright notice and this permission notice shall be included in
16 | # all copies or substantial portions of the Software.
17 | #
18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 | # IN THE SOFTWARE.
25 | # ----------------------------------------------------------------------------
26 |
27 | import ipywidgets
28 | import traitlets
29 | import IPython
30 | import json
31 | import functools
32 | import open3d as o3d
33 | # Note: the _AsyncEventLoop is started whenever this module is imported.
34 | from open3d.visualization.async_event_loop import async_event_loop
35 |
36 | from open3d._build_config import _build_config
37 | if not _build_config["BUILD_JUPYTER_EXTENSION"]:
38 | raise RuntimeError(
39 | "Open3D WebVisualizer Jupyter extension is not available. To use "
40 | "WebVisualizer, build Open3D with -DBUILD_JUPYTER_EXTENSION=ON.")
41 |
42 |
43 | @ipywidgets.register
44 | class WebVisualizer(ipywidgets.DOMWidget):
45 | """Open3D Web Visualizer based on WebRTC."""
46 |
47 | # Name of the widget view class in front-end.
48 | _view_name = traitlets.Unicode('WebVisualizerView').tag(sync=True)
49 |
50 | # Name of the widget model class in front-end.
51 | _model_name = traitlets.Unicode('WebVisualizerModel').tag(sync=True)
52 |
53 | # Name of the front-end module containing widget view.
54 | _view_module = traitlets.Unicode('open3d').tag(sync=True)
55 |
56 | # Name of the front-end module containing widget model.
57 | _model_module = traitlets.Unicode('open3d').tag(sync=True)
58 |
59 | # Version of the front-end module containing widget view.
60 | # is configured by cpp/pybind/make_python_package.cmake.
61 | _view_module_version = traitlets.Unicode(
62 | '~0.14.1').tag(sync=True)
63 | # Version of the front-end module containing widget model.
64 | _model_module_version = traitlets.Unicode(
65 | '~0.14.1').tag(sync=True)
66 |
67 | # Widget specific property. Widget properties are defined as traitlets. Any
68 | # property tagged with `sync=True` is automatically synced to the frontend
69 | # *any* time it changes in Python. It is synced back to Python from the
70 | # frontend *any* time the model is touched.
71 | window_uid = traitlets.Unicode("window_UNDEFINED",
72 | help="Window UID").tag(sync=True)
73 |
74 | # Two-way communication channels.
75 | pyjs_channel = traitlets.Unicode(
76 | "Empty pyjs_channel.",
77 | help="Python->JS message channel.").tag(sync=True)
78 | jspy_channel = traitlets.Unicode(
79 | "Empty jspy_channel.",
80 | help="JS->Python message channel.").tag(sync=True)
81 |
82 | def show(self):
83 | IPython.display.display(self)
84 |
85 | def _call_http_api(self, entry_point, query_string, data):
86 | return o3d.visualization.webrtc_server.call_http_api(
87 | entry_point, query_string, data)
88 |
89 | @traitlets.validate('window_uid')
90 | def _valid_window_uid(self, proposal):
91 | if proposal['value'][:7] != "window_":
92 | raise traitlets.TraitError('window_uid must be "window_xxx".')
93 | return proposal['value']
94 |
95 | @traitlets.observe('jspy_channel')
96 | def _on_jspy_channel(self, change):
97 | # self.result_map = {"0": "result0",
98 | # "1": "result1", ...};
99 | if not hasattr(self, "result_map"):
100 | self.result_map = dict()
101 |
102 | jspy_message = change["new"]
103 | try:
104 | jspy_requests = json.loads(jspy_message)
105 |
106 | for call_id, payload in jspy_requests.items():
107 | if "func" not in payload or payload["func"] != "call_http_api":
108 | raise ValueError(f"Invalid jspy function: {jspy_requests}")
109 | if "args" not in payload or len(payload["args"]) != 3:
110 | raise ValueError(
111 | f"Invalid jspy function arguments: {jspy_requests}")
112 |
113 | # Check if already in result.
114 | if not call_id in self.result_map:
115 | json_result = self._call_http_api(payload["args"][0],
116 | payload["args"][1],
117 | payload["args"][2])
118 | self.result_map[call_id] = json_result
119 | except:
120 | print(
121 | f"jspy_message is not a function call, ignored: {jspy_message}")
122 | else:
123 | self.pyjs_channel = json.dumps(self.result_map)
124 |
125 |
126 | def draw(geometry=None,
127 | title="Open3D",
128 | width=640,
129 | height=480,
130 | actions=None,
131 | lookat=None,
132 | eye=None,
133 | up=None,
134 | field_of_view=60.0,
135 | bg_color=(1.0, 1.0, 1.0, 1.0),
136 | bg_image=None,
137 | show_ui=None,
138 | point_size=None,
139 | animation_time_step=1.0,
140 | animation_duration=None,
141 | rpc_interface=False,
142 | on_init=None,
143 | on_animation_frame=None,
144 | on_animation_tick=None):
145 | """Draw in Jupyter Cell"""
146 |
147 | window_uid = async_event_loop.run_sync(
148 | functools.partial(o3d.visualization.draw,
149 | geometry=geometry,
150 | title=title,
151 | width=width,
152 | height=height,
153 | actions=actions,
154 | lookat=lookat,
155 | eye=eye,
156 | up=up,
157 | field_of_view=field_of_view,
158 | bg_color=bg_color,
159 | bg_image=bg_image,
160 | show_ui=show_ui,
161 | point_size=point_size,
162 | animation_time_step=animation_time_step,
163 | animation_duration=animation_duration,
164 | rpc_interface=rpc_interface,
165 | on_init=on_init,
166 | on_animation_frame=on_animation_frame,
167 | on_animation_tick=on_animation_tick,
168 | non_blocking_and_return_uid=True))
169 | visualizer = WebVisualizer(window_uid=window_uid)
170 | visualizer.show()
171 |
--------------------------------------------------------------------------------
/Tests/LinuxMain.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 |
3 | import Open3D_iOSTests
4 |
5 | var tests = [XCTestCaseEntry]()
6 | tests += Open3D_iOSTests.allTests()
7 | XCTMain(tests)
8 |
--------------------------------------------------------------------------------
/Tests/Open3D-iOSTests/Open3D_iOSTests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 | @testable import Open3D_iOS
3 |
4 | final class Open3D_iOSTests: XCTestCase {
5 | func testExample() {
6 | // This is an example of a functional test case.
7 | // Use XCTAssert and related functions to verify your tests produce the correct
8 | // results.
9 | XCTAssertEqual(Open3D_iOS().text, "Hello, World!")
10 | }
11 |
12 | static var allTests = [
13 | ("testExample", testExample),
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/Tests/Open3D-iOSTests/XCTestManifests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 |
3 | #if !canImport(ObjectiveC)
4 | public func allTests() -> [XCTestCaseEntry] {
5 | return [
6 | testCase(Open3D_iOSTests.allTests),
7 | ]
8 | }
9 | #endif
10 |
--------------------------------------------------------------------------------