@openhps/openvslam 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +115 -2
  3. package/cc/config.cc +49 -0
  4. package/cc/config.h +24 -0
  5. package/cc/frame_publisher.cc +62 -0
  6. package/cc/frame_publisher.h +27 -0
  7. package/cc/graph_node.cc +78 -0
  8. package/cc/graph_node.h +26 -0
  9. package/cc/keyframe.cc +81 -0
  10. package/cc/keyframe.h +27 -0
  11. package/cc/landmark.cc +85 -0
  12. package/cc/landmark.h +26 -0
  13. package/cc/map_publisher.cc +119 -0
  14. package/cc/map_publisher.h +33 -0
  15. package/cc/openvslam.cc +26 -0
  16. package/cc/pangolin_viewer/viewer.h +26 -0
  17. package/cc/socket_publisher/publisher.cc +84 -0
  18. package/cc/socket_publisher/publisher.h +26 -0
  19. package/cc/system.cc +190 -0
  20. package/cc/system.h +47 -0
  21. package/dist/cjs/data/VSLAMFrame.js +44 -0
  22. package/dist/cjs/data/VSLAMFrame.js.map +1 -0
  23. package/dist/cjs/data/VSLAMGraphNode.js +7 -0
  24. package/dist/cjs/data/VSLAMGraphNode.js.map +1 -0
  25. package/dist/cjs/data/VSLAMKeyFrame.js +56 -0
  26. package/dist/cjs/data/VSLAMKeyFrame.js.map +1 -0
  27. package/dist/cjs/data/VSLAMLandmark.js +53 -0
  28. package/dist/cjs/data/VSLAMLandmark.js.map +1 -0
  29. package/dist/cjs/data/VSLAMMap.js +36 -0
  30. package/dist/cjs/data/VSLAMMap.js.map +1 -0
  31. package/dist/cjs/data/index.js +8 -0
  32. package/dist/cjs/data/index.js.map +1 -0
  33. package/dist/cjs/index.js +9 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/nodes/VSLAMConfiguration.js +43 -0
  36. package/dist/cjs/nodes/VSLAMConfiguration.js.map +1 -0
  37. package/dist/cjs/nodes/index.js +7 -0
  38. package/dist/cjs/nodes/index.js.map +1 -0
  39. package/dist/cjs/nodes/processing/VSLAMProcessingNode.js +124 -0
  40. package/dist/cjs/nodes/processing/VSLAMProcessingNode.js.map +1 -0
  41. package/dist/cjs/nodes/processing/index.js +5 -0
  42. package/dist/cjs/nodes/processing/index.js.map +1 -0
  43. package/dist/cjs/nodes/sink/VSLAMSocketPublisher.js +68 -0
  44. package/dist/cjs/nodes/sink/VSLAMSocketPublisher.js.map +1 -0
  45. package/dist/cjs/nodes/sink/index.js +5 -0
  46. package/dist/cjs/nodes/sink/index.js.map +1 -0
  47. package/dist/cjs/package.json +3 -0
  48. package/dist/cjs/service/VSLAMService.js +121 -0
  49. package/dist/cjs/service/VSLAMService.js.map +1 -0
  50. package/dist/cjs/service/index.js +5 -0
  51. package/dist/cjs/service/index.js.map +1 -0
  52. package/dist/cjs/tsconfig.bundle.cjs.tsbuildinfo +1 -0
  53. package/dist/esm/data/VSLAMFrame.js +41 -0
  54. package/dist/esm/data/VSLAMFrame.js.map +1 -0
  55. package/dist/esm/data/VSLAMGraphNode.js +3 -0
  56. package/dist/esm/data/VSLAMGraphNode.js.map +1 -0
  57. package/dist/esm/data/VSLAMKeyFrame.js +53 -0
  58. package/dist/esm/data/VSLAMKeyFrame.js.map +1 -0
  59. package/dist/esm/data/VSLAMLandmark.js +50 -0
  60. package/dist/esm/data/VSLAMLandmark.js.map +1 -0
  61. package/dist/esm/data/VSLAMMap.js +33 -0
  62. package/dist/esm/data/VSLAMMap.js.map +1 -0
  63. package/dist/esm/data/index.js +5 -0
  64. package/dist/esm/data/index.js.map +1 -0
  65. package/dist/esm/index.js +5 -0
  66. package/dist/esm/index.js.map +1 -0
  67. package/dist/esm/nodes/VSLAMConfiguration.js +39 -0
  68. package/dist/esm/nodes/VSLAMConfiguration.js.map +1 -0
  69. package/dist/esm/nodes/index.js +4 -0
  70. package/dist/esm/nodes/index.js.map +1 -0
  71. package/dist/esm/nodes/processing/VSLAMProcessingNode.js +120 -0
  72. package/dist/esm/nodes/processing/VSLAMProcessingNode.js.map +1 -0
  73. package/dist/esm/nodes/processing/index.js +2 -0
  74. package/dist/esm/nodes/processing/index.js.map +1 -0
  75. package/dist/esm/nodes/sink/VSLAMSocketPublisher.js +64 -0
  76. package/dist/esm/nodes/sink/VSLAMSocketPublisher.js.map +1 -0
  77. package/dist/esm/nodes/sink/index.js +2 -0
  78. package/dist/esm/nodes/sink/index.js.map +1 -0
  79. package/dist/esm/package.json +3 -0
  80. package/dist/esm/service/VSLAMService.js +117 -0
  81. package/dist/esm/service/VSLAMService.js.map +1 -0
  82. package/dist/esm/service/index.js +2 -0
  83. package/dist/esm/service/index.js.map +1 -0
  84. package/dist/esm/tsconfig.bundle.esm.tsbuildinfo +1 -0
  85. package/dist/esm/tsconfig.bundle.types.tsbuildinfo +1 -0
  86. package/dist/types/data/VSLAMFrame.d.ts +16 -0
  87. package/dist/types/data/VSLAMFrame.d.ts.map +1 -0
  88. package/dist/types/data/VSLAMGraphNode.d.ts +3 -0
  89. package/dist/types/data/VSLAMGraphNode.d.ts.map +1 -0
  90. package/dist/types/data/VSLAMKeyFrame.d.ts +28 -0
  91. package/dist/types/data/VSLAMKeyFrame.d.ts.map +1 -0
  92. package/dist/types/data/VSLAMLandmark.d.ts +20 -0
  93. package/dist/types/data/VSLAMLandmark.d.ts.map +1 -0
  94. package/dist/types/data/VSLAMMap.d.ts +13 -0
  95. package/dist/types/data/VSLAMMap.d.ts.map +1 -0
  96. package/dist/types/data/index.d.ts +5 -0
  97. package/dist/types/data/index.d.ts.map +1 -0
  98. package/dist/types/index.d.ts +5 -0
  99. package/dist/types/index.d.ts.map +1 -0
  100. package/dist/types/nodes/VSLAMConfiguration.d.ts +36 -0
  101. package/dist/types/nodes/VSLAMConfiguration.d.ts.map +1 -0
  102. package/dist/types/nodes/index.d.ts +4 -0
  103. package/dist/types/nodes/index.d.ts.map +1 -0
  104. package/dist/types/nodes/processing/VSLAMProcessingNode.d.ts +36 -0
  105. package/dist/types/nodes/processing/VSLAMProcessingNode.d.ts.map +1 -0
  106. package/dist/types/nodes/processing/index.d.ts +2 -0
  107. package/dist/types/nodes/processing/index.d.ts.map +1 -0
  108. package/dist/types/nodes/sink/VSLAMSocketPublisher.d.ts +17 -0
  109. package/dist/types/nodes/sink/VSLAMSocketPublisher.d.ts.map +1 -0
  110. package/dist/types/nodes/sink/index.d.ts +2 -0
  111. package/dist/types/nodes/sink/index.d.ts.map +1 -0
  112. package/dist/types/service/VSLAMService.d.ts +57 -0
  113. package/dist/types/service/VSLAMService.d.ts.map +1 -0
  114. package/dist/types/service/index.d.ts +2 -0
  115. package/dist/types/service/index.d.ts.map +1 -0
  116. package/install/install.js +85 -0
  117. package/install/parseEnv.js +7 -0
  118. package/package.json +125 -5
  119. package/src/data/VSLAMFrame.ts +48 -0
  120. package/src/data/VSLAMGraphNode.ts +1 -0
  121. package/src/data/VSLAMKeyFrame.ts +50 -0
  122. package/src/data/VSLAMLandmark.ts +42 -0
  123. package/src/data/VSLAMMap.ts +20 -0
  124. package/src/data/index.ts +4 -0
  125. package/src/index.ts +4 -0
  126. package/src/nodes/VSLAMConfiguration.ts +72 -0
  127. package/src/nodes/index.ts +3 -0
  128. package/src/nodes/processing/VSLAMProcessingNode.ts +152 -0
  129. package/src/nodes/processing/index.ts +1 -0
  130. package/src/nodes/sink/VSLAMSocketPublisher.ts +75 -0
  131. package/src/nodes/sink/index.ts +1 -0
  132. package/src/openvslam/index.d.ts +9 -0
  133. package/src/openvslam/index.js +8 -0
  134. package/src/openvslam/typings/Config.d.ts +3 -0
  135. package/src/openvslam/typings/FramePublisher.d.ts +12 -0
  136. package/src/openvslam/typings/GraphNode.d.ts +5 -0
  137. package/src/openvslam/typings/KeyFrame.d.ts +24 -0
  138. package/src/openvslam/typings/Landmark.d.ts +19 -0
  139. package/src/openvslam/typings/MapPublisher.d.ts +21 -0
  140. package/src/openvslam/typings/PangolinViewer.d.ts +9 -0
  141. package/src/openvslam/typings/SocketPublisher.d.ts +9 -0
  142. package/src/openvslam/typings/System.d.ts +45 -0
  143. package/src/service/VSLAMService.ts +130 -0
  144. package/src/service/index.ts +1 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2019-2026 Maxim Van de Wynckel & Vrije Universiteit Brussel
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,116 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">
2
+ <img alt="OpenHPS" src="https://openhps.org/images/logo_text-512.png" width="40%" /><br />
3
+ @openhps/openvslam
4
+ </h1>
5
+ <p align="center">
6
+ <a href="https://github.com/OpenHPS/openhps-openvslam/actions/workflows/main.yml" target="_blank">
7
+ <img alt="Build Status" src="https://github.com/OpenHPS/openhps-openvslam/actions/workflows/main.yml/badge.svg">
8
+ </a>
9
+ <a href="https://codecov.io/gh/OpenHPS/openhps-openvslam">
10
+ <img src="https://codecov.io/gh/OpenHPS/openhps-openvslam/branch/master/graph/badge.svg"/>
11
+ </a>
12
+ <a href="https://codeclimate.com/github/OpenHPS/openhps-openvslam/" target="_blank">
13
+ <img alt="Maintainability" src="https://img.shields.io/codeclimate/maintainability/OpenHPS/openhps-openvslam">
14
+ </a>
15
+ <a href="https://badge.fury.io/js/@openhps%2Fopenvslam">
16
+ <img src="https://badge.fury.io/js/@openhps%2Fopenvslam.svg" alt="npm version" height="18">
17
+ </a>
18
+ </p>
2
19
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
20
+ <h3 align="center">
21
+ <a href="https://github.com/OpenHPS/openhps-core">@openhps/core</a> &mdash; <a href="https://openhps.org/docs/openvslam">API</a>
22
+ </h3>
23
+
24
+ <br />
25
+ @openhps/openvslam adds bindings and OpenHPS abstracts for [OpenVSLAM](https://stella-vslam.readthedocs.io/en/latest/). It supports [@openhps/opencv](https://github.com/OpenHPS/openhps-opencv) for video processing before sending it to OpenVSLAM. This module will create C++ bindings to OpenVSLAM and supports monocular and stereo SLAM (originally based on ORB-SLAM2).
26
+
27
+ ## Installation
28
+ 1. Install OpenCV 4.X-4.3.X (4.4.0 or higher is not supported)
29
+ 2. Install OpenVSLAM according to the instructions on https://openvslam-community.readthedocs.io/en/latest/
30
+ *We have a docker container for the unit tests that you can investigate.*
31
+ 3. You will need to declare the following environment variables before installing this NPM module
32
+ - ```OPENCV_LIB_DIR```: Library directory of OpenCV
33
+ - ```OPENCV_INCLUDE_DIR```: Include directory of OpenCV
34
+ - ```OPENVSLAM_LIB_DIR```: OpenVSLAM library directory
35
+ - ```OPENVSLAM_INCLUDE_DIR```: OpenVSLAM include directory
36
+ 4. Install @openhps/core if you have not installed it already
37
+ 5. Install @openhps/opencv if you have not installed it already
38
+ 6. ```bash
39
+ npm install @openhps/openvslam --save
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ### Basic Usage
45
+ OpenVSLAM uses a map database, vocabulary and configuration YAML file to start the mapping and/or localization. Basic usage
46
+ allows you to specify the locations of these files to start the processing.
47
+
48
+ ```typescript
49
+ import { ModelBuilder, CallbackSinkNode } from '@openhps/core';
50
+ import { VideoSource, CameraObject } from '@openhps/opencv';
51
+ import { VSLAMProcessingNode } from '@openhps/openvslam';
52
+
53
+ ModelBuilder.create()
54
+ .from(new VideoSource({
55
+ source: new CameraObject(),
56
+ videoSource: "someVideo.mp4",
57
+ autoPlay: true
58
+ }))
59
+ .via(new VSLAMProcessingNode({
60
+ config: "/path/to/config.yaml", // OpenVSLAM camera configuration
61
+ mapping: true, // Enable to disable the mapping
62
+ mapDatabaseFile: "/path/to/map.msg", // Map database file in MessagePack format
63
+ vocabularyFile: "/path/to/vocab.fbow", // OpenVSLAM vocabulary file
64
+ persistMapping: true, // Persist any changes to the map data file
65
+ }))
66
+ .to(new CallbackSinkNode(frame => {
67
+ // frame.source.position
68
+ }))
69
+ .build();
70
+ ```
71
+
72
+ ### Socket Viewer
73
+ OpenVSLAM comes with a socket viewer web application that will visualize the landmarks, keyframes, FPS while also allowing you to control the processing from within your browser. OpenHPS provides the socket viewer as a sink node.
74
+
75
+ ```typescript
76
+ import { ModelBuilder } from '@openhps/core';
77
+ import { VideoSource } from '@openhps/opencv';
78
+ import { VSLAMProcessingNode, VSLAMSocketViewer } from '@openhps/openvslam';
79
+
80
+ ModelBuilder.create()
81
+ .from(new VideoSource({
82
+ // ...
83
+ }))
84
+ .via(new VSLAMProcessingNode({
85
+ // ...
86
+ }))
87
+ .to(new VSLAMSocketViewer({
88
+ url: "http://localhost:3000", // Websocket port
89
+ timeout: 5000
90
+ }))
91
+ .build();
92
+ ```
93
+
94
+
95
+ ### Advanced Usage
96
+
97
+ ### Multi User Usage
98
+ By default, `VSLAMProcessingNode` will create a single OpenVSLAM instance to handle the processing.
99
+
100
+ ## Contributors
101
+ The framework is open source and was developed as part of the PhD of Maxim Van de Wynckel under the supervision of Prof. Dr. Beat Signer. It is currently maintained by [MVdW-Software](https://mvdw-software.com).
102
+
103
+
104
+ ## Contributing
105
+ Use of OpenHPS, contributions and feedback is highly appreciated. Please read our [contributing guidelines](https://github.com/OpenHPS/.github/blob/HEAD/CONTRIBUTING.md) for more information.
106
+
107
+ ## License
108
+ Copyright (C) 2019-2026 Maxim Van de Wynckel & Vrije Universiteit Brussel
109
+
110
+ OpenHPS and the wrapper @openhps/openvslam is Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
111
+
112
+ https://www.apache.org/licenses/LICENSE-2.0
113
+
114
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
115
+
116
+ stella-vslam (OpenVSLAM fork) is licensed under BSD and is not included in this repository.
package/cc/config.cc ADDED
@@ -0,0 +1,49 @@
1
+ #include "config.h"
2
+
3
+ #include <string>
4
+
5
+ Nan::Persistent<v8::Function> Config::constructor;
6
+
7
+ Config::Config(const std::string& config_file_path) {
8
+ self = std::make_shared<stella_vslam::config>(config_file_path);
9
+ }
10
+
11
+ Config::Config(const YAML::Node& yaml_node) {
12
+ self = std::make_shared<stella_vslam::config>(yaml_node);
13
+ }
14
+
15
+ Config::~Config() {}
16
+
17
+ void Config::Init(v8::Local<v8::Object> exports) {
18
+ v8::Local<v8::Context> context = exports->CreationContext();
19
+ Nan::HandleScope scope;
20
+
21
+ // Prepare constructor template
22
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
23
+ tpl->SetClassName(Nan::New("Config").ToLocalChecked());
24
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
25
+
26
+ constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
27
+ exports->Set(context,
28
+ Nan::New("Config").ToLocalChecked(),
29
+ tpl->GetFunction(context).ToLocalChecked());
30
+ }
31
+
32
+ void Config::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
33
+ v8::Isolate *isolate = info.GetIsolate();
34
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
35
+ if (info.IsConstructCall()) {
36
+ // Invoked as constructor: `new Config(...)`
37
+ v8::String::Utf8Value config_file_path(isolate, info[0]);
38
+ Config* obj = new Config(std::string(*config_file_path));
39
+ obj->Wrap(info.This());
40
+ info.GetReturnValue().Set(info.This());
41
+ } else {
42
+ // Invoked as plain function `Config(...)`, turn into construct call.
43
+ const int argc = 1;
44
+ v8::Local<v8::Value> argv[argc] = {info[0]};
45
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
46
+ info.GetReturnValue().Set(
47
+ cons->NewInstance(context, argc, argv).ToLocalChecked());
48
+ }
49
+ }
package/cc/config.h ADDED
@@ -0,0 +1,24 @@
1
+ #ifndef OPENHPS_OPENVSLAM_CONFIG_H
2
+ #define OPENHPS_OPENVSLAM_CONFIG_H
3
+
4
+ #include <nan.h>
5
+ #include <string>
6
+
7
+ #include <yaml-cpp/yaml.h>
8
+ #include <stella_vslam/config.h>
9
+
10
+ class Config : public Nan::ObjectWrap {
11
+ public:
12
+ static void Init(v8::Local<v8::Object> exports);
13
+ std::shared_ptr<stella_vslam::config> self;
14
+
15
+ private:
16
+ explicit Config(const std::string& config_file_path);
17
+ explicit Config(const YAML::Node& yaml_node);
18
+ ~Config();
19
+
20
+ static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
21
+ static Nan::Persistent<v8::Function> constructor;
22
+ };
23
+
24
+ #endif
@@ -0,0 +1,62 @@
1
+ #include "frame_publisher.h"
2
+
3
+ #include <string>
4
+
5
+ Nan::Persistent<v8::Function> FramePublisher::constructor;
6
+
7
+ FramePublisher::FramePublisher(const stella_vslam::system* system) {
8
+ self = system->get_frame_publisher();
9
+ }
10
+
11
+ FramePublisher::~FramePublisher() {}
12
+
13
+ void FramePublisher::Init(v8::Local<v8::Object> exports) {
14
+ v8::Local<v8::Context> context = exports->CreationContext();
15
+
16
+ // Prepare constructor template
17
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
18
+ tpl->SetClassName(Nan::New("FramePublisher").ToLocalChecked());
19
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
20
+
21
+ // Prototype
22
+ Nan::SetPrototypeMethod(tpl, "drawFrame", DrawFrame);
23
+
24
+ constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
25
+ exports->Set(context,
26
+ Nan::New("FramePublisher").ToLocalChecked(),
27
+ tpl->GetFunction(context).ToLocalChecked());
28
+ }
29
+
30
+ void FramePublisher::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
31
+ v8::Isolate *isolate = info.GetIsolate();
32
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
33
+ if (info.IsConstructCall()) {
34
+ // Invoked as constructor
35
+ System* system = Nan::ObjectWrap::Unwrap<System>(
36
+ info[0]->ToObject(context).ToLocalChecked());
37
+ FramePublisher* obj = new FramePublisher(system->self);
38
+ obj->Wrap(info.This());
39
+ info.GetReturnValue().Set(info.This());
40
+ } else {
41
+ // Invoked as plain function
42
+ const int argc = 1;
43
+ v8::Local<v8::Value> argv[argc] = {info[0]};
44
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
45
+ info.GetReturnValue().Set(
46
+ cons->NewInstance(context, argc, argv).ToLocalChecked());
47
+ }
48
+ }
49
+
50
+ v8::Local<v8::Object> FramePublisher::NewInstance(System* system) {
51
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
52
+ const int argc = 1;
53
+ v8::Local<v8::Value> argv[1] = {system->handle()};
54
+ return Nan::NewInstance(cons, argc, argv).ToLocalChecked();
55
+ }
56
+
57
+ void FramePublisher::DrawFrame(const Nan::FunctionCallbackInfo<v8::Value>& info) {
58
+ FramePublisher* obj = ObjectWrap::Unwrap<FramePublisher>(info.Holder());
59
+ Mat* result = new Mat();
60
+ result->setNativeObject(obj->self->draw_frame());
61
+ info.GetReturnValue().Set(Nan::New(result));
62
+ }
@@ -0,0 +1,27 @@
1
+ #ifndef OPENHPS_OPENVSLAM_FRAMEPUBLISHER_H
2
+ #define OPENHPS_OPENVSLAM_FRAMEPUBLISHER_H
3
+
4
+ #include <nan.h>
5
+ #include "system.h"
6
+ #include <Mat.h>
7
+
8
+ #include <stella_vslam/system.h>
9
+ #include <stella_vslam/publish/frame_publisher.h>
10
+
11
+ class FramePublisher : public Nan::ObjectWrap {
12
+ public:
13
+ static void Init(v8::Local<v8::Object> exports);
14
+ explicit FramePublisher(const stella_vslam::system* system);
15
+ static v8::Local<v8::Object> NewInstance(System* system);
16
+
17
+ std::shared_ptr<stella_vslam::publish::frame_publisher> self;
18
+
19
+ private:
20
+ ~FramePublisher();
21
+
22
+ static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
23
+ static void DrawFrame(const Nan::FunctionCallbackInfo<v8::Value>& info);
24
+ static Nan::Persistent<v8::Function> constructor;
25
+ };
26
+
27
+ #endif
@@ -0,0 +1,78 @@
1
+ #include "keyframe.h"
2
+
3
+ #include <string>
4
+ #include <iostream>
5
+ #include <Eigen/Core>
6
+ #include <nlohmann/json.hpp>
7
+
8
+ Nan::Persistent<v8::Function> GraphNode::constructor;
9
+
10
+ GraphNode::GraphNode() {}
11
+
12
+ GraphNode::~GraphNode() {}
13
+
14
+ void GraphNode::Init(v8::Local<v8::Object> exports) {
15
+ v8::Local<v8::Context> context = exports->CreationContext();
16
+
17
+ // Prepare constructor template
18
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
19
+ tpl->SetClassName(Nan::New("GraphNode").ToLocalChecked());
20
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
21
+
22
+ // Prototype
23
+ Nan::SetPrototypeMethod(tpl, "getCovisibilitiesOverWeight", GetCovisibilitiesOverWeight);
24
+
25
+ constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
26
+ exports->Set(context,
27
+ Nan::New("GraphNode").ToLocalChecked(),
28
+ tpl->GetFunction(context).ToLocalChecked());
29
+ }
30
+
31
+ void GraphNode::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
32
+ v8::Isolate *isolate = info.GetIsolate();
33
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
34
+ if (info.IsConstructCall()) {
35
+ // Invoked as constructor
36
+ GraphNode* obj = new GraphNode();
37
+ obj->Wrap(info.This());
38
+ info.GetReturnValue().Set(info.This());
39
+ } else {
40
+ // Invoked as plain function
41
+ const int argc = 0;
42
+ v8::Local<v8::Value> argv[argc] = { };
43
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
44
+ info.GetReturnValue().Set(
45
+ cons->NewInstance(context, argc, argv).ToLocalChecked());
46
+ }
47
+ }
48
+
49
+ v8::Local<v8::Object> GraphNode::NewInstance(std::shared_ptr<stella_vslam::data::keyframe> owner) {
50
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
51
+ const int argc = 0;
52
+ v8::Local<v8::Value> argv[0] = { };
53
+ const v8::Local<v8::Object> result = Nan::NewInstance(cons, argc, argv).ToLocalChecked();
54
+
55
+ GraphNode* obj = Nan::ObjectWrap::Unwrap<GraphNode>(result);
56
+ obj->self = owner;
57
+ return result;
58
+ }
59
+
60
+ void GraphNode::GetCovisibilitiesOverWeight(const Nan::FunctionCallbackInfo<v8::Value>& info) {
61
+ v8::Isolate *isolate = info.GetIsolate();
62
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
63
+
64
+ GraphNode* obj = ObjectWrap::Unwrap<GraphNode>(info.Holder());
65
+ if (!obj->self || !obj->self->graph_node_ || !info[0]->IsNumber()) {
66
+ info.GetReturnValue().Set(Nan::New<v8::Array>(0));
67
+ return;
68
+ }
69
+ unsigned int weight = info[0]->NumberValue(context).FromJust();
70
+ std::vector<std::shared_ptr<stella_vslam::data::keyframe>> keyframes = obj->self->graph_node_->get_covisibilities_over_weight(weight);
71
+
72
+ const size_t outSize = keyframes.size();
73
+ v8::Local<v8::Array> outArray = Nan::New<v8::Array>(outSize);
74
+ for (size_t i = 0; i < outSize; ++i) {
75
+ Nan::Set(outArray, i, KeyFrame::NewInstance(keyframes[i]));
76
+ }
77
+ info.GetReturnValue().Set(outArray);
78
+ }
@@ -0,0 +1,26 @@
1
+ #ifndef OPENHPS_OPENVSLAM_GRAPH_NODE_H
2
+ #define OPENHPS_OPENVSLAM_GRAPH_NODE_H
3
+
4
+ #include <nan.h>
5
+
6
+ #include <stella_vslam/type.h>
7
+ #include <stella_vslam/data/keyframe.h>
8
+
9
+ class GraphNode : public Nan::ObjectWrap {
10
+ public:
11
+ static void Init(v8::Local<v8::Object> exports);
12
+ // The graph node is owned by its keyframe, so keep a shared reference
13
+ // to the owning keyframe instead of taking ownership of the graph node
14
+ static v8::Local<v8::Object> NewInstance(std::shared_ptr<stella_vslam::data::keyframe> owner);
15
+ std::shared_ptr<stella_vslam::data::keyframe> self;
16
+
17
+ private:
18
+ explicit GraphNode();
19
+ ~GraphNode();
20
+
21
+ static void New(const Nan::FunctionCallbackInfo<v8::Value>& info);
22
+ static void GetCovisibilitiesOverWeight(const Nan::FunctionCallbackInfo<v8::Value>& info);
23
+ static Nan::Persistent<v8::Function> constructor;
24
+ };
25
+
26
+ #endif
package/cc/keyframe.cc ADDED
@@ -0,0 +1,81 @@
1
+ #include "keyframe.h"
2
+
3
+ #include <string>
4
+ #include <iostream>
5
+ #include <Eigen/Core>
6
+ #include <nlohmann/json.hpp>
7
+
8
+ Nan::Persistent<v8::Function> KeyFrame::constructor;
9
+
10
+ KeyFrame::KeyFrame() {}
11
+
12
+ KeyFrame::~KeyFrame() {}
13
+
14
+ void KeyFrame::Init(v8::Local<v8::Object> exports) {
15
+ v8::Local<v8::Context> context = exports->CreationContext();
16
+
17
+ // Prepare constructor template
18
+ v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
19
+ tpl->SetClassName(Nan::New("KeyFrame").ToLocalChecked());
20
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
21
+
22
+ // Prototype
23
+ Nan::SetPrototypeMethod(tpl, "toJSON", ToJSON);
24
+ Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("id").ToLocalChecked(), GetId);
25
+ Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New("graphNode").ToLocalChecked(), GetGraphNode);
26
+
27
+ constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
28
+ exports->Set(context,
29
+ Nan::New("KeyFrame").ToLocalChecked(),
30
+ tpl->GetFunction(context).ToLocalChecked());
31
+ }
32
+
33
+ void KeyFrame::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
34
+ v8::Isolate *isolate = info.GetIsolate();
35
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
36
+ if (info.IsConstructCall()) {
37
+ // Invoked as constructor
38
+ KeyFrame* obj = new KeyFrame();
39
+ obj->Wrap(info.This());
40
+ info.GetReturnValue().Set(info.This());
41
+ } else {
42
+ // Invoked as plain function
43
+ const int argc = 0;
44
+ v8::Local<v8::Value> argv[argc] = { };
45
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
46
+ info.GetReturnValue().Set(
47
+ cons->NewInstance(context, argc, argv).ToLocalChecked());
48
+ }
49
+ }
50
+
51
+ v8::Local<v8::Object> KeyFrame::NewInstance(std::shared_ptr<stella_vslam::data::keyframe> native) {
52
+ v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor);
53
+ const int argc = 0;
54
+ v8::Local<v8::Value> argv[0] = { };
55
+ const v8::Local<v8::Object> result = Nan::NewInstance(cons, argc, argv).ToLocalChecked();
56
+
57
+ KeyFrame* obj = Nan::ObjectWrap::Unwrap<KeyFrame>(result);
58
+ obj->self = native;
59
+ return result;
60
+ }
61
+
62
+ void KeyFrame::GetId(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) {
63
+ KeyFrame* obj = ObjectWrap::Unwrap<KeyFrame>(info.Holder());
64
+ info.GetReturnValue().Set(obj->self->id_);
65
+ }
66
+
67
+ void KeyFrame::GetGraphNode(v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) {
68
+ KeyFrame* obj = ObjectWrap::Unwrap<KeyFrame>(info.Holder());
69
+ // Pass a reference to the owning keyframe; the graph node itself is owned
70
+ // by the keyframe and must not be moved out of it
71
+ info.GetReturnValue().Set(GraphNode::NewInstance(obj->self));
72
+ }
73
+
74
+ void KeyFrame::ToJSON(const Nan::FunctionCallbackInfo<v8::Value>& info) {
75
+ KeyFrame* obj = ObjectWrap::Unwrap<KeyFrame>(info.Holder());
76
+ nlohmann::json json = obj->self->to_json();
77
+ v8::Local<v8::String> json_string = Nan::New(json.dump()).ToLocalChecked();
78
+ Nan::JSON NanJSON;
79
+ Nan::MaybeLocal<v8::Value> result = NanJSON.Parse(json_string);
80
+ info.GetReturnValue().Set(result.ToLocalChecked());
81
+ }