matchShapes for Contour Defects

asked 2020-06-02 14:45:35 -0600

Visionmop gravatar image

updated 2020-06-03 04:00:14 -0600

Hello everyone, I have little experience with OpenCV and hoped that someone here can help me here. The contour data in the following code represent the limit of a plastic part. By comparing the contour, defects of the part should be found. Therefore I read in data and perform the comparison with matchShapes(). Unfortunately, I can only post-process the data, since they do not come from OpenCV.

As the result images show, this works relatively well for some errors, unfortunately there are also cases where errors have a low score. I could imagine that this is due to the following reasons:

  1. the contours are shifted translationally and do not always start at the same point, maybe this has to be compensated
  2. Judging by moments is not the right tool
  3. The contours are not closed

I would be grateful for your comments or suggestions for an alternative approach.

Good Part with Low Score:

image description

Good Part with Low Score:

image description

Bad Part with High Score

image description

Bad Part with Low Score image description

Edit: I have found an example of a good part with a score as high as the bad one - maybe this will help to identify the problem:

    xTmp = { 1503.0, 1501.0, 1501.0, 1497.0, 1487.0, 1477.0, 1467.0, 1458.0, 1451.0, 1445.0, 1441.0, 1437.0, 1435.0, 1433.0, 1432.0, 1431.0, 1432.0, 1433.0, 1433.0, 1432.0, 1429.0, 1424.0, 1416.0, 1408.0, 1401.0, 1396.0, 1391.0, 1387.0, 1384.0, 1382.0, 1381.0, 1380.0, 1380.0, 1381.0, 1381.0, 1380.0, 1380.0, 1379.0, 1377.0, 1374.0, 1371.0, 1366.0, 1362.0, 1357.0, 1354.0, 1352.0, 1350.0, 1350.0, 1350.0, 1351.0, 1352.0, 1354.0, 1355.0, 1355.0, 1355.0, 1353.0, 1352.0, 1349.0, 1346.0, 1342.0, 1339.0, 1337.0, 1335.0, 1335.0, 1335.0, 1336.0, 1338.0, 1341.0, 1343.0, 1344.0, 1344.0, 1344.0, 1343.0, 1342.0, 1340.0, 1337.0, 1334.0, 1332.0, 1331.0, 1331.0, 1331.0, 1332.0, 1335.0, 1338.0, 1340.0, 1342.0, 1344.0, 1345.0, 1345.0, 1344.0, 1343.0, 1341.0, 1339.0, 1337.0, 1336.0, 1335.0, 1335.0, 1336.0, 1338.0, 1341.0, 1344.0, 1346.0, 1349.0, 1350.0, 1351.0, 1351.0, 1350.0, 1349.0, 1347.0, 1344.0, 1343.0, 1342.0, 1342.0, 1343.0, 1344.0, 1346.0, 1349.0, 1351.0, 1353.0, 1354.0, 1354.0, 1354.0, 1353.0, 1351.0, 1349.0, 1347.0, 1345.0, 1343.0, 1343.0, 1344.0, 1345.0, 1347.0, 1351.0, 1354.0, 1357.0, 1359.0, 1360.0, 1361.0, 1361.0, 1361.0, 1360.0, 1358.0, 1357.0, 1355.0, 1355.0, 1356.0, 1357.0, 1359.0, 1363.0, 1367.0, 1371.0, 1374.0, 1376 ...
(more)
edit retag flag offensive close merge delete