Using the opencv contour detection and map to identify the rectangle, findContours parameters set as CV. RETR_EXTERNAL, painted out some of the content within the profile, but still don't know what circumstance, you bosses, any ideas or methods to solve the below is my code, is something wrong with the image processing in front of me? Or what do you test the rectangular ideas?
# image processing
Def edge_demo (image) :
Blurred=CV. GaussianBlur (image, (3, 3), 0) # gaussian blur
Gray=CV. CvtColor (image, CV. COLOR_BGR2GRAY) # gray processing
# xgrad=CV. Sobel (gray, CV. CV_8U, 1, 0)
# ygrad=CV. Sobel (gray, CV. CV_8U, 0, 1)
Edge_output=CV. Canny (gray, 50, 150)
DST=CV. Bitwise_and (image, image, mask=edge_output)
Return edge_output
# draw a rectangle
Def contours_demo (image) :
Binary=edge_demo (image)
Contours, _=CV. FindContours (binary, CV. RETR_EXTERNAL, CV. CHAIN_APPROX_SIMPLE)
For c contours in [1] :
CV. DrawContours (image, [c], 0, (0,0,255), 2)
CV. Imshow (" detect comtour ", image)
CV. Imwrite (r "C: \ Users \ SongJian \ Desktop \ picpro \ canny2332 JPG", image)