<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                1.凸缺陷 找到凸缺陷 ~~~ hull=cv2.convexHull(cnt,returnPoints=False) defects=cv2.convexityDefects(cnt,hull) ~~~ 它會返回一個數組,其中每一行包含的值是【起點,終點,最遠的點,到最遠點的近似距離】 ~~~ import cv2 import numpy as np img=cv2.imread('0023.jpg') img_gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) ret,thresh=cv2.threshold(img_gray,127,255,0) contours=cv2.findContours(thresh,2,1) hierarchy = cv2.findContours(thresh,2,1) cnt=contours[0] hull=cv2.convexHull(cnt,returnPoints=False) defects=cv2.convexityDefects(cnt,hull) for i in range(defects.shape[0]): s,e,f,d=defects[i,0] start=tuple(cnt[s][0]) end=tuple(cnt[e][0]) far=tuple(cnt[f][0]) cv2.line(img,start,end,[0,255,0],2) cv2.circle(img,far,5,[0,0,255],-1) while(1): cv2.imshow('img',img) if cv2.waitKey(1)==ord('q'): break cv2.destroyAllWindows() ~~~ 2.Point Polygon Test 求解圖像中的一個點到一個對象輪廓的最短距離。如果點再輪廓的外部,返回值為負,如果在輪廓上,返回值為0,如果在輪廓內部,返回值為正。 下面我們以點(50,50)為例: ~~~ dist = cv2.pointPolygonTest(cnt,(50,50),True) ~~~ 此函數的第三個參數是measureDist。如果設置為True,就會計算最短距離。如果是False,只會判斷這個點與輪廓之間的位置關系(返回值為+1,-1,0) 3.形狀匹配 函數cv2.matchShape()可以幫我們比較兩個形狀或者輪廓的相似度,如果返回值越小,匹配越好,它是根據Hu矩來計算的。 ~~~ import cv2 import numpy as np img1 = cv2.imread('roi.jpg') img2 = cv2.imread('0022.jpg') ret,thresh=cv2.threshold(img1,127,255,0) ret,thresh2=cv2.threshold(img2,127,255,0) contours,hierarchy =cv2.findContours(thresh,2,1) cnt1=contours[0] contours,hierarchy =cv2.findContours(thresh2,2,1) cnt2=contours[0] ret=cv2.matchShapes(cnt1,cnt2,1,0,0) print(ret) ~~~ 在python3.5和cv2中contours,hierarch會報錯。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看