dl::TensorToPoint2D
dl::TensorToPoint2D
Decodes a tensor channel into Point2D
#include <TensorToPoint2D.hpp>
Inherits from dl::ChannelDecoder
Public Functions
| Name | |
|---|---|
| virtual std::string | name() const override |
| virtual std::string | outputTypeName() const override |
| Point2D< float > | decode(at::Tensor const & tensor, DecoderContext const & ctx, PointDecoderParams const & params) Decode the channel with the highest activation into a single point. |
| std::vector< Point2D< float > > | decodeMultiple(at::Tensor const & tensor, DecoderContext const & ctx, PointDecoderParams const & params) Decode all local maxima above threshold into multiple points. |
Additional inherited members
Public Functions inherited from dl::ChannelDecoder
| Name | |
|---|---|
| virtual | ~ChannelDecoder() =default |
Detailed Description
class dl::TensorToPoint2D;Decodes a tensor channel into Point2D
Strategies:
- Argmax: finds the pixel with highest value
- Subpixel: refines argmax with parabolic fit around the maximum
Output coordinates are scaled from tensor (H, W) back to target_image_size. If target_image_size is {0, 0}, coordinates are returned in tensor space.
Expects a 4D input tensor laid out as [B, C, H, W].
Public Functions Documentation
function name
virtual std::string name() const overrideReimplements: dl::ChannelDecoder::name
function outputTypeName
virtual std::string outputTypeName() const overrideReimplements: dl::ChannelDecoder::outputTypeName
function decode
static Point2D< float > decode(
at::Tensor const & tensor,
DecoderContext const & ctx,
PointDecoderParams const & params
)Decode the channel with the highest activation into a single point.
Parameters:
- tensor 4D activation tensor [B, C, H, W].
- ctx Decoder indexing context; height and width must match tensor dims 2 and 3.
- params Subpixel refinement and threshold settings.
Return: Peak location, or {0, 0} if the channel is entirely non-positive.
Precondition:
- tensor is defined
- tensor.dim() == 4 (layout [B, C, H, W])
- 0 <= ctx.batch_index < tensor.size(0)
- 0 <= ctx.source_channel < tensor.size(1)
- ctx.height > 0 and ctx.width > 0
- tensor.size(2) == ctx.height and tensor.size(3) == ctx.width
function decodeMultiple
static std::vector< Point2D< float > > decodeMultiple(
at::Tensor const & tensor,
DecoderContext const & ctx,
PointDecoderParams const & params
)Decode all local maxima above threshold into multiple points.
Parameters:
- tensor 4D activation tensor [B, C, H, W].
- ctx Decoder indexing context; height and width must match tensor dims 2 and 3.
- params Subpixel refinement and minimum activation threshold.
Precondition:
- tensor is defined
- tensor.dim() == 4 (layout [B, C, H, W])
- 0 <= ctx.batch_index < tensor.size(0)
- 0 <= ctx.source_channel < tensor.size(1)
- ctx.height > 0 and ctx.width > 0
- tensor.size(2) == ctx.height and tensor.size(3) == ctx.width
A local maximum is a pixel whose value is greater than all 8 neighbors.
Updated on 2026-11-13 at 20:25:42 +0000