Zedboard A diagnosis opencv image processing (2)

Through the previous efforts, n contours have been obtained, and now the final contour is determined, and then feature extraction is performed.

In-depth analysis of the lower contour and the method of processing the contour:

Before I actually tried to extract the foreground image with cv::grabCut funcTIon, but the manual operation required by this method is still a bit more, at least I can't use it here. So I gave up again.
Let's take a look at the cvApproxPoly() function.

Then there is the method of curve fitting:

In short, try it, who will let me drink!

First, I used the morphological processing method to perform the closing operation, first expand, then etch, then close, and perform the maximum contour search on the processed binary image to remove other contours. If the lighting is good, the effect is not bad:

Zedboard A diagnosis opencv image processing (2)


Zedboard A diagnosis opencv image processing (2)


Zedboard A diagnosis opencv image processing (2)

But it seems that it is not very stable, and the effect of changing a nail is not so good. Also, even if I can handle the process, there are two fingers on the border that are very troublesome and need to be removed. Of course, I have to show the worst effects:

Zedboard A diagnosis opencv image processing (2)

Mat Widget::FindmaxCounters(Mat image)
{
Vector contours;
Vector maxContour;
Vector ::iterator itc;
Mat dst = Mat::zeros(image.rows, image.cols, CV_8U);
findContours( image, contours, CV_RETR_EXTERNAL , CV_CHAIN_APPROX_NONE );
/ / Find the biggest outline
Size_t maxSize=0;
Itc = contours.begin();
While(itc!=contours.end())
{
If(itc->size()>maxSize)
{
maxSize=itc->size();
maxContour=*itc;
}
++itc;
}
Itc = contours.begin();
While(itc!= contours.end()) { //Eliminate smaller contours
If(itc->size() < maxSize)
Itc=contours.erase(itc);
Else
++itc;
}
QString str1;QFont ft;
Int ilz1 = (int)contours.size();
str1.setNum(ilz1);ft.setPointSize(20);
Ui->label_9->setAlignment(Qt::AlignCenter);//Setting word centered display
Ui->label_9->setFont(ft);
/ / put on the QLabel display
Ui->label_9->setText(str1);
Ui->label_9->show();
drawContours(dst, contours, 0, Scalar(255), CV_FILLED);
//CvRect s;
//CvPoint pt;
//vector contours;
//Mat dst = Mat::zeros(grayimage.rows, grayimage.cols, CV_8U);
//findContours( grayimage, contours, CV_RETR_EXTERNAL , CV_CHAIN_APPROX_NONE );
//s=cv::boundingRect(contours);
//pt = cvPoint(s.x+s.width/2,s.y+s.height/2);//------- You can use another way to get an interior point of the connected domain as the starting point Seed point
//cv::floodFill(dst, pt ,cvScalarAll(255));
Return dst;
}

Outdoor Optical Fiber Cable

Outdoor Fiber Cable,Outdoor Fiber,2 Core Outdoor Fiber Optic Cable,2 Core Outdoor Cable

Zhejiang Wanma Tianyi Communication Wire & Cable Co., Ltd. , https://www.zjwmty.com

This entry was posted in on