Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 971-Robot-Code
Submodule 971-Robot-Code updated 56 files
+17 −0 .vscode/c_cpp_properties.json
+23 −0 .vscode/settings.json
+3 −0 frc971/orin/.vscode/settings.json
+7 −1 frc971/orin/apriltag.cc
+5 −20 frc971/orin/apriltag.h
+236 −1 frc971/orin/apriltag_detect.cc
+76 −0 frc971/orin/aruco_dict.cpp
+37 −0 frc971/orin/aruco_dict.h
+10 −0 frc971/orin/bool_tag.h
+29 −0 frc971/orin/camera_matrix.h
+111 −0 frc971/orin/confidence_filter.cu
+85 −0 frc971/orin/confidence_filter.h
+205 −0 frc971/orin/cuCompactor.cuh
+23 −1 frc971/orin/cuda.h
+3 −1 frc971/orin/cuda_utils.h
+20 −0 frc971/orin/debug.h
+22 −0 frc971/orin/decoded_tag.h
+215 −0 frc971/orin/decoder_engine.cpp
+73 −0 frc971/orin/decoder_engine.h
+173 −0 frc971/orin/decoder_preprocess.cu
+44 −0 frc971/orin/decoder_preprocess.h
+82 −0 frc971/orin/decoder_softmax.cu
+31 −0 frc971/orin/decoder_softmax.h
+11 −0 frc971/orin/decoder_softmax_results.h
+77 −0 frc971/orin/distorted_h_transform.h
+727 −0 frc971/orin/engine.cpp
+184 −0 frc971/orin/engine.h
+158 −0 frc971/orin/grid_prior.cu
+50 −0 frc971/orin/grid_prior.h
+12 −0 frc971/orin/grid_prior_value.h
+18 −0 frc971/orin/image_format.h
+203 −0 frc971/orin/marker_dict.cpp
+46 −0 frc971/orin/marker_dict.h
+33 −0 frc971/orin/points_and_ids.h
+557 −0 frc971/orin/stag_decoder.cpp
+138 −0 frc971/orin/stag_decoder.h
+58 −0 frc971/orin/stage2_corners.cu
+30 −0 frc971/orin/stage2_corners.h
+36 −0 frc971/orin/stage2_keypoint.cu
+43 −0 frc971/orin/stage2_keypoint.h
+52 −0 frc971/orin/stage2_keypoint_group.cu
+50 −0 frc971/orin/stage2_keypoint_group.h
+57 −0 frc971/orin/stage2_keypoint_group_trust.cpp
+27 −0 frc971/orin/stage2_keypoint_group_trust.h
+118 −0 frc971/orin/stage2_keypoint_trust.cu
+30 −0 frc971/orin/stage2_keypoint_trust.h
+175 −0 frc971/orin/suppress_and_average_keypoints.cu
+35 −0 frc971/orin/suppress_and_average_keypoints.h
+57 −0 frc971/orin/unit_arucotag.cpp
+39 −0 frc971/orin/unit_arucotag.h
+177 −0 frc971/orin/unit_chessboard_tag.cpp
+80 −0 frc971/orin/unit_chessboard_tag.h
+493 −0 frc971/orin/unit_tag_template.cpp
+153 −0 frc971/orin/unit_tag_template.h
+40 −0 frc971/orin/warp_perspective_points.cpp
+87 −0 frc971/orin/warp_perspective_points.h
4 changes: 4 additions & 0 deletions zebROS_ws/src/deeptag_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ target_link_libraries(run_inference_benchmark PUBLIC deeptag)
set_target_properties(run_inference_benchmark PROPERTIES CUDA_ARCHITECTURES "86")
set_property(TARGET run_inference_benchmark PROPERTY CUDA_SEPARABLE_COMPILATION ON)

add_executable(decoder_test src/decoder_test.cpp)
target_link_libraries(decoder_test PUBLIC deeptag)
set_target_properties(decoder_test PROPERTIES CUDA_ARCHITECTURES "86")
set_property(TARGET decoder_test PROPERTY CUDA_SEPARABLE_COMPILATION ON)
# add_executable(softmax_test src/softmax_test.cpp)
# target_link_libraries(softmax_test PUBLIC deeptag)
# set_target_properties(softmax_test PROPERTIES CUDA_ARCHITECTURES "86")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONFIDENCE_FILTER_INC__
#define CONFIDENCE_FILTER_INC__

#include "span.hpp"
#include "deeptag_ros/span.hpp"

#ifndef __host__
#define __host__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cstdint>

#include "device_types.h"
#include "image_format.h"
#include "deeptag_ros/image_format.h"

cudaError_t cudaImageTileRGB(const void *input,
const imageFormat format,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CUDA_SSD_PREPROCESSING_H__
#define CUDA_SSD_PREPROCESSING_H__

#include "image_format.h"
#include "deeptag_ros/image_format.h"

/*
* Downsample and apply pixel normalization, NCHW format
Expand Down
7 changes: 2 additions & 5 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/decoded_tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <array>
#include <cstdint>
#include "opencv2/core.hpp"
#include "points_and_ids.h"
#include "deeptag_ros/points_and_ids.h"

template <size_t GRID_SIZE>
class DecodedTag
Expand All @@ -13,10 +13,7 @@ class DecodedTag
cv::Mat m_HCrop;
int m_tagId;
uint64_t m_binaryId;
std::array<PointsAndIDs, (GRID_SIZE + 2) * (GRID_SIZE + 2)> m_keypointsWithIds;
// TODO : this is just the points from the previous field copied into a different var
// see about combining them
std::array<cv::Point2d, (GRID_SIZE + 2) * (GRID_SIZE + 2)> m_keypointsInImage;
PointsAndIDs<GRID_SIZE + 2> m_keypointsWithIds;
std::array<cv::Point2d, 4> m_roi;

int m_mainIdx{0};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef DECODER_ENGINE_INC__
#define DECODER_ENGINE_INC__

#include "span.hpp"
#include "deeptag_ros/span.hpp"

#include "decoder_preprocess.h"
#include "engine.h"
#include "deeptag_ros/decoder_preprocess.h"
#include "deeptag_ros/engine.h"

class DecoderEngineCalibrator : public Int8EntropyCalibrator2
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <array>
#include "cuda_runtime.h" // for cudaError

#include "image_format.h"
#include "deeptag_ros/image_format.h"

class DecoderPreprocess
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define DECODER_SOFTMAX_

#include <cuda_runtime.h>
#include "decoder_softmax_results.h"
#include "span.hpp"
#include "deeptag_ros/decoder_softmax_results.h"
#include "deeptag_ros/span.hpp"


// Class to handle DecoderSoftmax ops.
Expand Down
14 changes: 7 additions & 7 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/deeptag_impls.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef DEEPTAG_IMPLS_INC__
#define DEEPTAG_IMPLS_INC__

#include "cuda_event_timing.h"
#include "deeptag.h"
#include "detection_engine.h"
#include "marker_dict.h"
#include "pose_estimator.h"
#include "stag_decoder.h"
#include "stag_detector.h"
#include "deeptag_ros/cuda_event_timing.h"
#include "deeptag_ros/deeptag.h"
#include "deeptag_ros/detection_engine.h"
#include "deeptag_ros/marker_dict.h"
#include "deeptag_ros/pose_estimator.h"
#include "deeptag_ros/stag_decoder.h"
#include "deeptag_ros/stag_detector.h"

class DeepTagImplBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DETECTION_ENGINE_INC__
#define DETECTION_ENGINE_INC__

#include "engine.h"
#include "deeptag_ros/engine.h"
class DetectionEngineCalibrator : public Int8EntropyCalibrator2
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <array>
#include "opencv2/core.hpp"
#include "opencv2/calib3d.hpp"
#include "warp_perspective_points.h"
#include "deeptag_ros/warp_perspective_points.h"
#undef DEBUG
#include "debug.h"
#include "deeptag_ros/debug.h"

template <size_t N>
std::array<cv::Point2d, N> fromCropToUndistorted(const std::array<cv::Point2d, N> &pointsInCrop,
Expand Down
2 changes: 1 addition & 1 deletion zebROS_ws/src/deeptag_ros/include/deeptag_ros/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "NvInferRuntimeCommon.h" // for Dims, ILogger
#include "driver_types.h" // for cudaStream_t, CUstream_st, CUgraph...

#include "cuda_event_timing.h" // for Timings
#include "deeptag_ros/cuda_event_timing.h" // for Timings
class GpuImageWrapper;

// Utility methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cstddef>
#include "driver_types.h" // for cudaStream_t

#include "image_format.h"
#include "deeptag_ros/image_format.h"
namespace cv
{
class Mat;
Expand Down
4 changes: 2 additions & 2 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/grid_prior.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef GRID_PRIOR_INC__
#define GRID_PRIOR_INC__
#include <cuda_runtime.h>
#include "grid_prior_value.h"
#include "span.hpp"
#include "deeptag_ros/grid_prior_value.h"
#include "deeptag_ros/span.hpp"

// Class to handle all of the GridPrior ops.
// Stores the grid priors (a map from model output indexes to image coords) along
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
enum class imageFormat
{
IMAGE_MONO8,
IMAGE_MONO32F,
IMAGE_RGB8,
IMAGE_BGR8,
IMAGE_RGBA8,
Expand Down
24 changes: 13 additions & 11 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/points_and_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
#define POINTS_AND_IDS_INC__
#include "opencv2/core.hpp"

template <size_t GRID_SIZE>
struct PointsAndIDs
{
PointsAndIDs()
: m_point{0., 0.}
, m_id{-1}
, m_score{0.}
{
std::ranges::fill(m_id, -1);
std::ranges::fill(m_score, -1);
}
PointsAndIDs(const double x, const double y, const int id, const double score = 0)
: m_point{cv::Point2d{x, y}}, m_id{id}, m_score{score}
{
}
cv::Point2d m_point;
int m_id;
double m_score;

std::array<cv::Point2d, GRID_SIZE * GRID_SIZE> m_point{};
std::array<int, GRID_SIZE * GRID_SIZE> m_id{};
std::array<double, GRID_SIZE * GRID_SIZE> m_score{};

size_t size(void) const { return m_point.size(); } // all arrays are the same size

friend std::ostream& operator<<(std::ostream &os, const PointsAndIDs &pid)
{
os << pid.m_point.x << ", " << pid.m_point.y << " id = " << pid.m_id << " score = " << pid.m_score;
for (size_t ii = 0; ii < pid.m_point.size(); ii++)
{
os << pid.m_point[ii].x << ", " << pid.m_point[ii].y << " id = " << pid.m_id[ii] << " score = " << pid.m_score[ii] << std::endl;
}
return os;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
template <bool BOOL> struct BoolTag;

#undef DEBUG
#include "debug.h"
#include "deeptag_ros/debug.h"

template <size_t GRID_SIZE, class UNIT_TAG_TYPE, size_t STEP_ELEM_NUM, bool IS_RANSAC_SOLVEPNP, bool IS_INVERSE_X = true>
class PoseEstimator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <vector>
#include <opencv2/core/types.hpp> // for Point2d
#include "span.hpp"
#include "deeptag_ros/span.hpp"

template <uint32_t BATCH_SIZE> class Stage1GridGroup;
class Stage1SSDGroup;
Expand Down
2 changes: 1 addition & 1 deletion zebROS_ws/src/deeptag_ros/include/deeptag_ros/softmax.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <stdint.h> // for int32_t
#include "driver_types.h" // for cudaStream_t
#include "span.hpp" // for span
#include "deeptag_ros/span.hpp" // for span

// Class to handle Softmax ops.
// Input is result from model, all bg scores (h x w) followed by all fg scores for grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <vector>
#include <cuda_runtime.h>

#include "span.hpp"
#include "ssd_box.h"
#include "deeptag_ros/span.hpp"
#include "deeptag_ros/ssd_box.h"

// Class to handle all of the SSDGridPrior ops.
// Stores the grid priors (a map from model output indexes to image coords) along
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

#include <cstdint>
#include "ssd_box.h"
#include "deeptag_ros/ssd_box.h"
class SSDTagKeypoint
{
public:
Expand Down
25 changes: 13 additions & 12 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/stag_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
#include <opencv2/core/types.hpp> // for Point2d
#include <string> // for string
#include <vector> // for vector
#include "decoded_tag.h" // for DecodedTag
#include "decoder_engine.h" // for DecoderEngine
#include "decoder_softmax.h" // for DecoderSoftmax
#include "grid_prior.h" // for GridPrior
#include "confidence_filter.h" // for ConfidenceFilter
#include "span.hpp" // for span
#include "stage2_corners.h" // for Stage2Corners
#include "stage2_keypoint_trust.h" // for Stage2KeypointTrust
#include "suppress_and_average_keypoints.h" // for SuppressAndAverageKeypoints
#include "deeptag_ros/decoded_tag.h" // for DecodedTag
#include "deeptag_ros/decoder_engine.h" // for DecoderEngine
#include "deeptag_ros/decoder_softmax.h" // for DecoderSoftmax
#include "deeptag_ros/grid_prior.h" // for GridPrior
#include "deeptag_ros/confidence_filter.h" // for ConfidenceFilter
#include "deeptag_ros/span.hpp" // for span
#include "deeptag_ros/stage2_corners.h" // for Stage2Corners
#include "deeptag_ros/stage2_keypoint_trust.h" // for Stage2KeypointTrust
#include "deeptag_ros/suppress_and_average_keypoints.h" // for SuppressAndAverageKeypoints

class GpuImageWrapper;
struct GridPriorValue;
class Stage2Keypoint;
class Stage2KeypointGroup;
class Timings;
struct PointsAndIDs;
template <size_t GRID_SIZE> struct PointsAndIDs;

template <class MARKER_DICT, size_t GRID_SIZE>
class STagDecoder
Expand All @@ -46,13 +46,14 @@ class STagDecoder
void setMinGridMatchRatio(const double minGridMatchRatio);
double getMinGridMatchRatio(void) const;
ushort2 getModelSize(void) const;
cudaStream_t getCudaStream(void);

private:
void runInference(std::vector<std::vector<Stage2KeypointGroup>> &stage2KeypointGroupss,
std::vector<std::vector<float2>> &stage2Corners,
std::vector<std::array<float2, 4>> &stage2Corners,
const std::vector<std::vector<GpuImageWrapper>> &detectInputs,
const tcb::span<const std::array<cv::Point2d, 4>> &rois);
void fillEmptyIds(std::array<PointsAndIDs, (GRID_SIZE + 2) * (GRID_SIZE + 2)> &orderedFineGridPointsIds,
void fillEmptyIds(PointsAndIDs<GRID_SIZE + 2> &orderedFineGridPointsIds,
const tcb::span<const Stage2KeypointGroup> &fineGridPointsWithIdsCandidates) const;

const MARKER_DICT &m_markerDict;
Expand Down
14 changes: 7 additions & 7 deletions zebROS_ws/src/deeptag_ros/include/deeptag_ros/stag_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <memory> // for unique_ptr:w
#include <string> // for string
#include <vector> // for vector
#include "confidence_filter.h" // for Stage1Predicate, Confide...
#include "deeptag_ros/confidence_filter.h" // for Stage1Predicate, Confide...
#include "driver_types.h" // for CUevent_st, cudaEvent_t
#include "grid_prior.h" // for GridPrior
#include "softmax.h" // for Softmax
#include "span.hpp" // for span
#include "ssd_grid_prior.h" // for SSDGridPrior
#include "suppress_and_average_keypoints.h" // for SuppressAndAverageKeypoints
#include "tag_detect_info.h" // for TagDetectInfo
#include "deeptag_ros/grid_prior.h" // for GridPrior
#include "deeptag_ros/softmax.h" // for Softmax
#include "deeptag_ros/span.hpp" // for span
#include "deeptag_ros/ssd_grid_prior.h" // for SSDGridPrior
#include "deeptag_ros/suppress_and_average_keypoints.h" // for SuppressAndAverageKeypoints
#include "deeptag_ros/tag_detect_info.h" // for TagDetectInfo
#include "vector_types.h" // for ushort2
template <size_t NUM_TILES, bool USE_SCALED_IMAGE> class DetectionEngine;
class GpuImageWrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <cstdint>

#include "vector_types.h"
#include "grid_prior_value.h"
#include "deeptag_ros/grid_prior_value.h"

#ifndef __host__
#define __host__
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef __device__
#define __device__
#endif
#include "ssd_box.h"
#include "deeptag_ros/ssd_box.h"

// Used to store merged Stage1Grid similar data as a single
// group rather than deal with duplicates of individual results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define STAGE2_CORNERS_INC__

#include "cuda_runtime.h"
#include "grid_prior_value.h"
#include "span.hpp"
#include "deeptag_ros/grid_prior_value.h"
#include "deeptag_ros/span.hpp"

class Stage2Corners
{
Expand All @@ -18,7 +18,7 @@ class Stage2Corners

virtual ~Stage2Corners();
void compute(const float *input, const tcb::span<const GridPriorValue> &priors, const float centerVariance, cudaStream_t cudaStream);
const tcb::span<const float2> getDeviceOutput(void);
// const tcb::span<const float2> getDeviceOutput(void);
const tcb::span<const float2> getHostOutput(void);

private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STAGE2_KEYPOINT_INC__
#define STAGE2_KEYPOINT_INC__
#include <cstdint>
#include "grid_prior_value.h"
#include "deeptag_ros/grid_prior_value.h"

#ifndef __host__
#define __host__
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef STAGE2_KEYPOINT_TRUST_INC__
#define STAGE2_KEYPOINT_TRUST_INC__
#include <cuda_runtime.h>
#include "stage2_keypoint.h"
#include "span.hpp"
#include "deeptag_ros/stage2_keypoint.h"
#include "deeptag_ros/span.hpp"

// Given a list of keypoints, check that enough of them
// have a high enough confidence that we trust that the group
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SUPPRESS_AND_AVERAGE_KEYPOINTS_H__
#define SUPPRESS_AND_AVERAGE_KEYPOINTS_H__

#include "span.hpp"
#include "deeptag_ros/span.hpp"

template <class INPUT, class OUTPUT>
class SuppressAndAverageKeypoints
Expand Down
Loading