Bent pins in connector

I started working on checking data connector for servers where we facing with bent pins problems (just edge pins can be bent) and sometimes with foam contamination (part of foam cover 1-n pins).

Part of first problem is almost solved. Using contours i am trying find in ROI if there is any contour which mean that connector is damaged (i am not saing that this is good aproach but seems that working). Second problem is to check if the pin itself is bent. So my idea was to find circles from contour (which didn’t work - not find everything) and then try to calculate distance between circles (variable where will be defined range for OK pins and the rest is NG - calculation should be for each pair). This approchac can also help to find it there is any foam contamination - i can compare number of circle contour with number of pins (36 pins).

If there will be anybody who have any idea, i will just be happy. thank you

there is reference img

import argparse
import cv2
import numpy as np
import imutils

ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", type=str, required=True,
	help="path to input image")
args = vars(ap.parse_args())

image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3,3), 0)

cv2.imshow("Original", image)
cv2.imshow("Blurred", blurred)

blurImg = cv2.Canny(blurred, 130, 230)

croppedtop = blurImg[53:70 , 92:513]
croppedbot = blurImg[387:410 , 96:507]

rgbtop = cv2.cvtColor(croppedtop, cv2.COLOR_GRAY2BGR)
rgbbot = cv2.cvtColor(croppedbot, cv2.COLOR_GRAY2BGR)

hsvtop = cv2.cvtColor(rgbtop  , cv2.COLOR_BGR2HSV)
hsvbot = cv2.cvtColor(rgbbot  , cv2.COLOR_BGR2HSV)

lower_white = np.array([0,0,180])
higher_white = np.array([255,255,255])
Result_top = cv2.inRange(hsvtop, lower_white, higher_white)
Result_bot = cv2.inRange(hsvbot, lower_white, higher_white)

cv2.imshow("Tight Edge Map", blurImg)
cv2.imshow("Result bot",Result_bot )
cv2.imshow("Result top",Result_top )

if cv2.countNonZero(Result_bot) > 0 or cv2.countNonZero(Result_top) > 0:
    print('Damaged slot!')
    #cnts = cv2.findContours(Result_bot.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    #cnts = imutils.grab_contours(cnts)
    #print("Total damages is: {}".format(len(cnts)))

still continue to figure out how to detect bent pins and seems that i have small progress. For this moment i am able to find all pins + 4 fake detection which i need remove. For removing any fake “pins” i will create map of connector where every couple of pin will have own ROI and then i hope that result will be 100% right. Next step will be measure distance between two points and decide if connector is damaged or not.

small progress about checking if pins are bend or not. As you can see i create array for each pin when i am try to calculate distance between two contacts. Next step will be to rewrite code for IP camera, currently i am testing on stative img


1 Like