-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Update
annotation-context.rs
to use correct API (#8708)
Co-authored-by: Antoine Beyeler <[email protected]> Co-authored-by: Clement Rey <[email protected]>
- Loading branch information
1 parent
cae7a6a
commit fb14c33
Showing
6 changed files
with
82 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <rerun.hpp> | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_annotation_context_connections"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
// Annotation context with two classes, using two labeled classes, of which ones defines a | ||
// color. | ||
rec.log_static( | ||
"masks", | ||
rerun::AnnotationContext({ | ||
rerun::AnnotationInfo(0, "Background"), | ||
rerun::AnnotationInfo(1, "Person", rerun::Rgba32(255, 0, 0)), | ||
}) | ||
); | ||
|
||
// Annotation context with simple keypoints & keypoint connections. | ||
std::vector<rerun::AnnotationInfo> keypoint_annotations; | ||
for (uint16_t i = 0; i < 10; ++i) { | ||
keypoint_annotations.push_back( | ||
rerun::AnnotationInfo(i, rerun::Rgba32(0, static_cast<uint8_t>(28 * i), 0)) | ||
); | ||
} | ||
|
||
std::vector<rerun::KeypointPair> keypoint_connections; | ||
for (uint16_t i = 0; i < 9; ++i) { | ||
keypoint_connections.push_back(rerun::KeypointPair(i, i + 1)); | ||
} | ||
|
||
rec.log_static( | ||
"detections", // Applies to all entities below "detections". | ||
rerun::AnnotationContext({rerun::ClassDescription( | ||
rerun::AnnotationInfo(0, "Snake"), | ||
keypoint_annotations, | ||
keypoint_connections | ||
)}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use rerun::{ | ||
datatypes::{ClassDescriptionMapElem, KeypointId}, | ||
AnnotationContext, AnnotationInfo, ClassDescription, Rgba32, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let rec = rerun::RecordingStreamBuilder::new("rerun_example_annotation_context_connections") | ||
.spawn()?; | ||
|
||
// Annotation context with two classes, using two labeled classes, of which ones defines a | ||
// color. | ||
rec.log_static( | ||
"masks", // Applies to all entities below "masks". | ||
&AnnotationContext::new([ | ||
ClassDescriptionMapElem::from((0, "Background")), | ||
ClassDescriptionMapElem::from((1, "Person", Rgba32::from_rgb(255, 0, 0))), | ||
]), | ||
)?; | ||
|
||
// Annotation context with simple keypoints & keypoint connections. | ||
rec.log_static( | ||
"detections", // Applies to all entities below "detections". | ||
&AnnotationContext::new([ClassDescription { | ||
info: (0, "Snake").into(), | ||
keypoint_annotations: (0..10) | ||
.map(|i| AnnotationInfo { | ||
id: i, | ||
label: None, | ||
color: Some(Rgba32::from_rgb(0, (28 * i) as u8, 0)), | ||
}) | ||
.collect(), | ||
keypoint_connections: (0..9) | ||
.map(|i| (KeypointId(i), KeypointId(i + 1))) | ||
.map(Into::into) | ||
.collect(), | ||
}]), | ||
)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters