Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.