|
|
VisionWorks Toolkit ReferenceApril 8, 2016 | 1.4 Release |
This section illustrates differences between OpenCV and VisionWorks primitives.
For arithmetic operations (add, subtract, multiply), OpenCV always uses SATURATE conversion policy while VisionWorks allows to choice between SATURATE and WRAP conversion policies.
For the multiply operation, OpenCV always uses ROUND_TO_NEAREST_EVEN rounding policy while VisionWorks allows to choice between ROUND_TO_NEAREST_EVEN and ROUND_TO_ZERO rounding policies.
AccumulateWeighted VisionWorks primitive rounds to zero while cv::addWeighted rounds to nearest.
VisionWorks image filters (Box3x3, Gaussian3x3, etc.) uses VX_BORDER_MODE_UNDEFINED by default, which means that pixels on the border might be calculated inaccurately. OpenCV always uses some border extrapolation method. Use VX_BORDER_MODE_CONSTANT to match cv::BORDER_CONSTANT and VX_BORDER_MODE_REPLICATE to match cv::BORDER_REPLICATE behavior. VisionWorks doesn't have analogues for cv::BORDER_REFLECT, cv::BORDER_REFLECT101 and cv::BORDER_WRAP.
VisionWorks uses BT.709 color space by default while OpenCV uses BT.601. It leads to different results in RGB[X]->Gray conversion if BT.601 is not explicitly used for VisionWorks images.
The OpenCV cv::filter2D function and the VisionWorks Convolve primitive use different formulas.
VisionWorks:
\begin{eqnarray} k_0 &=& \frac{m}{2} \\ l_0 &=& \frac{n}{2} \\ sum(x,y) &=& \sum_{0 \leq k < m,0 \leq l < n} input(x+k_0-k, y+l_0-l) C_{k,l} \end{eqnarray}
OpenCV:
\begin{eqnarray} k_0 &=& \frac{m}{2} \\ l_0 &=& \frac{n}{2} \\ sum(x,y) &=& \sum_{0 \leq k < m,0 \leq l < n} input(x-k_0+k, y-l_0+l) C_{k,l} \end{eqnarray}
In order to port OpenCV code that uses cv::filter2D, the kernel must be reversed and converted into 16S type:
OpenCV cv::integral calculates exclusive sum as \( (W + 1) \times (H + 1) \) image:
\begin{eqnarray} sum(X,Y) &=& \sum_{x < X,y < Y} image(x,y) \end{eqnarray}
and uses the following formula to calculate sum over a rectangular region of the image:
\begin{eqnarray} \sum_{x_1 \leq x < x_2, y_1 \leq y < y_2} image(x,y) = sum(x_2, y_2) - sum(x_1, y_2) - sum(x_2, y_1) + sum(x_1, y_1) \end{eqnarray}
VisionWorks IntegralImage primitive calculates inclusive sum as \( W \times H \) image:
\begin{eqnarray} sum(X,Y) &=& \sum_{x \leq X,y \leq Y} image(x,y) \end{eqnarray}
and uses the following formula to calculate sum over a rectangular region of the image:
\begin{eqnarray} \sum_{x_1 \leq x < x_2, y_1 \leq y < y_2} image(x,y) = sum(x_2 - 1, y_2 - 1) - sum(x_1 - 1, y_2 - 1) - sum(x_2 - 1, y_1 - 1) + sum(x_1 - 1, y_1 - 1) \end{eqnarray}
VisionWorks WarpAffine and WarpPerspective primitives behave like cv::warpAffine and cv::warpPerspective with the cv::WARP_INVERSE_MAP flag. To port cv::warpAffine or cv::warpPerspective calls to VisionWorks, the transformation matrix must be transposed:
The VisionWorks FindHomography primitive returns the homography matrix in a format applicable for the VisionWorks WarpPerspective primitive. To use the homography matrix in OpenCV, it must be transposed: