26 #include <core/exception.h> 27 #include <fvfilters/threshold.h> 33 #elif defined(HAVE_OPENCV) 34 # if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) 35 # include <opencv/cv.h> 37 # include <opencv/cv.hpp> 39 # error "Neither IPP nor OpenCV available" 42 namespace firevision {
59 unsigned char min_replace,
61 unsigned char max_replace)
62 :
Filter(
"FilterThreshold")
66 this->min_replace = min_replace;
67 this->max_replace = max_replace;
68 #if defined(HAVE_OPENCV) 69 if (min_replace != 0) {
70 throw fawkes::Exception(
"OpenCV-based threshold filter only allows min_replace=0");
83 unsigned char min_replace,
85 unsigned char max_replace)
89 this->min_replace = min_replace;
90 this->max_replace = max_replace;
111 if (status == ippStsNoErr) {
131 if (status == ippStsNoErr) {
144 if (status != ippStsNoErr) {
148 #elif defined(HAVE_OPENCV) 153 cv::Mat srcm(
src_roi[0]->height,
167 cv::threshold(srcm, dstm, max, max_replace, cv::THRESH_BINARY);
168 cv::threshold(srcm, dstm, min, 0, cv::THRESH_TOZERO);
fawkes::upoint_t start
ROI start.
unsigned int y
y coordinate
unsigned int x
x coordinate
unsigned int width
ROI width.
FilterThreshold(unsigned char min=128, unsigned char min_replace=0, unsigned char max=127, unsigned char max_replace=255)
Constructor.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Base class for exceptions in Fawkes.
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
unsigned int height
ROI height.
virtual void apply()
Apply the filter.
unsigned int line_step
line step
unsigned char * dst
Destination buffer.
unsigned int pixel_step
pixel step
void set_thresholds(unsigned char min, unsigned char min_replace, unsigned char max, unsigned char max_replace)
Set new thresholds.
ROI * dst_roi
Destination ROI.