擅长:python、mysql、java
<p>只要调整<a href="https://docs.opencv.org/3.1.0/dd/d49/tutorial_py_contour_features.html" rel="nofollow noreferrer">cv2 tutorial</a>,就可以找到最大的轮廓,然后得到它的边界矩形。在</p>
<pre><code>img = cv2.imread('/home/kvnp/Desktop/v02J6.jpg',0) #read in the image with correct dtype
_,thresh = cv2.threshold(img,200,255,0) # threshold the image
_,contours,_ = cv2.findContours(thresh, 1, 2) # find the contours
cnt = sorted(contours, key = lambda c: -len(c))[0] # order from largest to smallest and select the largest
x,y,w,h = cv2.boundingRect(cnt) # make bounding rectangle around the largest contour
corners = np.array([[x,y],[x+w,y],[x+w,y+h],[x,y+h]]) # make array of corners sorted clockwise
</code></pre>
<p>我看到的这个图像</p>
^{pr2}$