📜  omr sheet python stackoverflow - Python代码示例

📅  最后修改于: 2022-03-11 14:45:07.335000             🧑  作者: Mango

代码示例1
import cv2
import numpy as np

img=cv2.imread('test.png') #read image
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #turn image to gray
blur = cv2.GaussianBlur(gray,(3,3),0) #add blur
edges = cv2.Canny(blur,50,100) #find edges

contours, hierarchy = cv2.findContours(edges,cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) #find contours
cv2.drawContours(img,contours,-1,(0,255,0),2) #draw contours
cv2.imshow('Contours in Green',img) #show contours in green

#Now you need to sort them out.