Skip to content

Commit 6541247

Browse files
authored
Merge pull request #16 from S1ink/temp-additions
changes!?
2 parents de43dc9 + e20ec21 commit 6541247

7 files changed

Lines changed: 56 additions & 25 deletions

File tree

lib-vs/out/include/neon.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ void memcpy_deinterlace_wstb_asm( // subtracts weighted channels from primary,
4848
uint8_t offset,
4949
uint8_t alpha,
5050
uint8_t beta,
51-
uint8_t gamma,
5251
uint8_t thresh
5352
);
5453
void memcpy_deinterlace_togray_asm(
@@ -185,18 +184,18 @@ inline void neon_wst(
185184
}
186185
inline void neon_deinterlace_wstb(
187186
const cv::Mat& frame_3C, cv::Mat& dest,
188-
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t gamma = 0, uint8_t thresh = 0x7F
187+
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t thresh = 0x7F
189188
) {
190189
#if ENABLE_WRAPPER_DIM_SAFETY
191190
CV_Assert(frame_3C.type() == CV_8UC3);
192191
CV_Assert(dest.type() == CV_8UC1);
193192
CV_Assert(frame_3C.size().area() == dest.size().area());
194193
#endif
195-
memcpy_deinterlace_wst_asm(
194+
memcpy_deinterlace_wstb_asm(
196195
frame_3C.data,
197196
dest.data,
198197
frame_3C.size().area(),
199-
~primary, alpha, beta, gamma, thresh);
198+
~primary, alpha, beta, thresh);
200199
}
201200
inline void neon_deinterlace_cvt2gray(
202201
const cv::Mat& frame_3C, cv::Mat& dest

lib-vs/out/include/vision.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,22 @@ cs::VideoMode getJsonVideoMode(const wpi::json& config);
6363
/**
6464
* Divides a both parts of a cv::Size object by the specified scale
6565
* @param num_t The numberic type used in the cv::Size input (and function output) - does not need to be explicitly provided
66+
* @param dnum_t The numberic type used for the devisor
6667
* @param input The input size
6768
* @param scale The amount to be divided by
6869
* @return A new cv::Size representing the division
6970
*/
70-
template<typename num_t> static inline
71-
cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
71+
template<typename num_t, typename dnum_t> static inline
72+
cv::Size_<num_t> operator/(cv::Size_<num_t> input, dnum_t scale) {
7273
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
74+
static_assert(std::is_arithmetic<dnum_t>::value, "Template parameter (dnum_t) must be arithemetic type");
7375
return cv::Size_<num_t>(input.width/scale, input.height/scale);
7476
}
77+
// template<typename num_t> static inline
78+
// cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
79+
// static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
80+
// return cv::Size_<num_t>(input.width/scale, input.height/scale);
81+
// }
7582

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

175184
template<typename num_t>
176185
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour);
@@ -267,6 +276,16 @@ void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double sca
267276
}
268277
}
269278
}
279+
template<typename num_t>
280+
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale) {
281+
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
282+
for(cv::Rect_<num_t>& r : rects) {
283+
r.x *= scale;
284+
r.y *= scale;
285+
r.width *= scale;
286+
r.height *= scale;
287+
}
288+
}
270289

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

lib-vs/out/libvs3407.so

0 Bytes
Binary file not shown.

lib-vs/src/core/aprilpose.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111

1212
constexpr static inline cv::aruco::PREDEFINED_DICTIONARY_NAME
13-
FRC_DICT = cv::aruco::DICT_APRILTAG_16h5,
14-
FRC_UNOFF_DICT = cv::aruco::DICT_APRILTAG_36h11;
13+
FRC_DICT_2023 = cv::aruco::DICT_APRILTAG_16h5,
14+
FRC_DICT = cv::aruco::DICT_APRILTAG_36h11;
1515
constexpr static inline char const
16-
* FRC_DICT_NAME = "tag16h5",
17-
* FRC_UNOFF_DICT_NAME = "tag36h11";
16+
* FRC_DICT_NAME_2023 = "tag16h5",
17+
* FRC_DICT_NAME = "tag36h11";
1818

1919
template<class derived_t = void>
2020
class AprilPose_ : public vs2::VPipeline<AprilPose_<derived_t> > {

lib-vs/src/core/neon.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ void memcpy_deinterlace_wstb_asm( // subtracts weighted channels from primary,
4848
uint8_t offset,
4949
uint8_t alpha,
5050
uint8_t beta,
51-
uint8_t gamma,
5251
uint8_t thresh
5352
);
5453
void memcpy_deinterlace_togray_asm(
@@ -185,7 +184,7 @@ inline void neon_wst(
185184
}
186185
inline void neon_deinterlace_wstb(
187186
const cv::Mat& frame_3C, cv::Mat& dest,
188-
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t gamma = 0, uint8_t thresh = 0x7F
187+
vs2::BGR primary, uint8_t alpha = 0xFF, uint8_t beta = 0xFF, uint8_t thresh = 0x7F
189188
) {
190189
#if ENABLE_WRAPPER_DIM_SAFETY
191190
CV_Assert(frame_3C.type() == CV_8UC3);
@@ -196,7 +195,7 @@ inline void neon_deinterlace_wstb(
196195
frame_3C.data,
197196
dest.data,
198197
frame_3C.size().area(),
199-
~primary, alpha, beta, gamma, thresh);
198+
~primary, alpha, beta, thresh);
200199
}
201200
inline void neon_deinterlace_cvt2gray(
202201
const cv::Mat& frame_3C, cv::Mat& dest

lib-vs/src/core/neon64.S

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ memcpy_wst_asm:
153153
* Arg 3 ~ x3: C1/Primary channel offset(index) --> ex. 0 for first; alpha/beta follow
154154
* Arg 4 ~ x4: Alpha
155155
* Arg 5 ~ x5: Beta
156-
* Arg 6 ~ x6: Gamma
157-
* Arg 7 ~ x7: Threshold */
156+
* Arg 6 ~ x6: Threshold */
158157
memcpy_deinterlace_wstb_asm:
159158

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

168-
dup v6.16b, w6 // duplicate gamma across 16x8bit lanes
169-
dup v7.16b, w7 // duplicate threshold '''
167+
dup v6.16b, w6 // duplicate threshold '''
170168

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

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

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

@@ -199,9 +196,8 @@ memcpy_deinterlace_wstb_asm:
199196
ushl v2.16b, v2.16b, v4.16b // weight alpha
200197
ushl v0.16b, v0.16b, v5.16b // weight beta
201198
uqadd v3.16b, v2.16b, v0.16b // add weights
202-
uqadd v3.16b, v3.16b, v6.16b // add gamma
203199
uqsub v3.16b, v1.16b, v3.16b // subtract result from primary
204-
cmhi v3.16b, v3.16b, v7.16b // threshold result
200+
cmhi v3.16b, v3.16b, v6.16b // threshold result
205201

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

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

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

lib-vs/src/core/vision.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,22 @@ cs::VideoMode getJsonVideoMode(const wpi::json& config);
6363
/**
6464
* Divides a both parts of a cv::Size object by the specified scale
6565
* @param num_t The numberic type used in the cv::Size input (and function output) - does not need to be explicitly provided
66+
* @param dnum_t The numberic type used for the devisor
6667
* @param input The input size
6768
* @param scale The amount to be divided by
6869
* @return A new cv::Size representing the division
6970
*/
70-
template<typename num_t> static inline
71-
cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
71+
template<typename num_t, typename dnum_t> static inline
72+
cv::Size_<num_t> operator/(cv::Size_<num_t> input, dnum_t scale) {
7273
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
74+
static_assert(std::is_arithmetic<dnum_t>::value, "Template parameter (dnum_t) must be arithemetic type");
7375
return cv::Size_<num_t>(input.width/scale, input.height/scale);
7476
}
77+
// template<typename num_t> static inline
78+
// cv::Size_<num_t> operator/(cv::Size_<num_t> input, size_t scale) {
79+
// static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
80+
// return cv::Size_<num_t>(input.width/scale, input.height/scale);
81+
// }
7582

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

175184
template<typename num_t>
176185
cv::Point_<num_t> findCenter(const std::vector<cv::Point_<num_t> >& contour);
@@ -267,6 +276,16 @@ void rescale(std::vector<std::vector<cv::Point_<num_t> > >& contours, double sca
267276
}
268277
}
269278
}
279+
template<typename num_t>
280+
void rescale(std::vector<cv::Rect_<num_t> >& rects, double scale) {
281+
static_assert(std::is_arithmetic<num_t>::value, "Template parameter (num_t) must be arithemetic type");
282+
for(cv::Rect_<num_t>& r : rects) {
283+
r.x *= scale;
284+
r.y *= scale;
285+
r.width *= scale;
286+
r.height *= scale;
287+
}
288+
}
270289

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

0 commit comments

Comments
 (0)