NsdkSemanticsSession
A session for semantic segmentation and environmental understanding....
Declaration
final class NsdkSemanticsSessionSummary
A session for semantic segmentation and environmental understanding.
NsdkSemanticsSession provides capabilities for understanding the semantic structure
of the environment by classifying pixels into different object categories. This enables
applications to make intelligent decisions based on environmental context.
Overview
Semantics features include:
- Real-time semantic segmentation of camera images
- Multiple semantic categories (sky, ground, buildings, people, etc.)
- Confidence maps for semantic classifications
- Packed channel data for efficient processing
- Suppression masks for filtering unwanted areas
Usage Pattern
// Create and configure semantics session
let semanticsSession = nsdkSession.createSemanticsSession()
let config = Configuration()
semanticsSession.configure(with: config)
semanticsSession.start()
// Get available semantic channels
let (error, channelNames) = semanticsSession.getChannelNames()
if error == .none, let names = channelNames {
print("Available channels: \(names)")
}
// Get semantic confidence for a specific channel
let (status, result) = semanticsSession.getLatestConfidence(channelIndex: 0)
if status.isOk(), let semanticResult = result {
// Process semantic data
processSemanticData(semanticResult)
}
Methods
| Name | Type | Summary |
|---|---|---|
| configure | void | |
| featureStatus | NsdkFeatureStatus | Gets the current status of the Semantics feature. This method reports any errors or warnings that have occurred within the semantics system. Check this periodically to monitor the health of semantic processing operations. - Returns: Feature status flags indicating current state and any issues ## Example |
| latestConfidence | NsdkAsyncState<SemanticsResult, AwarenessError> | Retrieves the latest confidence map for a specific semantic channel. This method returns a confidence map where each pixel value represents the confidence score (0.0-1.0) that the pixel belongs to the specified semantic category. Higher confidence values indicate stronger belief in the semantic classification. - Parameter channel: The name of the semantic channel to retrieve - Returns: A tuple containing the operation status and semantic result if successful ## Example ## Confidence Interpretation Confidence values range from 0.0 to 1.0: - 0.0: Definitely not the specified semantic category - 0.5: Uncertain classification - 1.0: Definitely the specified semantic category Use confidence thresholds to filter results based on your application's needs. |
| latestImageParams | NsdkAsyncState<AwarenessImageParams, AwarenessError> | Retrieves the latest camera intrinsic parameters for semantic processing. This method returns the camera intrinsic parameters that were used during semantic processing. These parameters are essential for coordinate transformations between image coordinates and 3D world coordinates. - Returns: A tuple containing the operation status and intrinsics result |
| latestPackedChannels | NsdkAsyncState<SemanticsResult, AwarenessError> | Retrieves the latest packed semantic channels data. This method returns a multi-channel image where each channel represents a different semantic category. Packed channels provide an efficient way to access multiple semantic classifications in a single image, reducing the need for multiple API calls. - Returns: A tuple containing the operation status and semantic result if successful ## Example ## Packed Channels Format The packed channels image contains multiple semantic categories encoded as separate channels in a single image. Each channel corresponds to a semantic category, and pixel values represent classification confidence or probability scores. ## Performance Benefits Using packed channels is more efficient than calling getLatestConfidence multipletimes, as it reduces the number of API calls and data transfers required. |
| latestSuppressionMask | NsdkAsyncState<SemanticsResult, AwarenessError> | Retrieves the latest suppression mask for semantic processing. This method returns a binary mask indicating areas that should be ignored or suppressed during semantic processing. Suppression masks are useful for filtering out regions that are not relevant for semantic understanding, such as areas with poor image quality. - Returns: A tuple containing the operation status and semantic result if successful ## Example ## Suppression Mask Usage Suppression masks are binary images where: - 0: Areas to be suppressed (ignored in semantic processing) - 1: Areas to be processed normally Use suppression masks to improve semantic processing quality by excluding problematic regions from analysis. |
| start | void | Starts the Semantics system. After starting, Semantics will begin processing incoming frame data for semantic segmentation. The system must be configured before starting. ## Example |
| stop | void | Stops the Semantics system. This halts all semantic processing. The session can be reconfigured and restarted after stopping. |
| unpackChannelsFromBitmask | SemanticsChannels | Unpacks semantic channels from a packed channel bitmask. This method converts a bitmask value from a packed channel pixel into a SemanticsChannelsOptionSet, where each bit represents a semantic channel (bit 0 = Sky, bit 1 = Ground, etc.). - Parameter bitmask: The value of a pixel from an image returned by latestPackedChannels()- Returns: A SemanticsChannels OptionSet representing the channels present in the bitmask |
Nested Types
Structs
| Name | Type | Summary |
|---|---|---|
| Configuration | Configuration | Configuration structure for the semantics session. |
Enums
| Name | Type | Summary |
|---|---|---|
| SemanticsMode | SemanticsMode | Options for different semantics modes. These trade off between performance and accuracy. |
Relationships
conforms to: NsdkFeatureSession
- Attention: This method must be called while the session is stopped,
or else configuration will fail. In that case, while this function returns without
throwing, configuration will still fail asynchronously. Use
featureStatus()to check that configuration has not failed.
- Parameter config: An object that defines this session's behavior.
Only settings that differ from the defaults will be applied.
- Throws:
NsdkError.invalidArgumentif the configuration is invalid.Check NSDK's C logs for more information.