25 #include <hip/hip_runtime.h>
30 using namespace roccv;
34 static __host__ __device__ __forceinline__
bool pixel_in_box(
float ix,
float iy,
float left,
float right,
float top,
float bottom) {
35 return (ix > left) && (ix < right) && (iy > top) && (iy < bottom);
39 static __host__ __device__
void blend_single_color(T &color,
const T &color_in) {
41 using WorkType = float4;
42 WorkType fgColor = detail::RangeCast<WorkType>(color_in);
43 WorkType bgColor = detail::RangeCast<WorkType>(color);
44 float fgAlpha = fgColor.w;
45 float bgAlpha = bgColor.w;
46 float blendAlpha = fgAlpha + bgAlpha * (1 - fgAlpha);
48 WorkType blendColor = (fgColor * fgAlpha + bgColor * bgAlpha * (1 - fgAlpha)) / blendAlpha;
49 blendColor.w = blendAlpha;
50 color = detail::RangeCast<T>(blendColor);
54 inline static __host__ __device__
void shade_rectangle(
const Rect_t &rect,
int ix,
int iy, T *out_color) {
58 blend_single_color<T>(out_color[0], detail::RangeCast<T>(rect.
color));
62 blend_single_color<T>(out_color[0], detail::RangeCast<T>(rect.
color));
99 inline __device__ __host__
float norm1(
const T &a) {
101 if constexpr (NumElements<T> == 1)
103 else if constexpr (NumElements<T> == 2)
104 return abs(a.x) + abs(a.y);
105 else if constexpr (NumElements<T> == 3)
106 return abs(a.x) + abs(a.y) + abs(a.z);
107 else if constexpr (NumElements<T> == 4)
108 return abs(a.x) + abs(a.y) + abs(a.z) + abs(a.w);
143 template <
typename T>
144 inline __device__ __host__
void bgr2yuv_kernel(
const T &r,
const T &g,
const T &b,
float &y,
float &u,
float &v,
146 y = r * factors.
a + g * factors.
b + b * factors.
c;
147 v = (r - y) / factors.
e;
148 u = (b - y) / factors.
d;
151 template <
typename T>
152 inline __device__ __host__
void yuv2rgb_kernel(
const T &y,
const T &u,
const T &v,
float &r,
float &g,
float &b,
154 r = y + factors.
e * (v - delta);
155 g = y - (factors.
a * factors.
e / factors.
b) * (v - delta) - (factors.
c * factors.
b / factors.
b) * (u - delta);
156 b = y + factors.
d * (u - delta);
Definition: exception.hpp:31
const float BT601E
Definition: kernel_helpers.hpp:73
const float BT2020A
Definition: kernel_helpers.hpp:83
const float BT709E
Definition: kernel_helpers.hpp:80
const float BT2020C
Definition: kernel_helpers.hpp:85
const float BT2020B
Definition: kernel_helpers.hpp:84
const float BT709A
Definition: kernel_helpers.hpp:76
const float BT601D
Definition: kernel_helpers.hpp:72
const float BT709C
Definition: kernel_helpers.hpp:78
const float BT601C
Definition: kernel_helpers.hpp:71
const float BT2020D
Definition: kernel_helpers.hpp:86
const float BT709D
Definition: kernel_helpers.hpp:79
const float BT601B
Definition: kernel_helpers.hpp:70
const float BT2020E
Definition: kernel_helpers.hpp:87
const float BT709B
Definition: kernel_helpers.hpp:77
const float BT601A
Definition: kernel_helpers.hpp:69
Definition: non_max_suppression_helpers.hpp:26
Definition: strided_data_wrap.hpp:33
Definition: strided_data_wrap.hpp:33
@ NOT_IMPLEMENTED
invalid permutation of parameters.
eColorSpec
Definition: operator_types.h:66
@ BT2020
Definition: operator_types.h:69
@ BT601
Definition: operator_types.h:67
@ BT709
Definition: operator_types.h:68
Definition: kernel_helpers.hpp:89
float e
Definition: kernel_helpers.hpp:94
float b
Definition: kernel_helpers.hpp:91
float d
Definition: kernel_helpers.hpp:93
float a
Definition: kernel_helpers.hpp:90
float c
Definition: kernel_helpers.hpp:92
Definition: operator_types.h:115
float i_right
Definition: operator_types.h:118
float o_left
Definition: operator_types.h:117
float i_left
Definition: operator_types.h:118
bool bordered
Definition: operator_types.h:120
float o_bottom
Definition: operator_types.h:117
float i_top
Definition: operator_types.h:118
float o_right
Definition: operator_types.h:117
float i_bottom
Definition: operator_types.h:118
float o_top
Definition: operator_types.h:117
uchar4 color
Definition: operator_types.h:119