Skip to content

Commit

Permalink
Merge pull request #16 from S1ink/temp-additions
Browse files Browse the repository at this point in the history
changes!?
  • Loading branch information
S1ink committed Jan 15, 2024
2 parents de43dc9 + e20ec21 commit 6541247
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 25 deletions.
7 changes: 3 additions & 4 deletions lib-vs/out/include/neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void memcpy_deinterlace_wstb_asm( // subtracts weighted channels from primary,
uint8_t offset,
uint8_t alpha,
uint8_t beta,
uint8_t gamma,
uint8_t thresh
);
void memcpy_deinterlace_togray_asm(
Expand Down Expand Up @@ -185,18 +184,18 @@ inline void neon_wst(
}
inline void neon_deinterlace_wstb(
const cv::Mat& frame_3C, cv::Mat& dest,
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t gamma = 0, uint8_t thresh = 0x7F
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t thresh = 0x7F
) {
#if ENABLE_WRAPPER_DIM_SAFETY
CV_Assert(frame_3C.type() == CV_8UC3);
CV_Assert(dest.type() == CV_8UC1);
CV_Assert(frame_3C.size().area() == dest.size().area());
#endif
memcpy_deinterlace_wst_asm(
memcpy_deinterlace_wstb_asm(
frame_3C.data,
dest.data,
frame_3C.size().area(),
~primary, alpha, beta, gamma, thresh);
~primary, alpha, beta, thresh);
}
inline void neon_deinterlace_cvt2gray(
const cv::Mat& frame_3C, cv::Mat& dest
Expand Down
23 changes: 21 additions & 2 deletions lib-vs/out/include/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,22 @@ cs::VideoMode getJsonVideoMode(const wpi::json& config);
/**
* Divides a both parts of a cv::Size object by the specified scale
* @param num_t The numberic type used in the cv::Size input (and function output) - does not need to be explicitly provided
* @param dnum_t The numberic type used for the devisor
* @param input The input size
* @param scale The amount to be divided by
* @return A new cv::Size representing the division
*/
template<typename num_t> static inline
cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
template<typename num_t, typename dnum_t> static inline
cv::Size_<num_t> operator/(cv::Size_<num_t> input, dnum_t scale) {
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
static_assert(std::is_arithmetic<dnum_t>::value, "Template parameter (dnum_t) must be arithemetic type");
return cv::Size_<num_t>(input.width/scale, input.height/scale);
}
// template<typename num_t> static inline
// cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
// static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
// return cv::Size_<num_t>(input.width/scale, input.height/scale);
// }

template<typename num_t>
inline bool inRange(num_t a, num_t lower, num_t upper) {
Expand Down Expand Up @@ -171,6 +178,8 @@ template<typename num_t>
void rescale(std::vector<cv::Point_<num_t> >& points, double scale); // scales up or down (multiplies by scale)
template<typename num_t>
void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double scale);
template<typename num_t>
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale);

template<typename num_t>
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour);
Expand Down Expand Up @@ -267,6 +276,16 @@ void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double sca
}
}
}
template<typename num_t>
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale) {
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
for(cv::Rect_<num_t>& r : rects) {
r.x *= scale;
r.y *= scale;
r.width *= scale;
r.height *= scale;
}
}

template<typename num_t>
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour) {
Expand Down
Binary file modified lib-vs/out/libvs3407.so
Binary file not shown.
8 changes: 4 additions & 4 deletions lib-vs/src/core/aprilpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@


constexpr static inline cv::aruco::PREDEFINED_DICTIONARY_NAME
FRC_DICT = cv::aruco::DICT_APRILTAG_16h5,
FRC_UNOFF_DICT = cv::aruco::DICT_APRILTAG_36h11;
FRC_DICT_2023 = cv::aruco::DICT_APRILTAG_16h5,
FRC_DICT = cv::aruco::DICT_APRILTAG_36h11;
constexpr static inline char const
* FRC_DICT_NAME = "tag16h5",
* FRC_UNOFF_DICT_NAME = "tag36h11";
* FRC_DICT_NAME_2023 = "tag16h5",
* FRC_DICT_NAME = "tag36h11";

template<class derived_t = void>
class AprilPose_ : public vs2::VPipeline<AprilPose_<derived_t> > {
Expand Down
5 changes: 2 additions & 3 deletions lib-vs/src/core/neon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void memcpy_deinterlace_wstb_asm( // subtracts weighted channels from primary,
uint8_t offset,
uint8_t alpha,
uint8_t beta,
uint8_t gamma,
uint8_t thresh
);
void memcpy_deinterlace_togray_asm(
Expand Down Expand Up @@ -185,7 +184,7 @@ inline void neon_wst(
}
inline void neon_deinterlace_wstb(
const cv::Mat& frame_3C, cv::Mat& dest,
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t gamma = 0, uint8_t thresh = 0x7F
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t thresh = 0x7F
) {
#if ENABLE_WRAPPER_DIM_SAFETY
CV_Assert(frame_3C.type() == CV_8UC3);
Expand All @@ -196,7 +195,7 @@ inline void neon_deinterlace_wstb(
frame_3C.data,
dest.data,
frame_3C.size().area(),
~primary, alpha, beta, gamma, thresh);
~primary, alpha, beta, thresh);
}
inline void neon_deinterlace_cvt2gray(
const cv::Mat& frame_3C, cv::Mat& dest
Expand Down
15 changes: 5 additions & 10 deletions lib-vs/src/core/neon64.S
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ memcpy_wst_asm:
* Arg 3 ~ x3: C1/Primary channel offset(index) --> ex. 0 for first; alpha/beta follow
* Arg 4 ~ x4: Alpha
* Arg 5 ~ x5: Beta
* Arg 6 ~ x6: Gamma
* Arg 7 ~ x7: Threshold */
* Arg 6 ~ x6: Threshold */
memcpy_deinterlace_wstb_asm:

dup v4.16b, w4 // duplicate alpha across 16x8bit lanes
Expand All @@ -165,8 +164,7 @@ memcpy_deinterlace_wstb_asm:
clz v5.16b, v5.16b
neg v5.16b, v5.16b

dup v6.16b, w6 // duplicate gamma across 16x8bit lanes
dup v7.16b, w7 // duplicate threshold '''
dup v6.16b, w6 // duplicate threshold '''

lsr x2, x2, #4 // right shift the count by 4 bits (divide by 16, 16 bytes = 128 bits)

Expand All @@ -182,9 +180,8 @@ memcpy_deinterlace_wstb_asm:
ushl v1.16b, v1.16b, v4.16b // weight alpha --> shift right by the amount of leading 0's from alpha (lshift by negative)
ushl v2.16b, v2.16b, v5.16b // weight beta
uqadd v3.16b, v1.16b, v2.16b // add weights
uqadd v3.16b, v3.16b, v6.16b // add gamma
uqsub v3.16b, v0.16b, v3.16b // subtract result from primary
cmhi v3.16b, v3.16b, v7.16b // threshold result
cmhi v3.16b, v3.16b, v6.16b // threshold result

str q3, [x1], #16 // Load out of Q3

Expand All @@ -199,9 +196,8 @@ memcpy_deinterlace_wstb_asm:
ushl v2.16b, v2.16b, v4.16b // weight alpha
ushl v0.16b, v0.16b, v5.16b // weight beta
uqadd v3.16b, v2.16b, v0.16b // add weights
uqadd v3.16b, v3.16b, v6.16b // add gamma
uqsub v3.16b, v1.16b, v3.16b // subtract result from primary
cmhi v3.16b, v3.16b, v7.16b // threshold result
cmhi v3.16b, v3.16b, v6.16b // threshold result

str q3, [x1], #16 // Load out of Q3

Expand All @@ -216,9 +212,8 @@ memcpy_deinterlace_wstb_asm:
ushl v0.16b, v0.16b, v4.16b // weight alpha
ushl v1.16b, v1.16b, v5.16b // weight beta
uqadd v3.16b, v0.16b, v1.16b // add weights
uqadd v3.16b, v3.16b, v6.16b // add gamma
uqsub v3.16b, v2.16b, v3.16b // subtract result from primary
cmhi v3.16b, v3.16b, v7.16b // threshold result
cmhi v3.16b, v3.16b, v6.16b // threshold result

str q3, [x1], #16 // Load out of Q3

Expand Down
23 changes: 21 additions & 2 deletions lib-vs/src/core/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,22 @@ cs::VideoMode getJsonVideoMode(const wpi::json& config);
/**
* Divides a both parts of a cv::Size object by the specified scale
* @param num_t The numberic type used in the cv::Size input (and function output) - does not need to be explicitly provided
* @param dnum_t The numberic type used for the devisor
* @param input The input size
* @param scale The amount to be divided by
* @return A new cv::Size representing the division
*/
template<typename num_t> static inline
cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
template<typename num_t, typename dnum_t> static inline
cv::Size_<num_t> operator/(cv::Size_<num_t> input, dnum_t scale) {
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
static_assert(std::is_arithmetic<dnum_t>::value, "Template parameter (dnum_t) must be arithemetic type");
return cv::Size_<num_t>(input.width/scale, input.height/scale);
}
// template<typename num_t> static inline
// cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
// static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
// return cv::Size_<num_t>(input.width/scale, input.height/scale);
// }

template<typename num_t>
inline bool inRange(num_t a, num_t lower, num_t upper) {
Expand Down Expand Up @@ -171,6 +178,8 @@ template<typename num_t>
void rescale(std::vector<cv::Point_<num_t> >& points, double scale); // scales up or down (multiplies by scale)
template<typename num_t>
void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double scale);
template<typename num_t>
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale);

template<typename num_t>
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour);
Expand Down Expand Up @@ -267,6 +276,16 @@ void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double sca
}
}
}
template<typename num_t>
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale) {
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
for(cv::Rect_<num_t>& r : rects) {
r.x *= scale;
r.y *= scale;
r.width *= scale;
r.height *= scale;
}
}

template<typename num_t>
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour) {
Expand Down

0 comments on commit 6541247

Please sign in to comment.