@@ -1643,29 +1643,18 @@ namespace cv
1643
1643
Size ksize, Point anchor,
1644
1644
bool normalize, int borderType)
1645
1645
{
1646
- int stype = _src.type ();
1647
1646
if (ddepth < 0 )
1648
1647
ddepth = CV_8UC1;
1649
- if (stype != CV_8UC1 || (ddepth != CV_8U && ddepth != CV_16S) ||
1650
- (anchor.x >= 0 && anchor.x != ksize.width / 2 ) ||
1651
- (anchor.y >= 0 && anchor.y != ksize.height / 2 ) ||
1652
- ksize.width != 3 || ksize.height != 3 )
1648
+ if (_src.type () != CV_8UC1 || ddepth != CV_8U || !normalize ||
1649
+ _src.cols < 3 || _src.rows < 3 ||
1650
+ ksize.width != 3 || ksize.height != 3 ||
1651
+ (anchor.x >= 0 && anchor.x != 1 ) ||
1652
+ (anchor.y >= 0 && anchor.y != 1 ) ||
1653
+ ovx::skipSmallImages<VX_KERNEL_BOX_3x3>(_src.cols , _src.rows ))
1653
1654
return false ;
1654
1655
1655
1656
Mat src = _src.getMat ();
1656
1657
1657
- if (ddepth == CV_8U && ksize.width == 3 && ksize.height == 3 && normalize ?
1658
- ovx::skipSmallImages<VX_KERNEL_BOX_3x3>(src.cols , src.rows ) :
1659
- ovx::skipSmallImages<VX_KERNEL_CUSTOM_CONVOLUTION>(src.cols , src.rows )
1660
- )
1661
- return false ;
1662
-
1663
- _dst.create (src.size (), CV_MAKETYPE (ddepth, 1 ));
1664
- Mat dst = _dst.getMat ();
1665
-
1666
- if (src.cols < ksize.width || src.rows < ksize.height )
1667
- return false ;
1668
-
1669
1658
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix ())
1670
1659
return false ; // Process isolated borders only
1671
1660
vx_enum border;
@@ -1681,11 +1670,12 @@ namespace cv
1681
1670
return false ;
1682
1671
}
1683
1672
1673
+ _dst.create (src.size (), CV_8UC1);
1674
+ Mat dst = _dst.getMat ();
1675
+
1684
1676
try
1685
1677
{
1686
1678
ivx::Context ctx = ovx::getOpenVXContext ();
1687
- // if ((vx_size)(ksize.width) > ctx.convolutionMaxDimension() || (vx_size)(ksize.height) > ctx.convolutionMaxDimension())
1688
- // return false;
1689
1679
1690
1680
Mat a;
1691
1681
if (dst.data != src.data )
@@ -1696,34 +1686,14 @@ namespace cv
1696
1686
ivx::Image
1697
1687
ia = ivx::Image::createFromHandle (ctx, VX_DF_IMAGE_U8,
1698
1688
ivx::Image::createAddressing (a.cols , a.rows , 1 , (vx_int32)(a.step )), a.data ),
1699
- ib = ivx::Image::createFromHandle (ctx, ddepth == CV_16S ? VX_DF_IMAGE_S16 : VX_DF_IMAGE_U8,
1700
- ivx::Image::createAddressing (dst.cols , dst.rows , ddepth == CV_16S ? 2 : 1 , (vx_int32)(dst.step )), dst.data );
1689
+ ib = ivx::Image::createFromHandle (ctx, VX_DF_IMAGE_U8,
1690
+ ivx::Image::createAddressing (dst.cols , dst.rows , 1 , (vx_int32)(dst.step )), dst.data );
1701
1691
1702
1692
// ATTENTION: VX_CONTEXT_IMMEDIATE_BORDER attribute change could lead to strange issues in multi-threaded environments
1703
1693
// since OpenVX standart says nothing about thread-safety for now
1704
1694
ivx::border_t prevBorder = ctx.immediateBorder ();
1705
1695
ctx.setImmediateBorder (border, (vx_uint8)(0 ));
1706
- if (ddepth == CV_8U && ksize.width == 3 && ksize.height == 3 && normalize)
1707
- {
1708
- ivx::IVX_CHECK_STATUS (vxuBox3x3 (ctx, ia, ib));
1709
- }
1710
- else
1711
- {
1712
- #if VX_VERSION <= VX_VERSION_1_0
1713
- if (ctx.vendorID () == VX_ID_KHRONOS && ((vx_size)(src.cols ) <= ctx.convolutionMaxDimension () || (vx_size)(src.rows ) <= ctx.convolutionMaxDimension ()))
1714
- {
1715
- ctx.setImmediateBorder (prevBorder);
1716
- return false ;
1717
- }
1718
- #endif
1719
- Mat convData (ksize, CV_16SC1);
1720
- convData = normalize ? (1 << 15 ) / (ksize.width * ksize.height ) : 1 ;
1721
- ivx::Convolution cnv = ivx::Convolution::create (ctx, convData.cols , convData.rows );
1722
- cnv.copyFrom (convData);
1723
- if (normalize)
1724
- cnv.setScale (1 << 15 );
1725
- ivx::IVX_CHECK_STATUS (vxuConvolve (ctx, ia, cnv, ib));
1726
- }
1696
+ ivx::IVX_CHECK_STATUS (vxuBox3x3 (ctx, ia, ib));
1727
1697
ctx.setImmediateBorder (prevBorder);
1728
1698
}
1729
1699
catch (ivx::RuntimeError & e)
@@ -2205,7 +2175,6 @@ static bool ocl_GaussianBlur_8UC1(InputArray _src, OutputArray _dst, Size ksize,
2205
2175
static bool openvx_gaussianBlur (InputArray _src, OutputArray _dst, Size ksize,
2206
2176
double sigma1, double sigma2, int borderType)
2207
2177
{
2208
- int stype = _src.type ();
2209
2178
if (sigma2 <= 0 )
2210
2179
sigma2 = sigma1;
2211
2180
// automatic detection of kernel size from sigma
@@ -2214,26 +2183,20 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
2214
2183
if (ksize.height <= 0 && sigma2 > 0 )
2215
2184
ksize.height = cvRound (sigma2*6 + 1 ) | 1 ;
2216
2185
2217
- if (stype != CV_8UC1 ||
2218
- ksize.width < 3 || ksize.height < 3 ||
2219
- ksize.width > 5 || ksize.height > 5 ||
2220
- ksize.width % 2 != 1 || ksize.height % 2 != 1 )
2186
+ if (_src.type () != CV_8UC1 ||
2187
+ _src.cols < 3 || _src.rows < 3 ||
2188
+ ksize.width != 3 || ksize.height != 3 )
2221
2189
return false ;
2222
2190
2223
2191
sigma1 = std::max (sigma1, 0 .);
2224
2192
sigma2 = std::max (sigma2, 0 .);
2225
2193
2226
- Mat src = _src.getMat ();
2227
- Mat dst = _dst.getMat ();
2228
-
2229
- if (ksize.width == 3 && ksize.height == 3 && (sigma1 == 0.0 || (sigma1 - 0.8 ) < DBL_EPSILON) && (sigma2 == 0.0 || (sigma2 - 0.8 ) < DBL_EPSILON) ?
2230
- ovx::skipSmallImages<VX_KERNEL_GAUSSIAN_3x3>(src.cols , src.rows ) :
2231
- ovx::skipSmallImages<VX_KERNEL_CUSTOM_CONVOLUTION>(src.cols , src.rows )
2232
- )
2194
+ if (!(sigma1 == 0.0 || (sigma1 - 0.8 ) < DBL_EPSILON) || !(sigma2 == 0.0 || (sigma2 - 0.8 ) < DBL_EPSILON) ||
2195
+ ovx::skipSmallImages<VX_KERNEL_GAUSSIAN_3x3>(_src.cols , _src.rows ))
2233
2196
return false ;
2234
2197
2235
- if ( src. cols < ksize. width || src. rows < ksize. height )
2236
- return false ;
2198
+ Mat src = _src. getMat ();
2199
+ Mat dst = _dst. getMat () ;
2237
2200
2238
2201
if ((borderType & BORDER_ISOLATED) == 0 && src.isSubmatrix ())
2239
2202
return false ; // Process isolated borders only
@@ -2253,8 +2216,6 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
2253
2216
try
2254
2217
{
2255
2218
ivx::Context ctx = ovx::getOpenVXContext ();
2256
- if ((vx_size)(ksize.width ) > ctx.convolutionMaxDimension () || (vx_size)(ksize.height ) > ctx.convolutionMaxDimension ())
2257
- return false ;
2258
2219
2259
2220
Mat a;
2260
2221
if (dst.data != src.data )
@@ -2272,26 +2233,7 @@ static bool openvx_gaussianBlur(InputArray _src, OutputArray _dst, Size ksize,
2272
2233
// since OpenVX standart says nothing about thread-safety for now
2273
2234
ivx::border_t prevBorder = ctx.immediateBorder ();
2274
2235
ctx.setImmediateBorder (border, (vx_uint8)(0 ));
2275
- if (ksize.width == 3 && ksize.height == 3 && (sigma1 == 0.0 || (sigma1 - 0.8 ) < DBL_EPSILON) && (sigma2 == 0.0 || (sigma2 - 0.8 ) < DBL_EPSILON))
2276
- {
2277
- ivx::IVX_CHECK_STATUS (vxuGaussian3x3 (ctx, ia, ib));
2278
- }
2279
- else
2280
- {
2281
- #if VX_VERSION <= VX_VERSION_1_0
2282
- if (ctx.vendorID () == VX_ID_KHRONOS && ((vx_size)(a.cols ) <= ctx.convolutionMaxDimension () || (vx_size)(a.rows ) <= ctx.convolutionMaxDimension ()))
2283
- {
2284
- ctx.setImmediateBorder (prevBorder);
2285
- return false ;
2286
- }
2287
- #endif
2288
- Mat convData;
2289
- cv::Mat (cv::getGaussianKernel (ksize.height , sigma2)*cv::getGaussianKernel (ksize.width , sigma1).t ()).convertTo (convData, CV_16SC1, (1 << 15 ));
2290
- ivx::Convolution cnv = ivx::Convolution::create (ctx, convData.cols , convData.rows );
2291
- cnv.copyFrom (convData);
2292
- cnv.setScale (1 << 15 );
2293
- ivx::IVX_CHECK_STATUS (vxuConvolve (ctx, ia, cnv, ib));
2294
- }
2236
+ ivx::IVX_CHECK_STATUS (vxuGaussian3x3 (ctx, ia, ib));
2295
2237
ctx.setImmediateBorder (prevBorder);
2296
2238
}
2297
2239
catch (ivx::RuntimeError & e)
0 commit comments