mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge remote-tracking branch 'origin/3.4' into merge-3.4
This commit is contained in:
+17
-21
@@ -218,6 +218,11 @@ int main( int argc, char** argv )
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline static bool isGoodBox(const RotatedRect& box) {
|
||||
//size.height >= size.width awalys,only if the pts are on a line or at the same point,size.width=0
|
||||
return (box.size.height <= box.size.width * 30) && (box.size.width > 0);
|
||||
}
|
||||
|
||||
// Define trackbar callback function. This function finds contours,
|
||||
// draws them, and approximates by ellipses.
|
||||
void processImage(int /*h*/, void*)
|
||||
@@ -276,39 +281,30 @@ void processImage(int /*h*/, void*)
|
||||
{
|
||||
vector<Point2f> pts = points[i];
|
||||
|
||||
if (pts.size()<=5) {
|
||||
//At least 5 points can fit an ellipse
|
||||
if (pts.size()<5) {
|
||||
continue;
|
||||
}
|
||||
if (fitEllipseQ) {
|
||||
box = fitEllipse(pts);
|
||||
if( MAX(box.size.width, box.size.height) > MIN(box.size.width, box.size.height)*30 ||
|
||||
MAX(box.size.width, box.size.height) <= 0 ||
|
||||
MIN(box.size.width, box.size.height) <= 0){continue;};
|
||||
if (isGoodBox(box)) {
|
||||
paper.drawEllipseWithBox(box, fitEllipseColor, 3);
|
||||
}
|
||||
}
|
||||
if (fitEllipseAMSQ) {
|
||||
boxAMS = fitEllipseAMS(pts);
|
||||
if( MAX(boxAMS.size.width, boxAMS.size.height) > MIN(boxAMS.size.width, boxAMS.size.height)*30 ||
|
||||
MAX(box.size.width, box.size.height) <= 0 ||
|
||||
MIN(box.size.width, box.size.height) <= 0){continue;};
|
||||
if (isGoodBox(boxAMS)) {
|
||||
paper.drawEllipseWithBox(boxAMS, fitEllipseAMSColor, 2);
|
||||
}
|
||||
}
|
||||
if (fitEllipseDirectQ) {
|
||||
boxDirect = fitEllipseDirect(pts);
|
||||
if( MAX(boxDirect.size.width, boxDirect.size.height) > MIN(boxDirect.size.width, boxDirect.size.height)*30 ||
|
||||
MAX(box.size.width, box.size.height) <= 0 ||
|
||||
MIN(box.size.width, box.size.height) <= 0 ){continue;};
|
||||
if (isGoodBox(boxDirect)){
|
||||
paper.drawEllipseWithBox(boxDirect, fitEllipseDirectColor, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (fitEllipseQ) {
|
||||
paper.drawEllipseWithBox(box, fitEllipseColor, 3);
|
||||
}
|
||||
if (fitEllipseAMSQ) {
|
||||
paper.drawEllipseWithBox(boxAMS, fitEllipseAMSColor, 2);
|
||||
}
|
||||
if (fitEllipseDirectQ) {
|
||||
paper.drawEllipseWithBox(boxDirect, fitEllipseDirectColor, 1);
|
||||
}
|
||||
|
||||
paper.drawPoints(pts, cv::Scalar(255,255,255));
|
||||
paper.drawPoints(pts, fitEllipseTrueColor);
|
||||
}
|
||||
|
||||
imshow("result", paper.img);
|
||||
|
||||
@@ -92,7 +92,7 @@ void Sharpen(const Mat& myImage,Mat& Result)
|
||||
|
||||
for(int i= nChannels;i < nChannels*(myImage.cols-1); ++i)
|
||||
{
|
||||
*output++ = saturate_cast<uchar>(5*current[i]
|
||||
output[i] = saturate_cast<uchar>(5*current[i]
|
||||
-current[i-nChannels] - current[i+nChannels] - previous[i] - next[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user