(output)
| 110 | outputToCam = None |
| 111 | |
| 112 | def process_mapping_output(output): |
| 113 | nonlocal visualizer |
| 114 | nonlocal finalMapWritten |
| 115 | |
| 116 | if visualizer is not None: |
| 117 | visualizer.onMappingOutput(output) |
| 118 | |
| 119 | if output.finalMap: |
| 120 | trajectory = compute_full_trajectory(output.map.keyFrames, poseTrails, outputToCam) |
| 121 | |
| 122 | with open(args.output, "w") as outFile: |
| 123 | for output in trajectory: |
| 124 | outFile.write(json.dumps(output) + "\n") |
| 125 | finalMapWritten = True |
| 126 | |
| 127 | elif len(output.updatedKeyFrames) > 0: |
| 128 | frameId = output.updatedKeyFrames[-1] |
| 129 | keyFrame = output.map.keyFrames.get(frameId) |
| 130 | if not keyFrame: return |
| 131 | |
| 132 | frameSet = keyFrame.frameSet |
| 133 | targetFrame = frameSet.rgbFrame |
| 134 | if not targetFrame: targetFrame = frameSet.primaryFrame |
| 135 | if not targetFrame or not targetFrame.image: return |
| 136 | img = targetFrame.image.toArray() |
| 137 | |
| 138 | if args.preview: |
| 139 | import cv2 |
| 140 | bgrImage = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) |
| 141 | cv2.imshow("Frame", bgrImage) |
| 142 | cv2.setWindowTitle("Frame", "Key frame candidate #{}".format(frameId)) |
| 143 | cv2.waitKey(1) |
| 144 | |
| 145 | def on_vio_output(vioOutput): |
| 146 | nonlocal visualizer, isTracking, outputToCam |
no test coverage detected