Created
February 22, 2018 06:11
-
-
Save esmarr58/d0e3d14c225474789a28205e8422d1a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MainWindow::ftimer(){ | |
//Paso # 1 - Procesar imagen anterior para filtro de ventana | |
if(!ImagenHSV.empty()){ | |
int canal0Min = ui->barraCanal0Min->value(); | |
int canal0Max = ui->barraCanal0Max->value(); | |
int canal1Min = ui->barraCanal1Min->value(); | |
int canal1Max = ui->barraCanal1Max->value(); | |
int canal2Min = ui->barraCanal2Min->value(); | |
int canal2Max = ui->barraCanal2Max->value(); | |
inRange(IMAGENchica,Scalar(canal0Min,canal1Min,canal2Min),Scalar(canal0Max,canal1Max,canal2Max),ImagenFiltrada); | |
vector<vector<Point> > contornos; | |
vector<Vec4i> jerarquia; | |
Mat copiaImagenFiltrada; | |
copiaImagenFiltrada = ImagenFiltrada; | |
findContours(copiaImagenFiltrada, contornos, jerarquia, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) ); | |
Mat drawing = Mat::zeros( copiaImagenFiltrada.size(), CV_8UC3 ); | |
int area = 0; | |
for( int i = 0; i< (int)contornos.size(); i++ ) | |
{ | |
Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) ); | |
drawContours( drawing, contornos, i, color, 2, 8, jerarquia, 0, Point() ); | |
area = contourArea(contornos[i]); | |
qDebug() << "Area " << i << " : " << area; | |
} | |
QImage qImage = Mat2QImage(drawing); | |
QPixmap pixmap = QPixmap::fromImage(qImage); | |
ui->labelContornos->clear(); | |
ui->labelContornos->setPixmap(pixmap); | |
qImage = Mat2QImage(ImagenFiltrada); | |
pixmap = QPixmap::fromImage(qImage); | |
ui->labelInrange->clear(); | |
ui->labelInrange->setPixmap(pixmap); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment