代码拉取完成,页面将自动刷新
#include "houghdialog.h"
#include "ui_houghdialog.h"
HoughDialog::HoughDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::HoughDialog)
{
ui->setupUi(this);
}
HoughDialog::~HoughDialog()
{
delete ui;
}
void HoughDialog::on_pushButton_clicked()
{
flush();
}
void HoughDialog::receiveImage(Mat in){
src=in.clone();
flush();
}
void HoughDialog::flush(){
Mat gray_src;
dst=src.clone();
cvtColor(src,gray_src,CV_BGR2GRAY);//转化为灰度图
int lowThreshold = ui->CannyLE->text().toInt();
int houghThreshold = ui->HoughLE->text().toInt();
int minLength = ui->lengthLE->text().toInt();
int maxDistanse = ui->disLE->text().toInt();
Canny(gray_src, gray_src, lowThreshold, lowThreshold*3, 3);//cannny区域分割
vector<Vec4f> lines;
HoughLinesP(gray_src,lines,1,CV_PI/180,houghThreshold,minLength,maxDistanse);//霍夫变换
for (size_t i = 0; i < lines.size(); i++)//将检测到的直线进行绘制
{
Vec4f point1 = lines[i];
line(dst, Point(point1[0], point1[1]), Point(point1[2], point1[3]), Scalar(255, 255, 0), 2, LINE_AA);
}
Mat dstShow=dst.clone();
cvtColor(dstShow,dstShow,CV_BGR2RGB);
QImage img = QImage((const unsigned char*)(dstShow.data),dstShow.cols,dstShow.rows,dstShow.step,QImage::Format_RGB888);
ui->graphicsView->resize(img.width(), img.height());
QGraphicsScene *scene = new QGraphicsScene;
//scene->setSceneRect(0,0,img.width(),img.height());
scene->addPixmap(QPixmap::fromImage(img));
ui->graphicsView->setScene(scene);
ui->graphicsView->adjustSize();
ui->graphicsView->show();
}
void HoughDialog::on_buttonBox_accepted()
{
emit sendImage(dst);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。