US 12,307,623 B1
Method and device for precisely obtaining fan-shaped image frame of paper cup
Ming Huang, Guangdong (CN)
Assigned to Shenzhen Saiwai Technology Co., Ltd., Shenzhen (CN)
Filed by Shenzhen Saiwai Technology Co., Ltd., Guangdong (CN)
Filed on Sep. 25, 2024, as Appl. No. 18/896,726.
Claims priority of application No. 202410836783.0 (CN), filed on Jun. 26, 2024.
Int. Cl. G06T 7/00 (2017.01); G06T 3/067 (2024.01); G06T 3/40 (2006.01); G06T 7/11 (2017.01)
CPC G06T 3/067 (2024.01) [G06T 3/40 (2013.01); G06T 7/11 (2017.01); G06T 2207/20036 (2013.01)] 9 Claims
OG exemplary drawing
 
1. A method for precisely obtaining a fan-shaped image frame of a paper cup, comprising the following steps:
S10: importing an image to be processed into a pre-trained fan-shaped image detection model, detecting the imported image to be processed through the pre-trained fan-shaped image detection model, and outputting a rectangular detection box, which is denoted as fan_bbox;
S20: performing fan-shaped image segmentation of the imported image to be processed through a pre-trained fan-shaped image segmentation model, and outputting a binary mask of a fan-shaped image, which is denoted as fan_mask;
S30: binarizing the imported image to be processed to obtain a binary image denoted as bin_image, and segmenting the binary image bin_image according to the binary mask fan_mask to obtain a binary fan-shaped image denoted as fan_seg;
S40: determining a number of times that a side line of the rectangular detection box fan_bbox passes through a frame communication area of the binary fan-shaped image fan_seg through a preset hit_num algorithm, and adjusting a side line position of the rectangular detection box fan_bbox according to the number of times, to obtain a minimum bounding rectangle of the binary fan-shaped image fan_seg, which is denoted as min_bbox;
S50: obtaining a model list including a template image of each paper cup model, corresponding precise fan-shaped image specification data and a precise binary mask, wherein the template image is denoted as tmpl_image, and the precise binary mask is denoted as tmpl_mask;
S60: obtaining a rough contour of the fan-shaped image denoted as fan_contour, according to the binary mask fan_mask and the binary image bin_image;
S70: determining a target paper cup model corresponding to the rough contour fan_contour of the fan-shaped image through a preset algorithm, which is denoted as cup_type, wherein determination conditions of the preset algorithm include: when a right side line of the rough contour fan_contour of the fan-shaped image and a right side line of the target paper cup model cup_type are most approximate to a same straight line;
S80: importing a template image tmpl_image of the target paper cup model cup_type, the imported_image to be processed, and the corresponding minimum bounding rectangle min_bbox, and cropping the imported image to be processed as the minimum bounding rectangle min_bbox to obtain a processing area image roi_image; and
S90: scaling the processing area image roi_image to a same size as the template image tmpl_image, and performing a bitwise AND operation between the precise binary mask tmpl_mask and the processing area image roi_image to obtain the fan-shaped image precisely segmented from the imported image to be processed and the fan-shaped image frame corresponding to the fan-shaped image precisely segmented from the imported image to be processed.