MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ hash_vision_step()

size_t MayaFlux::Kinesis::Vision::hash_vision_step ( VisionOp  op,
const VisionParams &  params 
)
inline

Hash a VisionStep's op and parameters together.

Keys GPU dispatch memoization on VisionPass::completed, which spans one walk including any suspensions. Two steps hashing equal are treated as interchangeable, so every field that changes the output must be hashed.

Definition at line 621 of file VisionOp.hpp.

622{
623 size_t seed = std::hash<std::string_view> {}(Reflect::enum_to_string(op));
624
625 std::visit([&seed](const auto& p) {
626 using T = std::decay_t<decltype(p)>;
627 if constexpr (std::is_same_v<T, std::monostate>) {
628 } else if constexpr (std::is_same_v<T, ThresholdParams>) {
629 hash_combine(seed, std::hash<float> {}(p.value));
630 hash_combine(seed, std::hash<uint8_t> {}(static_cast<uint8_t>(p.channels)));
631 for (const auto& band : p.bands) {
632 hash_combine(seed, std::hash<float> {}(band.lo));
633 hash_combine(seed, std::hash<float> {}(band.hi));
634 }
635 } else if constexpr (std::is_same_v<T, ThresholdAdaptiveParams>) {
636 hash_combine(seed, std::hash<uint32_t> {}(p.block_size));
637 hash_combine(seed, std::hash<float> {}(p.offset));
638 hash_combine(seed, std::hash<uint8_t> {}(static_cast<uint8_t>(p.channels)));
639 } else if constexpr (std::is_same_v<T, OtsuParams>) {
640 hash_combine(seed, std::hash<uint8_t> {}(static_cast<uint8_t>(p.channels)));
641 } else if constexpr (std::is_same_v<T, NormalizeRangeParams>) {
642 hash_combine(seed, std::hash<float> {}(p.lo));
643 hash_combine(seed, std::hash<float> {}(p.hi));
644 } else if constexpr (std::is_same_v<T, GaussianBlurParams>) {
645 hash_combine(seed, std::hash<float> {}(p.sigma));
646 } else if constexpr (std::is_same_v<T, FilterSeparableParams>) {
647 for (float v : p.kernel_x)
648 hash_combine(seed, std::hash<float> {}(v));
649 for (float v : p.kernel_y)
650 hash_combine(seed, std::hash<float> {}(v));
651 } else if constexpr (std::is_same_v<T, CannyParams>) {
652 hash_combine(seed, std::hash<float> {}(p.sigma));
653 hash_combine(seed, std::hash<float> {}(p.low_threshold));
654 hash_combine(seed, std::hash<float> {}(p.high_threshold));
655 } else if constexpr (std::is_same_v<T, MorphParams>) {
656 hash_combine(seed, std::hash<uint32_t> {}(p.radius));
657 } else if constexpr (std::is_same_v<T, HarrisParams>) {
658 hash_combine(seed, std::hash<float> {}(p.k));
659 hash_combine(seed, std::hash<float> {}(p.sigma));
660 hash_region(seed, p.region);
661 } else if constexpr (std::is_same_v<T, ExtractPeaksParams>) {
662 hash_combine(seed, std::hash<float> {}(p.threshold));
663 hash_combine(seed, std::hash<uint32_t> {}(p.nms_radius));
664 hash_combine(seed, std::hash<bool> {}(p.export_keypoints));
665 hash_region(seed, p.region);
666 } else if constexpr (std::is_same_v<T, TrackKeypointsParams>) {
667 hash_combine(seed, std::hash<uint32_t> {}(p.window_radius));
668 hash_combine(seed, std::hash<uint32_t> {}(p.max_iterations));
669 hash_combine(seed, std::hash<float> {}(p.eigen_threshold));
670 hash_combine(seed, std::hash<float> {}(p.error_threshold));
671 hash_combine(seed, std::hash<uint32_t> {}(p.levels));
672 hash_combine(seed, std::hash<uint32_t> {}(p.max_points));
673 hash_combine(seed, std::hash<float> {}(p.min_distance));
674 hash_combine(seed, std::hash<float> {}(p.forward_backward_threshold));
675 hash_combine(seed, std::hash<bool> {}(p.export_tracks));
676 hash_combine(seed, std::hash<bool> {}(p.host_tracks));
677 } else if constexpr (std::is_same_v<T, FindContoursParams>) {
678 hash_combine(seed, std::hash<float> {}(p.min_area));
679 hash_combine(seed, std::hash<uint32_t> {}(p.max_contours));
680 hash_combine(seed, std::hash<uint32_t> {}(p.max_points_per_contour));
681 hash_combine(seed, std::hash<bool> {}(p.as_image));
682 hash_combine(seed, std::hash<bool> {}(p.export_contours_buffer));
683 } else if constexpr (std::is_same_v<T, ConnectedComponentsParams>) {
684 hash_combine(seed, std::hash<bool> {}(p.export_labels));
685 hash_combine(seed, std::hash<bool> {}(p.with_colors));
686 hash_combine(seed, std::hash<bool> {}(p.export_boxes));
687 hash_combine(seed, std::hash<bool> {}(p.export_label_buffer));
688 } else if constexpr (std::is_same_v<T, OpticalFlowDenseParams>) {
689 hash_combine(seed, std::hash<uint32_t> {}(p.window_radius));
690 hash_combine(seed, std::hash<uint32_t> {}(p.iterations));
691 hash_combine(seed, std::hash<uint32_t> {}(p.levels));
692 hash_combine(seed, std::hash<float> {}(p.eigen_threshold));
693 hash_combine(seed, std::hash<float> {}(p.max_step));
694 hash_combine(seed, std::hash<bool> {}(p.visualize));
695 hash_combine(seed, std::hash<float> {}(p.visual_range));
696 hash_combine(seed, std::hash<float> {}(p.visual_min_motion));
697 } else if constexpr (std::is_same_v<T, ConfineParams>) {
698 hash_combine(seed, std::hash<float> {}(p.bounds.x));
699 hash_combine(seed, std::hash<float> {}(p.bounds.y));
700 hash_combine(seed, std::hash<float> {}(p.bounds.w));
701 hash_combine(seed, std::hash<float> {}(p.bounds.h));
702 hash_combine(seed, std::hash<bool> {}(p.resize_to_source));
703 }
704 },
705 params);
706
707 return seed;
708}
void hash_combine(size_t &seed, size_t value)
Combine a hash into an existing seed, FNV-style.
Definition VisionOp.hpp:594
void hash_region(size_t &seed, const std::optional< BoundingBox > &region)
Combine an optional region into a hash: absence and presence hash differently, presence by its four b...
Definition VisionOp.hpp:603

References MayaFlux::Reflect::enum_to_string(), hash_combine(), and hash_region().

Referenced by MayaFlux::Yantra::VisionGpuExecutor::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: