void DistanceTransform::process()
{
    //get the input image
    CvMatData img = m_inputPin->get();

    // open input images for reading
    const cv::Mat& src = img;

    if(img.channels() != 1)
        qDebug() << "Wrong number of channels";
    if(img.depth() != CV_8U && img.depth() != CV_8S)
        qDebug() << "Wrong depth in the image";

    //get a destination image with the distance values.
    CvMatData out = CvMatData::create( img.width(), img.height(), CV_32FC1 );
    // open output image for writing
    cv::Mat& dst = out;

    //DistanceTransform both images
    try{
        cv::distanceTransform(src, dst, m_distanceType.getSelectedValue(), m_maskSize.getSelectedValue());
    }
    catch(std::exception &e){
        //Don't know why but this try/catch block prevents exception troubles.
        qDebug() << "exception: " << e.what();
        throw;
    }

    // publish the new image
    m_outputPin->put( out );

}
Exemplo n.º 2
0
bool Gray2RGB::process()
{
	assert(m_inputPin != 0);
    assert(m_outputPin != 0);

    CvMatData src = m_inputPin->get();

    // allocate a target buffer
    CvMatData target;
    target.create( src.width(), src.height(), src.type() );

    // do a flip of the image
    const cv::Mat in = src;
    cv::Mat out = target;
    cv::flip( in, out, 1);

    // publish the new image
    m_outputPin->put( out );


//   CvMatData in = m_inputPin->get();
    //const cv::Mat& inputImage = in;
    //m_outputPin->put( inputImage );
    return true;

}
Exemplo n.º 3
0
bool ImageThreshold::process()
{
    CvMatData in = m_inputPin->get();
    CvMatData out = CvMatData::create( in.width(), in.height(), in.type() );

    const cv::Mat& src = in;
    cv::Mat& dst = out;

    // perform threshold operation on the image
    cv::threshold( src, dst, m_threshold, m_maxValue, m_method.getSelectedValue() );

    // publish the new image
    m_outputPin->put( out );

    return true;
}
void ImageCornerHarris::process()
{
    assert(m_inputPin != 0);
    assert(m_outputPin != 0);

    // get the src image
    CvMatData in = m_inputPin->get();

    // make a target image
    // cv::CornerHarris expects a 32F dst image
    CvMatDataProperties props( in.width(), in.height(), CV_32FC1 );
    CvMatData out = CvMatData::create( props );

    const cv::Mat& src = in;
    cv::Mat& dst = out;

    // do a canny edge detection operator of the image
    cv::cornerHarris( src, dst, m_blockSize, m_kernelSize,
                      m_k, m_borderType.getSelectedValue() );

    // publish the new image
    m_outputPin->put( out );
}