机器视觉电阻姿态检测
import cv2 import numpy as np import sys from PyQt5 import QtWidgets, QtCore, QtGui from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import * imgName='11111' imagepath='1111111' def canny_demo(image): h, w = image.shape[:2] mh = 185 mw = 100 t = 80 canny_output = cv2.Canny(image, t, t * 2) for i in range(h): for j in range(w): if (canny_output[i][j] == 255): if i > (h // 2 mh // 4) or i < (h // 2 - mh // 4) or j < (w // 2 - mw // 4) or j > (w // 2 mw // 4): continue else: image[i][j][0] = 0 image[i][j][1] = 255 image[i][j][2] = 0 return canny_output def resistanceCheck(imagepath): #imagepath=imgName #print(imagepath) src = cv2.imread(imagepath) #print(src) h, w &