Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b00c4e

Browse files
committed
Stateless HAL for filters and morphology.
1 parente4d294d commit0b00c4e

File tree

3 files changed

+159
-3
lines changed

3 files changed

+159
-3
lines changed

‎modules/imgproc/src/filter.dispatch.cpp‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,24 @@ static bool replacementFilter2D(int stype, int dtype, int kernel_type,
11711171
int anchor_x,int anchor_y,
11721172
double delta,int borderType,bool isSubmatrix)
11731173
{
1174+
// Prioritize stateless implementation
1175+
int res =cv_hal_filter_stateless(src_data, src_step, stype,
1176+
dst_data, dst_step, dtype, width, height,
1177+
full_width, full_height, offset_x, offset_y,
1178+
kernel_data, kernel_step, kernel_type,
1179+
kernel_width, kernel_height, anchor_x, anchor_y,
1180+
delta, borderType, isSubmatrix, src_data == dst_data);
1181+
if (res == CV_HAL_ERROR_OK)
1182+
{
1183+
returntrue;
1184+
}elseif (res != CV_HAL_ERROR_NOT_IMPLEMENTED)
1185+
{
1186+
CV_Error_(cv::Error::StsInternal,
1187+
("HAL implementation filter_stateless ==>"CVAUX_STR(cv_hal_filter_stateless)" returned %d (0x%08x)", res, res));
1188+
}
1189+
11741190
cvhalFilter2D* ctx;
1175-
intres =cv_hal_filterInit(&ctx, kernel_data, kernel_step, kernel_type, kernel_width, kernel_height, width, height,
1191+
res =cv_hal_filterInit(&ctx, kernel_data, kernel_step, kernel_type, kernel_width, kernel_height, width, height,
11761192
stype, dtype, borderType, delta, anchor_x, anchor_y, isSubmatrix, src_data == dst_data);
11771193
if (res == CV_HAL_ERROR_NOT_IMPLEMENTED)
11781194
{
@@ -1385,8 +1401,23 @@ static bool replacementSepFilter(int stype, int dtype, int ktype,
13851401
uchar * kernely_data,int kernely_len,
13861402
int anchor_x,int anchor_y,double delta,int borderType)
13871403
{
1404+
// Prioritize stateless implementation
1405+
int res =cv_hal_sepFilter_stateless(src_data, src_step, stype,
1406+
dst_data, dst_step, dtype,
1407+
width, height, full_width, full_height, offset_x, offset_y,
1408+
kernelx_data, kernelx_len, kernely_data, kernely_len, ktype,
1409+
anchor_x, anchor_y, delta, borderType);
1410+
if (res == CV_HAL_ERROR_OK)
1411+
{
1412+
returntrue;
1413+
}elseif (res != CV_HAL_ERROR_NOT_IMPLEMENTED)
1414+
{
1415+
CV_Error_(cv::Error::StsInternal,
1416+
("HAL implementation sepFilter_stateless ==>"CVAUX_STR(cv_hal_sepFilter_stateless)" returned %d (0x%08x)", res, res));
1417+
}
1418+
13881419
cvhalFilter2D *ctx;
1389-
intres =cv_hal_sepFilterInit(&ctx, stype, dtype, ktype,
1420+
res =cv_hal_sepFilterInit(&ctx, stype, dtype, ktype,
13901421
kernelx_data, kernelx_len,
13911422
kernely_data, kernely_len,
13921423
anchor_x, anchor_y, delta, borderType);

‎modules/imgproc/src/hal_replacement.hpp‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,40 @@ int my_hal_filterFree(cvhalFilter2D *context) {
8686
*/
8787
structcvhalFilter2D {};
8888

89+
/**
90+
@brief 2D filtering in a stateless manner
91+
@param src_data source image data
92+
@param src_step source image step
93+
@param src_type source image type
94+
@param dst_data destination image data
95+
@param dst_step destination image step
96+
@param dst_type destination image type
97+
@param width images width
98+
@param height images height
99+
@param full_width full width of source image (outside the ROI)
100+
@param full_height full height of source image (outside the ROI)
101+
@param offset_x source image ROI offset X
102+
@param offset_y source image ROI offset Y
103+
@param kernel_data pointer to kernel data
104+
@param kernel_step kernel step
105+
@param kernel_type kernel type (CV_8U, ...)
106+
@param kernel_width kernel width
107+
@param kernel_height kernel height
108+
@param anchor_x relative X position of center point within the kernel
109+
@param anchor_y relative Y position of center point within the kernel
110+
@param delta added to pixel values
111+
@param borderType border processing mode (CV_HAL_BORDER_REFLECT, ...)
112+
@param isSubmatrix indicates whether the submatrices will be allowed as source image
113+
@param allowInplace indicates whether the inplace operation will be possible
114+
@sa cv::filter2D, cv::hal::Filter2D
115+
*/
116+
inlineinthal_ni_filter_stateless(uchar * src_data,size_t src_step,int src_type,
117+
uchar * dst_data,size_t dst_step,int dst_type,
118+
int width,int height,int full_width,int full_height,int offset_x,int offset_y,
119+
uchar * kernel_data,size_t kernel_step,int kernel_type,int kernel_width,int kernel_height,
120+
int anchor_x,int anchor_y,double delta,int borderType,bool isSubmatrix,bool allowInplace)
121+
{return CV_HAL_ERROR_NOT_IMPLEMENTED; }
122+
89123
/**
90124
@brief hal_filterInit
91125
@param context double pointer to user-defined context
@@ -131,11 +165,44 @@ inline int hal_ni_filter(cvhalFilter2D *context, uchar *src_data, size_t src_ste
131165
inlineinthal_ni_filterFree(cvhalFilter2D *context) {return CV_HAL_ERROR_NOT_IMPLEMENTED; }
132166

133167
//! @cond IGNORED
168+
#definecv_hal_filter_stateless hal_ni_filter_stateless
134169
#definecv_hal_filterInit hal_ni_filterInit
135170
#definecv_hal_filter hal_ni_filter
136171
#definecv_hal_filterFree hal_ni_filterFree
137172
//! @endcond
138173

174+
/**
175+
@brief separable filtering in a stateless manner
176+
@param src_data source image data
177+
@param src_step source image step
178+
@param src_type source image type
179+
@param dst_data destination image data
180+
@param dst_step destination image step
181+
@param dst_type destination image type
182+
@param width images width
183+
@param height images height
184+
@param full_width full width of source image (outside the ROI)
185+
@param full_height full height of source image (outside the ROI)
186+
@param offset_x source image ROI offset X
187+
@param offset_y source image ROI offset Y
188+
@param kernelx_data pointer to x-kernel data
189+
@param kernelx_len x-kernel vector length
190+
@param kernely_data pointer to y-kernel data
191+
@param kernely_len y-kernel vector length
192+
@param kernel_type kernel type (CV_8U, ...)
193+
@param anchor_x relative X position of center point within the kernel
194+
@param anchor_y relative Y position of center point within the kernel
195+
@param delta added to pixel values
196+
@param borderType border processing mode (CV_HAL_BORDER_REFLECT, ...)
197+
@sa cv::sepFilter2D, cv::hal::SepFilter2D
198+
*/
199+
inlineinthal_ni_sepFilter_stateless(uchar * src_data,size_t src_step,int src_type,
200+
uchar * dst_data,size_t dst_step,int dst_type,
201+
int width,int height,int full_width,int full_height,int offset_x,int offset_y,
202+
uchar * kernelx_data,int kernelx_len, uchar * kernely_data,int kernely_len,int kernel_type,
203+
int anchor_x,int anchor_y,double delta,int borderType)
204+
{return CV_HAL_ERROR_NOT_IMPLEMENTED; }
205+
139206
/**
140207
@brief hal_sepFilterInit
141208
@param context double pointer to user-defined context
@@ -177,11 +244,54 @@ inline int hal_ni_sepFilter(cvhalFilter2D *context, uchar *src_data, size_t src_
177244
inlineinthal_ni_sepFilterFree(cvhalFilter2D *context) {return CV_HAL_ERROR_NOT_IMPLEMENTED; }
178245

179246
//! @cond IGNORED
247+
#definecv_hal_sepFilter_stateless hal_ni_sepFilter_stateless
180248
#definecv_hal_sepFilterInit hal_ni_sepFilterInit
181249
#definecv_hal_sepFilter hal_ni_sepFilter
182250
#definecv_hal_sepFilterFree hal_ni_sepFilterFree
183251
//! @endcond
184252

253+
/**
254+
@brief morphology in a stateless manner
255+
@param operation morphology operation CV_HAL_MORPH_ERODE or CV_HAL_MORPH_DILATE
256+
@param src_type source image type
257+
@param dst_type destination image type
258+
@param src_data source image data
259+
@param src_step source image step
260+
@param dst_data destination image data
261+
@param dst_step destination image step
262+
@param width images width
263+
@param height images height
264+
@param src_full_width full width of source image (outside the ROI)
265+
@param src_full_height full height of source image (outside the ROI)
266+
@param src_roi_x source image ROI X offset
267+
@param src_roi_y source image ROI Y offset
268+
@param dst_full_width full width of destination image
269+
@param dst_full_height full height of destination image
270+
@param dst_roi_x destination image ROI X offset
271+
@param dst_roi_y destination image ROI Y offset
272+
@param kernel_type kernel type (CV_8U, ...)
273+
@param kernel_data pointer to kernel data
274+
@param kernel_step kernel step
275+
@param kernel_width kernel width
276+
@param kernel_height kernel height
277+
@param anchor_x relative X position of center point within the kernel
278+
@param anchor_y relative Y position of center point within the kernel
279+
@param borderType border processing mode (CV_HAL_BORDER_REFLECT, ...)
280+
@param borderValue values to use for CV_HAL_BORDER_CONSTANT mode
281+
@param iterations number of iterations
282+
@param allowSubmatrix indicates whether the submatrices will be allowed as source image
283+
@param allowInplace indicates whether the inplace operation will be possible
284+
@sa cv::erode, cv::dilate, cv::morphologyEx, cv::hal::Morph
285+
*/
286+
inlineinthal_ni_morph_stateless(int operation, uchar * src_data,size_t src_step,int src_type,
287+
uchar * dst_data,size_t dst_step,int dst_type,
288+
int width,int height,int src_full_width,int src_full_height,int src_roi_x,int src_roi_y,
289+
int dst_full_width,int dst_full_height,int dst_roi_x,int dst_roi_y,
290+
uchar * kernel_data,size_t kernel_step,int kernel_type,int kernel_width,int kernel_height,
291+
int anchor_x,int anchor_y,int borderType,constdouble borderValue[4],
292+
int iterations,bool allowSubmatrix,bool allowInplace)
293+
{return CV_HAL_ERROR_NOT_IMPLEMENTED; }
294+
185295
/**
186296
@brief hal_morphInit
187297
@param context double pointer to user-defined context
@@ -233,6 +343,7 @@ inline int hal_ni_morph(cvhalFilter2D *context, uchar *src_data, size_t src_step
233343
inlineinthal_ni_morphFree(cvhalFilter2D *context) {return CV_HAL_ERROR_NOT_IMPLEMENTED; }
234344

235345
//! @cond IGNORED
346+
#definecv_hal_morph_stateless hal_ni_morph_stateless
236347
#definecv_hal_morphInit hal_ni_morphInit
237348
#definecv_hal_morph hal_ni_morph
238349
#definecv_hal_morphFree hal_ni_morphFree

‎modules/imgproc/src/morph.dispatch.cpp‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,22 @@ static bool halMorph(int op, int src_type, int dst_type,
212212
int kernel_width,int kernel_height,int anchor_x,int anchor_y,
213213
int borderType,constdouble borderValue[4],int iterations,bool isSubmatrix)
214214
{
215+
// Prioritize stateless implementation
216+
int res =cv_hal_morph_stateless(op, src_data, src_step, src_type, dst_data, dst_step, dst_type, width, height,
217+
roi_width, roi_height, roi_x, roi_y, roi_width2, roi_height2, roi_x2, roi_y2,
218+
kernel_data, kernel_step, kernel_type, kernel_width, kernel_height, anchor_x, anchor_y,
219+
borderType, borderValue, iterations, isSubmatrix, src_data == dst_data);
220+
if (res == CV_HAL_ERROR_OK)
221+
{
222+
returntrue;
223+
}elseif (res != CV_HAL_ERROR_NOT_IMPLEMENTED)
224+
{
225+
CV_Error_(cv::Error::StsInternal,
226+
("HAL implementation morph_stateless ==>"CVAUX_STR(cv_hal_morph_stateless)" returned %d (0x%08x)", res, res));
227+
}
228+
215229
cvhalFilter2D * ctx;
216-
intres =cv_hal_morphInit(&ctx, op, src_type, dst_type, width, height,
230+
res =cv_hal_morphInit(&ctx, op, src_type, dst_type, width, height,
217231
kernel_type, kernel_data, kernel_step, kernel_width, kernel_height,
218232
anchor_x, anchor_y,
219233
borderType, borderValue,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp