bool ImageFlip::process() { CvMatData in = m_inputPin->get(); CvMatData out = CvMatData::create(in.properties()); // open for reading const cv::Mat& src = in; // open image for writing cv::Mat& target = out; // do a flip of the image cv::flip( src, target, m_method.getSelectedValue() ); // publish the new image m_outputPin->put( target ); return true; }
/** Calculates the first, second, third or mixed image derivatives using an extended Sobel operator Parameters: * src – The source image * dst – The destination image; will have the same size and the same number of channels as src * ddepth – The destination image depth * xorder – Order of the derivative x * yorder – Order of the derivative y * ksize – Size of the extended Sobel kernel, must be 1, 3, 5 or 7 * scale – The optional scale factor for the computed derivative values (by default, no scaling is applied, see getDerivKernels() ) * delta – The optional delta value, added to the results prior to storing them in dst * borderType – The pixel extrapolation method, see borderInterpolate() */ void EdgeDetectorSobel::process() { CvMatData srcPtr = m_inputPin->get(); CvMatData dstPtr = CvMatData::create( srcPtr.properties() ); // open for reading const cv::Mat& src = srcPtr; // open image for writing cv::Mat& dst = dstPtr; assert( m_xOrder == 1 || m_xOrder == 0 ); assert( m_yOrder == 1 || m_yOrder == 0 ); assert( m_kernelSize == 1 || m_kernelSize == 3 || m_kernelSize == 5 || m_kernelSize == 7 ); // do sobel operation cv::Sobel( src, dst, dst.depth() , m_xOrder, m_yOrder, m_kernelSize, m_scale, m_delta, m_borderType.getSelectedValue() ); // publish output m_outputPin->put( dstPtr ); }
bool EdgeDetectorCanny::process() { // get the source CvMatData in = m_inputPin->get(); // get a new target image with the same properties as the src CvMatData out = CvMatData::create( in.properties() ); // open for reading const cv::Mat& src = in; // open image for writing cv::Mat& edges = out; // do a canny edge detection operator of the image // the input should be grayscaled cv::Canny( src, edges, m_thresholdLow, m_thresholdHigh, m_apertureSize, m_l2Gradient ); // publish the new image m_outputPin->put( out ); return true; }