23 #include <core/exception.h>
24 #include <fvfilters/sobel.h>
28 #elif defined(HAVE_OPENCV)
29 # include <opencv2/opencv.hpp>
31 # error "Neither IPP nor OpenCV available"
34 namespace firevision {
153 default:
throw fawkes::Exception(
"Cannot generate Sobel kernel for the given orientation");
break;
163 #if defined(HAVE_IPP)
170 if (
ori[0] == ORI_HORIZONTAL) {
179 }
else if (
ori[0] == ORI_VERTICAL) {
188 }
else if ((
ori[0] == ORI_DEG_0) || (
ori[0] == ORI_DEG_45) || (
ori[0] == ORI_DEG_90)
189 || (
ori[0] == ORI_DEG_135) || (
ori[0] == ORI_DEG_180) || (
ori[0] == ORI_DEG_225)
190 || (
ori[0] == ORI_DEG_270) || (
ori[0] == ORI_DEG_315) || (
ori[0] == ORI_DEG_360)) {
192 generate_kernel(kernel,
ori[0]);
194 IppiSize kernel_size;
195 kernel_size.width = kernel_size.height = 3;
198 anchor.x = anchor.y = 1;
214 status = ippStsNullPtrErr;
217 if (status != ippStsNoErr) {
220 #elif defined(HAVE_OPENCV)
221 cv::Mat srcm(
src_roi[0]->height,
240 if (
ori[0] == ORI_HORIZONTAL) {
252 }
else if (
ori[0] == ORI_VERTICAL) {
264 }
else if ((
ori[0] == ORI_DEG_0) || (
ori[0] == ORI_DEG_45) || (
ori[0] == ORI_DEG_90)
265 || (
ori[0] == ORI_DEG_135) || (
ori[0] == ORI_DEG_180) || (
ori[0] == ORI_DEG_225)
266 || (
ori[0] == ORI_DEG_270) || (
ori[0] == ORI_DEG_315) || (
ori[0] == ORI_DEG_360)) {
267 cv::Mat kernel(3, 3, CV_32F);
268 generate_kernel((
float *)kernel.ptr(),
ori[0]);
270 cv::filter2D(srcm, dstm, -1, kernel, cv::Point(1, 1));
Base class for exceptions in Fawkes.
virtual void apply()
Apply the filter.
FilterSobel(orientation_t ori=ORI_HORIZONTAL)
Constructor.
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
void shrink_region(ROI *r, unsigned int n)
This shrinks the regions as needed for a N x N matrix.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
unsigned char * dst
Destination buffer.
ROI * dst_roi
Destination ROI.
orientation_t * ori
Orientations, one for each source image.
unsigned int height
ROI height.
fawkes::upoint_t start
ROI start.
unsigned int line_step
line step
unsigned int width
ROI width.
unsigned int pixel_step
pixel step
unsigned int x
x coordinate
unsigned int y
y coordinate