如果方块在图像中连接了区域,我该如何检测它们.
我测试了OpenCV C++/Obj-C中提到的方法 :高级方形检测
它运作不佳.
有什么好主意吗?
import cv2
import numpy as np
def angle_cos(p0, p1, p2):
d1, d2 = (p0-p1).astype('float'), (p2-p1).astype('float')
return abs( np.dot(d1, d2) / np.sqrt( np.dot(d1, d1)*np.dot(d2, d2) ) )
def find_squares(img):
squares = []
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# cv2.imshow("gray", gray)
gaussian = cv2.GaussianBlur(gray, (5, 5), 0)
temp,bin = cv2.threshold(gaussian, 80, 255, cv2.THRESH_BINARY)
# cv2.imshow("bin", bin)
contours, hierarchy = cv2.findContours(bin, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours( gray, contours, -1, (0, 255, 0), 3 )
#cv2.imshow('contours', gray)
for cnt …
Run Code Online (Sandbox Code Playgroud) python opencv image-processing object-detection computer-vision
在WinRT中没有FileInfo
类,只有一个StorageFile
类.
如何使用StorageFile
该类获取文件的大小?