A card intelligent sorting method, device, equipment and storage medium
The intelligent card sorting method using instance segmentation networks and multi-layer feature extraction solves the problems of insufficient card recognition accuracy and robustness under complex working conditions, achieving efficient card sorting and improving the overall efficiency of the sorting system.
Patent Information
- Application Number
- CN202611641705.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-22
- Publication Date
- 2026-11-20
AI Technical Summary
Existing card sorting methods lack accuracy and robustness under complex working conditions, making it difficult to meet the processing needs of high-speed production lines. Furthermore, the sequential execution of traditional visual recognition and mechanical sorting actions leads to low efficiency.
An instance segmentation network is used to extract pixel-level segments of card regions. Through multi-layer feature extraction and multi-channel similarity retrieval, combined with visual fine matching and special label filtering, multi-layer feature data association and comprehensive similarity determination of cards are realized, and finally, the robotic arm is controlled to perform sorting.
It improved the accuracy and robustness of card recognition, enhanced the overall operational efficiency of the sorting system, and reduced the cost of manual verification.
Smart Images

Figure CN123142201A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of image recognition and industrial intelligent sorting technology, and in particular to a card intelligent sorting method, apparatus, equipment and storage medium. Background Technology
[0002] With the continuous expansion of card application scenarios, the issuance and sorting demand of bank cards, membership cards, and various certificates are constantly increasing, and the demand for automated card sorting in industrial scenarios is constantly rising. However, in actual sorting environments, cards often have issues such as glare, surface wear, and localized dirt obscuring their surface. Furthermore, card types and designs are becoming increasingly diverse, and similar card types are constantly increasing, which brings considerable challenges to accurate card identification and efficient sorting.
[0003] Current card sorting methods typically employ traditional machine vision technology for card recognition. These methods generally rely on manually designed image feature extraction rules to extract features such as card characters and layout outlines, which are then input into a classifier for matching and recognition to complete card classification and sorting. However, under complex operating conditions, the robustness of manual features is poor, easily leading to feature extraction bias and recognition errors. Furthermore, single-dimensional feature matching struggles to distinguish between card types with highly similar layouts, and differentiating features such as anti-counterfeiting labels and background materials cannot be effectively utilized, resulting in insufficient accuracy and discriminative power in card recognition. In addition, in traditional solutions, visual recognition and mechanical sorting actions are executed sequentially; the time-consuming visual computation restricts overall sorting efficiency and makes it difficult to adapt to the processing demands of high-speed production lines.
[0004] Therefore, how to improve the accuracy and robustness of card recognition under complex working conditions, while improving the overall operating efficiency of the sorting system, is an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the card intelligent sorting method, apparatus, device, and storage medium provided in this application can improve the accuracy and robustness of card recognition under complex working conditions, while also improving the overall operating efficiency of the sorting system. The card intelligent sorting method, apparatus, device, and storage medium provided in this application are implemented as follows: This application provides a smart card sorting method, including: The original image of the card to be sorted is obtained, the original image is scaled and brightness equalized, and the processed image is input into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. The binary mask is then processed morphologically and the contour is extracted to obtain the target card contour. Based on the target outline of the card, the edge lines of the four sides of the card are determined. The four corner points of the card are determined according to the intersection points of adjacent edge lines. The card cropping area is determined according to the four corner points of the card. The card cropping area is cropped from the original image to obtain the front view image of the card. Based on the card's front view image, global semantic features, local visual features, textual semantic features, and special visual features of the card are extracted, and the global semantic features, local visual features, textual semantic features, and special visual features are associated with the card identifier to obtain multi-layer feature data of the card; The multi-layer feature data of the card is stored in a vector database, and multi-channel similarity retrieval is performed based on the multi-layer feature data of the card to be identified. The multi-channel retrieval results are then aggregated to obtain candidate card data. The candidate card data is subjected to visual fine matching processing and special identifier filtering processing. The candidate card data is then filtered based on the visual matching results and special identifier matching results to obtain the filtered candidate card data. The selected candidate card data are subjected to a comprehensive similarity determination to obtain card recognition results. Based on the card recognition results, the robotic arm is controlled to sort the cards to be sorted to the corresponding positions.
[0006] In some embodiments, the process of acquiring the original image of the card to be sorted, performing size scaling and brightness equalization on the original image, and inputting the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain a binary mask corresponding to the target card, and performing morphological processing and contour extraction on the binary mask to obtain the target card contour, includes: The original image is scaled to a preset input size, and the scaled image is then subjected to brightness equalization to obtain the image to be segmented. The image to be segmented is input into the pre-trained instance segmentation network to perform pixel-level segmentation of the target card in the image to be segmented, thereby obtaining the binary mask corresponding to the target card. The binary mask is subjected to morphological closing operations to fill the holes and cracks inside the binary mask and smooth the mask edges, resulting in a processed binary mask. The processed binary mask is subjected to contour extraction to obtain multiple connected region contours. The contours are then filtered according to the area of each connected region contour, and the connected region contour with the largest area is taken as the target contour of the card. Isolated noise regions are removed according to a preset area threshold.
[0007] In some embodiments, determining the edge lines of the four sides of the card based on the target outline of the card, determining the four corner points of the card based on the intersection points of adjacent edge lines, determining the card cropping area based on the four corner points of the card, and cropping the card cropping area from the original image to obtain a front view image of the card includes: The minimum bounding rectangle algorithm is used to calculate the target outline of the card to obtain the initial reference orientation and position of the four sides of the card. All pixels on the outline are assigned according to their distance from the four thick sides to obtain four outline point sets corresponding to the four sides of the card. For each set of contour points, calculate the projection position of each point in the set onto the straight line of the corresponding edge, retain only the mid-section contour points whose projection positions are within a preset range of the midpoint of the corresponding edge, and discard the contour points close to both ends of the edge to obtain the filtered mid-section contour point set of each edge. For each set of mid-section contour points, a random sampling consensus algorithm or the least squares method is used to fit a straight line to obtain the equations of the four stable edge lines corresponding to the four sides of the card. Based on the equations of the four stable edge lines, calculate the coordinates of the intersection points of each pair of adjacent edge lines to obtain four intersection points, which are then used as the four corner points of the card. The cropping area of the card in the original image is determined based on the coordinates of the four corner points. The image corresponding to the cropping area is then cropped from the original image to obtain the front view image of the card.
[0008] In some embodiments, the step of extracting global semantic features, local visual features, textual semantic features, and special visual features of the card based on the card's front view image, and associating the global semantic features, local visual features, textual semantic features, and special visual features with the card identifier to obtain multi-layer feature data of the card, includes: The front view image of the card is input into the pre-trained convolutional neural network backbone to extract the global semantic feature vector; The card's front view image is subjected to adaptive cropping of the core region. The cropped local image is then input into a visual feature extraction network to extract local visual feature vectors. The card's front view image is subjected to full-face text recognition and semantic encoding to extract text semantic feature vectors; The card's front view image is input into a pre-trained multi-task visual recognition model to extract special visual feature vectors containing anti-counterfeiting marks, background textures, and surface texture information. The global semantic feature vector, the local visual feature vector, the text semantic feature vector, and the special visual feature vector are bound and associated with the unique identifier of the corresponding card to obtain multi-layer feature data of the card.
[0009] In some embodiments, storing the multi-layer feature data of the card into a vector database, performing multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified, and aggregating the multi-channel retrieval results to obtain candidate card data includes: The global semantic feature vector, local visual feature vector, and text semantic feature vector are each constructed into three independent retrieval channels, which are then stored in three independent approximate nearest neighbor index structures in the vector database. The feature vector in each retrieval channel is associated with the unique identifier of the corresponding card. Extract the global semantic feature vector, local visual feature vector, and textual semantic feature vector of the card to be identified, and input them into the three corresponding retrieval channels of the vector database. Use cosine similarity as the metric to perform similarity search, and each channel independently recalls a preset number of similar card candidates. All similar card candidates recalled from the three channels are merged and deduplicated according to the unique card identifier, and the similarity score of each candidate in each channel is retained to form a candidate set containing multi-dimensional scores. According to the preset weight coefficients of each channel, the multi-dimensional similarity scores of each candidate in the candidate set are weighted and calculated to obtain the fusion retrieval score of each candidate. The candidates are then sorted in descending order of the fusion retrieval scores to obtain the aggregated candidate card data.
[0010] In some embodiments, the step of performing visual fine matching processing and special identifier filtering processing on the candidate card data, and filtering the candidate card data based on the visual matching results and special identifier matching results to obtain filtered candidate card data includes: For each candidate card in the candidate card data, local feature points and feature descriptors are extracted from the front view image of the card to be identified and the corresponding candidate card image, and feature point pairing matching is performed; based on the successfully paired feature point pairs, the homography matrix is calculated and geometric consistency is checked to obtain the visual matching score corresponding to each candidate card. Extract the special visual feature vectors corresponding to each candidate card, compare them with the special visual feature vectors of the card to be identified, and combine the matching results of anti-counterfeiting mark category, background texture type and surface texture attribute to obtain the special feature matching degree of each candidate card. The candidate cards are sorted and filtered based on their visual matching scores and special feature matching degrees. Candidate cards that do not meet the preset conditions for geometric consistency or whose special feature matching degree is lower than the preset threshold are removed, resulting in the filtered candidate card data.
[0011] In some embodiments, the step of performing a comprehensive similarity determination on the filtered candidate card data to obtain a card recognition result, and controlling the robotic arm to sort the cards to be sorted to the corresponding positions based on the card recognition result, includes: For each candidate card after screening, the visual matching score, special feature matching degree and multi-channel retrieval similarity score are combined to calculate the comprehensive similarity score corresponding to each candidate card. All candidate cards are sorted in descending order according to their comprehensive similarity scores, and the candidate card ranked first is selected as the optimal matching candidate. The comprehensive similarity score of the best matching candidate is compared with a preset multi-level threshold to generate the corresponding recognition result; when the comprehensive similarity score is greater than or equal to the first preset threshold, a successful matching recognition result is generated; when the comprehensive similarity score is between the first preset threshold and the second preset threshold, a fuzzy recognition result awaiting review is generated; when the comprehensive similarity score is less than the second preset threshold, an unknown anomaly recognition result is generated. Based on the generated recognition results, the robot arm is given sorting control instructions to move the cards to be sorted to the corresponding positions. Cards that are successfully matched are moved to the corresponding category sorting slot, while cards that are ambiguous and need to be reviewed or are of unknown anomaly are moved to the manual review slot.
[0012] This application provides a smart card sorting device, comprising: The acquisition module is used to acquire the original image of the card to be sorted, perform size scaling and brightness equalization processing on the original image, and input the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. The binary mask is then subjected to morphological processing and contour extraction to obtain the target card contour. The processing module is used to determine the edge lines of the four sides of the card based on the target outline of the card, determine the four corner points of the card based on the intersection points of adjacent edge lines, determine the card cropping area based on the four corner points of the card, and crop the card cropping area from the original image to obtain a front view image of the card. The processing module is also used to extract global semantic features, local visual features, text semantic features and special visual features of the card based on the front view image of the card, and associate the global semantic features, the local visual features, the text semantic features and the special visual features with the card identifier to obtain multi-layer feature data of the card; The processing module is also used to store the multi-layer feature data of the card into a vector database respectively, and perform multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified, and aggregate the multi-channel retrieval results to obtain candidate card data. The processing module is also used to perform visual fine matching processing and special identifier filtering processing on the candidate card data, and to filter the candidate card data according to the visual matching results and special identifier matching results to obtain the filtered candidate card data. The judgment module is used to perform a comprehensive similarity judgment on the filtered candidate card data to obtain the card recognition result, and control the robotic arm to sort the cards to be sorted to the corresponding positions according to the card recognition result.
[0013] The computer device provided in this application includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements the method described in this application.
[0014] The computer-readable storage medium provided in this application embodiment stores a computer program thereon, which, when executed by a processor, implements the method described in this application embodiment.
[0015] This application provides a card intelligent sorting method, apparatus, device, and storage medium. It acquires the original image of the card to be sorted, performs scaling and brightness equalization processing, and then inputs it into an instance segmentation network to extract the card's target contour and fit edge corner points, cropping to obtain a front view image of the card. Subsequently, it extracts global semantic features, local visual features, textual semantic features, and special visual features to construct multi-layer feature data associated with card identifiers. Candidate cards are obtained through multi-channel similarity retrieval and aggregation, and secondary screening is completed through visual fine matching and special identifier filtering. Finally, a comprehensive similarity judgment is performed, the recognition result is output, and a robotic arm is controlled to complete the sorting. This improves the accuracy and robustness of card recognition under complex working conditions, while also increasing the overall operating efficiency of the sorting system, thus solving the technical problems mentioned in the background art. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 A schematic diagram illustrating the implementation process of a smart card sorting method provided in this application embodiment; Figure 2 A schematic diagram illustrating the implementation process of obtaining the target outline of a card, provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a smart card sorting device provided in an embodiment of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0019] The following description of some technologies involved in the embodiments of this application is provided to aid understanding and should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, some descriptions of well-known functions and structures are omitted in the following description.
[0020] Figure 1 This is a schematic diagram illustrating the implementation flow of a smart card sorting method provided in an embodiment of this application, including steps 101 to 106. Wherein, Figure 1 This is merely one execution order shown in the embodiments of this application and does not represent the only execution order for a smart card sorting method. Where the final result can be achieved, Figure 1 The steps shown can be performed in parallel or in reverse order.
[0021] Step 101: Obtain the original image of the card to be sorted, perform size scaling and brightness equalization on the original image, and input the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. Perform morphological processing and contour extraction on the binary mask to obtain the target card contour.
[0022] In this embodiment, the original RGB (Red, Green, Blue) images of the cards to be sorted are first acquired using an industrial area scan camera deployed above the material picking trough. The original images are then scaled to a preset input size of 640×640 pixels to fit the input requirements of the subsequent instance segmentation network. Simultaneously, adaptive histogram equalization is performed on the scaled images to reduce the interference of uneven global illumination on subsequent segmentation, resulting in the image to be segmented.
[0023] The image to be segmented is input into a pre-trained instance segmentation network. In this embodiment, the instance segmentation network adopts the Mask R-CNN (Mask Region-based Convolutional Neural Network) architecture, whose backbone network is a combination of ResNet-50 (Residual Network-50, a 50-layer residual network) and FPN (Feature Pyramid Network). After receiving the image to be segmented, the backbone network extracts multi-scale feature maps, the input region proposal network generates candidate target regions, and then processes them through classification branches, bounding box regression branches, and segmentation branches respectively, finally outputting the pixel-level binary mask corresponding to the target card.
[0024] In the binary mask, the pixel region corresponding to the target card is marked as 1, and the background pixels are marked as 0. Morphological closing operations are performed on the output binary mask. Using a 3×3 rectangular structuring element, the binary mask is first dilated and then eroded to fill the tiny holes and cracks inside the mask, while smoothing the mask edges to obtain the processed binary mask.
[0025] The Suzuki-Abe (Suzuki-Abe border-following algorithm) contour tracking algorithm is used to extract the contours of the processed binary mask to obtain the contours of all connected regions in the image. The bounding area of each connected region contour is calculated, and the connected region contour with the largest area is selected as the target contour of the card. At the same time, isolated noise regions with an area smaller than a preset area threshold are removed. In this embodiment, the preset area threshold is set to 1% of the total image area.
[0026] Step 102: Determine the edges of the four sides of the card based on the target outline of the card, determine the four corner points of the card based on the intersection of adjacent edges, and determine the card cropping area based on the four corner points of the card. Crop the card cropping area from the original image to obtain the front view image of the card.
[0027] In this embodiment, the minimum bounding rectangle rotation algorithm is used to calculate the card target outline to obtain the minimum bounding rectangle surrounding the target outline, and outputs the line equations corresponding to the orientation and position of the four thick sides of the rectangle. For all pixels on the outline, the vertical distance from each pixel to the four thick side lines is calculated, and each pixel is assigned to the nearest thick side, finally obtaining four outline point sets corresponding to the four sides of the card.
[0028] For each set of contour points, calculate the projection position of each point in the set on the straight line of the corresponding edge, determine the projection coordinates of the two endpoints of the corresponding edge, take the middle 70% of the projection interval as the preset retention range, retain only the middle contour points whose projection positions fall within this range, discard the contour points close to the two ends of the edge, eliminate the contour distortion interference in the corner area, and obtain the filtered middle contour point set of each edge.
[0029] For each set of mid-section contour points, a random sampling consensus algorithm is used to fit a straight line. After iteratively eliminating outliers, the optimal straight line parameters are obtained, and the equations of the four stable edge lines corresponding to the four sides of the card are output.
[0030] Based on the equations of the four stable edge lines, the coordinates of the intersection points of each pair of adjacent edge lines are calculated: the intersection of the top edge line and the left edge line is the top left corner, the intersection of the top edge line and the right edge line is the top right corner, the intersection of the bottom edge line and the right edge line is the bottom right corner, and the intersection of the bottom edge line and the left edge line is the bottom left corner, resulting in a total of four intersection points. These four intersection points are designated as the four corner points of the card. Based on the coordinates of these four corner points, the quadrilateral cropping region of the card in the original image is determined. Perspective transformation is then used to correct the quadrilateral region into a frontal rectangle. This region is then cropped from the original image, resulting in a frontal view image of the card with a uniform size of 512×512 pixels.
[0031] Step 103: Extract global semantic features, local visual features, textual semantic features, and special visual features of the card based on the card's front view image, and associate the global semantic features, local visual features, textual semantic features, and special visual features with the card identifier to obtain multi-layer feature data of the card.
[0032] In this embodiment of the application, four types of feature vectors are extracted based on the obtained front view image of the card. The specific process is as follows: Global semantic feature extraction employs a convolutional neural network as its backbone. This embodiment uses the PP-HGNetV2 (PaddlePaddle-High-Performance GPU Net Version 2) network, removing the fully connected classification layer at the end of the network. The main body of the network contains multiple convolutional modules and downsampling layers. The card's front view image is input into this backbone network. After multiple levels of convolutional downsampling and feature transformation, the spatial dimension of the feature map is compressed to 1×1 through a global average pooling layer, finally outputting a 512-dimensional floating-point global semantic feature vector.
[0033] Local visual feature extraction first involves adaptive cropping of the region of interest: calculating the geometric center coordinates of the card's front view image. Offset the cropping center vertically upwards by 1 / 8 of the image height, i.e. Take the smaller value between the image width and height, and use 4 / 5 of that as the cropping side length for the square. The top, bottom, left, and right boundaries of a square cropping window are calculated. If the window exceeds the original image area, it automatically shrinks inward, forcibly maintaining an aspect ratio of 1:1, and cropping to obtain a local image patch. The local image patch is input into a lightweight visual backbone network ResNet-50 (Residual Network-50, a 50-layer residual network). After convolutional feature extraction and global average pooling, a 512-dimensional local visual feature vector is output.
[0034] Text semantic feature extraction employs the TroOCR (Transformer-based Optical Character Recognition) model to perform full-face text recognition on the card's front view image. The TroOCR model uses an end-to-end architecture with a visual Transformer as the encoder and a Transformer as the decoder. Based on general pre-trained weights, this model utilizes a private dataset containing 100,000 partial cropped images of cards and is fine-tuned using low-rank adaptation techniques to accommodate the unique embossed text, dot-matrix printed characters, and laser-engraved fonts on the cards. After recognizing all text fields on the card, all text fields are concatenated according to a spatial reading order from top to bottom and left to right to form a complete card text sequence. This card text sequence is then input into the BGE-M3 (BAAI General Embedding-M3) semantic embedding model for encoding, generating a 768-dimensional global text semantic feature vector.
[0035] Special visual feature extraction employs Vision Transformer as the backbone network. The input is a full-frontal image of the card, and a multi-head self-attention mechanism is used to capture the long-range dependencies between card markings and background textures, outputting a high-dimensional visual feature map. The backbone network's backend connects to three parallel task output heads: the first is a marking detection head, implemented based on the DETR (Detection Transformer) architecture, used to locate and classify special markings such as logos and holographic anti-counterfeiting labels on the card surface; the second is a background texture classification head, using a fully connected layer structure, outputting the probability distribution of background texture categories such as grid patterns and wavy patterns; and the third is a texture attribute classification head, a multi-label fully connected classification structure, outputting card surface texture attribute labels such as matte, glossy, and pearlescent.
[0036] During the model training phase, the backbone network is initialized with pre-trained weights from a general image dataset. Full parameter fine-tuning is then performed on a card dataset containing 50,000 labeled samples. Cut Mix (data augmentation method) and Rand Augment (random augmentation) data augmentation strategies are introduced during training to improve model robustness. The classification token embedding vector corresponding to the last layer of the backbone network is extracted as a 512-dimensional special visual feature vector, which implicitly encodes multiple visual information such as identifiers, background textures, and other visual information.
[0037] By binding and associating the aforementioned global semantic feature vector, local visual feature vector, textual semantic feature vector, and special visual feature vector with the unique identifier of the corresponding card, complete multi-layer feature data of the card is obtained.
[0038] Step 104: Store the multi-layer feature data of the card into the vector database, and perform multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified. Aggregate the multi-channel retrieval results to obtain candidate card data.
[0039] In this embodiment, the underlying vector retrieval uses a hierarchical navigation small-world algorithm to construct an approximate nearest neighbor index, and cosine similarity is used as the distance metric. The global semantic feature vector, local visual feature vector, and textual semantic feature vector are each constructed as three independent retrieval channels, which are stored in three hierarchical navigation small-world indices of the vector database. The feature vector in each channel is associated with the unique identifier of the corresponding card.
[0040] When performing card recognition, the global semantic feature vector, local visual feature vector, and textual semantic feature vector of the card to be recognized are extracted and input into the three corresponding retrieval channels of the vector database respectively. A similarity search is performed, and each channel independently recalls the top-500 similar card candidates.
[0041] For all similar card candidates recalled from the three channels, they are merged and deduplicated according to the unique card identifier, retaining the similarity score of each candidate in each channel to form a candidate set containing multi-dimensional scores. According to the preset weight coefficients for each channel (0.3 for the global semantic channel, 0.3 for the local visual channel, and 0.4 for the text semantic channel in this embodiment), the multi-dimensional similarity scores of each candidate in the candidate set are weighted and summed to obtain the fusion retrieval score for each candidate. The candidates are then sorted in descending order of their fusion retrieval scores, and the top 100 candidates are selected as the aggregated candidate card data.
[0042] Step 105: Perform visual matching and special identifier filtering on the candidate card data. Based on the visual matching results and special identifier matching results, filter the candidate card data to obtain the filtered candidate card data.
[0043] In this embodiment of the application, the aggregated candidate card data is subjected to visual fine matching processing and special identifier filtering processing in sequence: The visual matching process employs the Super Point local feature extraction network for feature point extraction. This network uses a VGG (Visual Geometry Group) style convolutional backbone structure to output the coordinates of feature points in the image and their corresponding feature descriptors. Local feature points and feature descriptors are extracted from the front view image of the card to be identified and each candidate card image, and feature point pairing is performed using nearest neighbor matching. Based on the successfully paired feature point pairs, a random sampling consensus algorithm is used to calculate the homography matrix, and geometric consistency is verified using reprojection error to obtain the visual matching score for each candidate card.
[0044] The special identifier filtering process extracts the special visual feature vectors corresponding to each candidate card, calculates the cosine similarity with the special visual feature vectors of the card to be identified, and combines the matching results of anti-counterfeiting mark category, background texture type and surface texture attributes to obtain the special feature matching degree of each candidate card.
[0045] Based on the visual matching score and special feature matching degree of each candidate card, the candidate cards are filtered out. Candidate cards with geometric consistency reprojection error greater than a preset threshold and special feature matching degree lower than a preset threshold are removed, resulting in the filtered candidate card data.
[0046] Step 106: Perform a comprehensive similarity judgment on the screened candidate card data to obtain the card recognition result, and control the robotic arm to sort the cards to be sorted to the corresponding positions based on the card recognition result.
[0047] In this embodiment, for each screened candidate card, the visual matching score, special feature matching degree, and fusion retrieval score are combined, and a comprehensive similarity score is calculated for each candidate card according to a preset weight. All candidate cards are then sorted in descending order based on their comprehensive similarity scores, and the candidate card ranked first is selected as the optimal matching candidate. Two levels of judgment thresholds are set: a first preset threshold of 0.85 and a second preset threshold of 0.70. The comprehensive similarity score of the optimal matching candidate is compared with the preset thresholds. If the overall similarity score is greater than or equal to 0.85, it is considered a successful match, and the corresponding card's identification information is output as the recognition result. If the overall similarity score is between 0.70 and 0.85, it is judged as fuzzy and needs to be reviewed. If the overall similarity score is less than 0.70, it is judged as an unknown abnormal card.
[0048] Based on the final recognition result, the robotic arm control system outputs sorting control instructions: for successfully matched cards, the robotic arm moves the cards to be sorted to the corresponding sorting slot; for cards with unclear verification or unknown abnormalities, the robotic arm moves them to the manual verification slot to complete the card sorting.
[0049] This application adopts a progressive technical architecture of "image preprocessing - instance segmentation - orthographic correction - multi-layer feature extraction - multi-channel coarse retrieval - visual fine matching - comprehensive judgment and sorting". Instance segmentation accurately locates the card area, and edge fitting and perspective correction are combined to obtain a distortion-free orthographic image, eliminating interference from shooting angle and lighting. The ability to distinguish similar cards is improved by complementing four types of multi-dimensional features: global, local, text, and special. The combination of vector retrieval coarse screening and visual fine matching secondary screening balances retrieval efficiency and recognition accuracy. Finally, multi-level confidence judgment controls the robotic arm to automatically sort, which still has high recognition accuracy and sorting efficiency under complex working conditions, effectively reducing the cost of manual verification.
[0050] In the above Figure 1 Based on the above, this application embodiment also provides a schematic diagram of the implementation process for obtaining the target outline of a card. For example... Figure 2 As shown, steps 201 to 204 are included: Step 201: The original image is scaled to a preset input size, and the scaled image is then subjected to brightness equalization to obtain the image to be segmented.
[0051] In this embodiment, an industrial area scan camera deployed above the sorting station acquires the original RGB images of the cards to be sorted. The original images are then normalized using a bilinear interpolation algorithm to scale them to a preset input size of 640×640 pixels, adapting to the input tensor specifications of the subsequent instance segmentation network. Simultaneously, the scaled images undergo brightness equalization processing with contrast-constrained adaptive histogram equalization, adjusting the grayscale mapping of the image brightness channels to reduce the interference of global illumination unevenness and local reflections on the image's grayscale distribution, ultimately obtaining the image to be segmented.
[0052] Step 202: Input the image to be segmented into a pre-trained instance segmentation network to perform pixel-level segmentation of the target cards in the image to be segmented, and obtain the binary mask corresponding to the target cards.
[0053] In this embodiment, the image to be segmented is input into a pre-trained instance segmentation network. This embodiment uses the Mask R-CNN architecture to achieve pixel-level segmentation. The network consists of three parts: a backbone feature extraction network, a region proposal network, and a multi-task output branch. The backbone network uses a ResNet-50 combined with a feature pyramid network structure. After multi-level convolutional downsampling of the input image, it outputs multi-scale feature maps. The region proposal network generates candidate target region boxes based on the feature maps. The multi-task output branch includes a classification branch, a bounding box regression branch, and a mask segmentation branch, which output the candidate region category, position correction parameters, and pixel-level segmentation mask, respectively. The network finally outputs a single-channel binary mask corresponding to the target card. The pixel region where the target card is located within the mask is marked as foreground and has a value of 1; the remaining background pixels have a value of 0. This instance segmentation network is pre-trained and converges using a sample set of cards with different lighting, angles, and wear levels, exhibiting stable segmentation accuracy.
[0054] Step 203: Perform morphological closing operation on the binary mask to fill the holes and cracks inside the binary mask and smooth the mask edges to obtain the processed binary mask.
[0055] In this embodiment, morphological closing operations are performed on the binary mask. A 3×3 rectangular structuring element is used. First, the binary mask is dilated to expand the foreground region outward by 1 pixel, filling the tiny holes and edge cracks inside the mask caused by image noise. Then, the dilated mask is eroded to shrink the foreground region inward by 1 pixel. Without changing the overall shape and position of the mask, the edge burrs of the mask are smoothed to obtain the processed binary mask.
[0056] Step 204: Extract the contours of the processed binary mask to obtain multiple connected region contours, filter them according to the area of each connected region contour, take the connected region contour with the largest area as the card target contour, and remove isolated noise regions according to the preset area threshold.
[0057] In this embodiment, the Suzuki-Abe contour tracking algorithm is used to traverse the processed binary mask and extract the closed contours of all connected regions in the mask. The pixel area enclosed by each connected region contour is calculated, and all connected region contours are sorted in descending order according to their area values. The connected region contour with the largest area is selected as the target contour of the card. At the same time, a preset area threshold is set. In this embodiment, the preset area threshold is 1% of the total number of pixels in the image. Isolated small contours with an area smaller than this threshold are removed, and scattered noise areas in the background are also removed.
[0058] This application's embodiments unify image specifications through size scaling to adapt to the input requirements of instance segmentation networks; reduce interference from uneven illumination and local reflections through brightness equalization processing to improve segmentation stability under complex lighting conditions; accurately distinguish the foreground and background of the card using pixel-level instance segmentation and output a binary mask; fill internal holes in the mask and smooth edges through morphological closing operations to compensate for local defects in the segmentation results; and filter target contours by area sorting and remove noise areas to obtain accurate and complete card target contours, providing reliable basic data for subsequent edge fitting and image cropping, and reducing error propagation.
[0059] In some embodiments, the card's four sides are determined based on the card's target contour, the four corner points of the card are determined based on the intersection of adjacent sides, and the card's cropping area is determined based on the card's four corner points. The card's cropping area is then cropped from the original image to obtain a front view image of the card. This includes: calculating the card's target contour using the minimum bounding rectangle rotation algorithm to obtain the initial reference orientation and position of the card's four sides; assigning all pixels on the contour according to their distance from the four thick sides to obtain four contour point sets corresponding to the card's four sides respectively.
[0060] Specifically, for all contour point coordinates contained in the card target contour, a rotation enumeration method is used to solve for the minimum area enclosing rectangle. Within a range of 0° to 180°, rotation angles are traversed in 1° increments. After rotating all contour points around the origin by the corresponding angle, the area of the axis-aligned enclosing rectangle is calculated, and the rotation angle and rectangle size parameters corresponding to the minimum area are recorded. Based on the optimal rotation angle and rectangle size, the equations of the four lines enclosing the rectangle in the original coordinate system are derived, serving as the orientation and position reference for the four thick edges of the card. For all pixels on the target contour, the vertical distance from each pixel to the four thick edge lines is calculated, and each pixel is assigned to the thick edge with the smallest vertical distance, ultimately forming four independent contour point sets corresponding to the top, bottom, left, and right edges of the card.
[0061] Furthermore, for each set of contour points, the projection position of each point in the set onto the straight line of the corresponding edge is calculated. Only the mid-section contour points whose projection positions are within a preset range of the midpoint of the corresponding edge are retained, while the contour points close to both ends of the edge are discarded, thus obtaining the filtered mid-section contour point set of each edge.
[0062] Specifically, for each set of contour points, first determine the direction vector of the corresponding edge, then project each contour point in the set onto the line containing that direction vector, calculate the projection length of each point, and obtain the distribution of the projection positions of all points. Calculate the minimum and maximum projection lengths of the edge to determine the total length range of the edge; take the midpoint of this range as the center, retain the middle section of 70% of the total length as a preset range, and only retain the middle contour points whose projection positions fall within this preset range, discarding contour points within the 15% length range closest to both ends of the edge. This eliminates contour distortion and edge noise interference in corner areas, resulting in the filtered set of middle contour points for each edge.
[0063] Furthermore, for each set of mid-section contour points, a random sampling consensus algorithm or the least squares method is used to fit straight lines to obtain the equations of four stable edge lines corresponding to the four sides of the card.
[0064] Specifically, for each mid-section contour point set, a random sampling consensus algorithm is used for line fitting to improve the fitting stability under contour noise. The specific process is as follows: randomly select two points from the current mid-section contour point set to fit an initial straight line; calculate the perpendicular distance from all points in the point set to the straight line, mark points with a distance less than a preset distance threshold as interior points, and mark the rest as exterior points; repeat the above sampling and interior point counting process, and after 100 iterations, select the straight line with the most interior points as the optimal fitting result, and finally output the equations of the four stable edge lines corresponding to the four sides of the card, which are expressed in the form of the general form of a straight line Ax + By + C = 0.
[0065] Furthermore, based on the equations of the four stable edge lines, the coordinates of the intersection points of each pair of adjacent edge lines are calculated to obtain four intersection points, which are then determined as the four corner points of the card.
[0066] Specifically, based on the equations of the four stable edge lines, a system of two linear equations in two variables is constructed for each pair of adjacent edge lines. By solving the system of equations, the coordinates of the four intersection points are obtained: the intersection of the upper edge line and the left edge line is the upper left corner point, the intersection of the upper edge line and the right edge line is the upper right corner point, the intersection of the lower edge line and the right edge line is the lower right corner point, and the intersection of the lower edge line and the left edge line is the lower left corner point. These four intersection points are determined as the four corner points of the card.
[0067] Furthermore, the cropping region of the card in the original image is determined based on the coordinates of the four corner points, and the image corresponding to the cropping region is cropped from the original image to obtain the front view image of the card.
[0068] Specifically, the quadrilateral cropping area of the card in the original image is determined based on the coordinates of the four corner points. A perspective transformation algorithm is used to map the tilted quadrilateral area into a standard regular rectangle. The output size is set to 512×512 pixels. Pixel resampling is performed through bilinear interpolation. A distortion-free card front view image is obtained by cropping and correcting from the original image.
[0069] This application embodiment preliminarily determines the orientation and position of the four sides of the card using the minimum circumscribed rotating rectangle, enabling rapid side assignment of contour points; by retaining the middle contour points and discarding the distorted points at both ends, it eliminates the interference of irregular corner contours on straight line fitting, improving fitting accuracy; a noise-resistant straight line fitting algorithm is used to obtain stable edge equations, and precise corner points are solved by the intersection of adjacent edge lines; based on the corner points, perspective transformation and cropping are performed to correct the tilted card area into a standard front view image, eliminating perspective distortion, unifying image size, and ensuring the consistency and accuracy of subsequent feature extraction.
[0070] In some embodiments, global semantic features, local visual features, textual semantic features, and special visual features of a card are extracted based on the card's front view image, and the global semantic features, local visual features, textual semantic features, and special visual features are associated with the card identifier to obtain multi-layer feature data of the card, including: inputting the card's front view image into a pre-trained convolutional neural network backbone to extract a global semantic feature vector.
[0071] Specifically, a convolutional neural network is used as the backbone for global feature extraction. This embodiment selects the PP-HGNetV2 network architecture, removing the fully connected layers and output layers used for classification at the end of the network, and retaining the multi-level convolutional feature extraction module and downsampling module. A card front view image with a size of 512×512 pixels is input into this backbone network, and it undergoes feature transformation and 2x downsampling in multiple convolutional stages to extract low-dimensional to high-dimensional image features step by step, outputting a high-dimensional feature map with a dimension of 16×16×512. A global average pooling operation is performed on the high-dimensional feature map, averaging all feature values of each channel along the spatial dimension, compressing the spatial dimension to 1×1, and finally outputting a 512-dimensional floating-point global semantic feature vector. This vector represents the overall layout, main color, and global semantic information of the card.
[0072] Furthermore, the core region of the card's front view image is adaptively cropped, and the cropped local image is input into a visual feature extraction network to extract local visual feature vectors.
[0073] Specifically, the first step is to perform adaptive cropping of the region of interest on the card's front view image. The specific calculation process is as follows: calculate the geometric center coordinates of the card's front view image. ,in Half the image width The cropping center is half the image height; the cropping center is shifted vertically upwards by 1 / 8 of the image height to obtain the ordinate of the target cropping center. To avoid the border strip and redundant decorations at the bottom of the card, take the smaller value between the image width and height, and use 4 / 5 of that as the square cropping side length. To ensure the cropped area covers the core information area of the card, the top, bottom, left, and right boundaries of the cropping window are calculated based on the cropping center and the side length of the square. If the window boundary exceeds the original image range, it is automatically shrunk inward to maintain a 1:1 aspect ratio, ultimately cropping a square local image patch. This local image patch is input into a lightweight visual backbone network, ResNet-50. The fully connected classification layer at the end is removed, and after multi-level convolutional feature extraction, global average pooling is performed to output a 512-dimensional local visual feature vector. This vector characterizes the texture, pattern, and layout details of the core area of the card.
[0074] Furthermore, full-face text recognition and semantic encoding are performed on the front view image of the card to extract the text semantic feature vector.
[0075] Specifically, the TroOCR model is used to perform full-card text recognition. This model adopts an end-to-end architecture, consisting of a visual Transformer encoder and a Transformer decoder. The visual encoder divides the input image into image patches and encodes them into visual feature sequences, while the decoder outputs the recognized text based on the visual feature sequences through autoregression. The model is first pre-trained on a general printed text dataset, and then fine-tuned using a private dataset containing partially cropped images of 100,000 cards through low-rank adaptation techniques to adapt to the unique embossed characters, dot matrix printed characters, and laser-engraved fonts of the cards, improving the recognition recall rate of low-contrast characters. After recognition, the position coordinates and content of all text fields on the card are obtained, and all text fields are concatenated sequentially according to the spatial reading order from top to bottom and from left to right to form a complete card text sequence. The card text sequence is then input into the BGE-M3 semantic embedding model, which is based on the Transformer encoder architecture and performs contextual semantic encoding on the text sequence, ultimately outputting a 768-dimensional global text semantic feature vector that supports semantic-level fuzzy matching.
[0076] Furthermore, the front view image of the card is input into a pre-trained multi-task visual recognition model to extract special visual feature vectors containing anti-counterfeiting marks, background textures, and surface texture information.
[0077] Specifically, a multi-task visual recognition model is employed to extract unique visual features. The model's core network is a VisionTransformer. After inputting a full-view image of the card, an image patch embedding layer divides the image into fixed-size patches and converts them into embedding sequences. These are then transformed using a multi-layer, multi-head self-attention encoder to capture the long-range dependencies between scattered logos and background patterns on the card, outputting a global visual feature sequence. The backbone network's backend connects to three parallel task output heads: Identification Detection Head: Based on the DETR detection architecture, it includes a Transformer encoder and decoder, and outputs the position frame and category of special markings on the card surface, covering the issuing bank logo, holographic anti-counterfeiting label, and laser pattern; Background texture classification header: It adopts a structure of global average pooling plus two fully connected layers to output the probability distribution of texture categories such as grid texture, wave texture, starburst texture, solid color gradient, etc. Texture Attribute Classification Head: Employs a fully connected layer structure for multi-label classification, outputting prediction results for card surface texture attributes such as matte, glossy, pearlescent, and metallic. During model training, the backbone network is initialized with pre-trained weights from a general image dataset. Full parameter fine-tuning is then performed on a card dataset containing 50,000 labeled samples. CutMix and Rand Augment data augmentation strategies are introduced during training to improve the model's robustness to lighting changes and local occlusion. The classification token embedding vector output from the last layer of the backbone network is extracted as a 512-dimensional special visual feature vector, implicitly encoding multi-dimensional information such as category, background type, and texture style.
[0078] Furthermore, the global semantic feature vector, local visual feature vector, textual semantic feature vector, and special visual feature vector are bound and associated with the unique identifier of the corresponding card to obtain multi-layer feature data of the card.
[0079] Specifically, the aforementioned global semantic feature vector, local visual feature vector, textual semantic feature vector, and special visual feature vector are bound one-to-one with the unique identifier of the corresponding card. Each feature vector is labeled with a corresponding feature type identifier, which together form a structured multi-layer feature data for the card, ensuring that the four types of features of the same card can be uniformly accessed through the unique identifier.
[0080] This application's embodiments extract global semantic features through a convolutional backbone to characterize the overall layout and color information of the card; extract local visual features by adaptively cropping the core area to focus on key details of the card surface; extract textual semantic features through character recognition and semantic encoding to support fuzzy matching at the semantic level; extract special visual features including anti-counterfeiting marks, background patterns, and textures through a multi-task visual model to mine differentiated information about the card surface; the four types of features complement each other from different dimensions, significantly improving the distinguishability of highly similar cards; and bind and associate various features with the unique identifier of the card to form structured multi-layer feature data, which facilitates subsequent multi-channel retrieval and unified access.
[0081] In some embodiments, the multi-layer feature data of the card is stored in a vector database, and multi-channel similarity retrieval is performed based on the multi-layer feature data of the card to be identified. The multi-channel retrieval results are aggregated to obtain candidate card data, including: constructing the global semantic feature vector, local visual feature vector, and text semantic feature vector into three independent retrieval channels, and storing them in three independent approximate nearest neighbor index structures in the vector database. The feature vector in each retrieval channel is associated with the unique identifier of the corresponding card.
[0082] Specifically, the underlying vector retrieval employs a hierarchical navigation small-world algorithm to construct an approximate nearest neighbor index. The index itself is a multi-layered directed graph structure: the bottom layer contains all vector nodes, and upper-layer nodes are randomly selected from lower-layer nodes with fixed probabilities. During retrieval, the system navigates downwards layer by layer from the top-level entry node to approximate the nearest neighbor, achieving logarithmic search complexity. Cosine similarity is used as the distance metric. Global semantic feature vectors, local visual feature vectors, and textual semantic feature vectors are each constructed as three independent retrieval channels, with each channel corresponding to an independent hierarchical navigation small-world index. The global semantic channel corresponds to a 512-dimensional feature vector, the local visual channel to a 512-dimensional feature vector, and the textual semantic channel to a 768-dimensional feature vector. Each vector node is bound to a unique identifier of the corresponding card in the index, establishing a one-to-one mapping between the vector and the card entity. During data storage, the three types of feature vectors corresponding to each card are inserted into the index structure of the corresponding channel, completing the storage of multi-channel, multi-layered feature data.
[0083] Furthermore, the global semantic feature vector, local visual feature vector, and textual semantic feature vector of the card to be identified are extracted and input into the three corresponding retrieval channels of the vector database. Cosine similarity is used as the metric to perform similarity search, and each channel independently recalls a preset number of similar card candidates.
[0084] Specifically, during card recognition retrieval, the global semantic feature vector, local visual feature vector, and textual semantic feature vector of the card to be recognized are extracted and input into the three corresponding retrieval channels of the vector database. The three channels perform similarity searches in parallel, using cosine similarity as the metric. The cosine of the angle between the query vector and each vector in the index is calculated; a cosine value closer to 1 indicates higher vector similarity. Each channel independently recalls the top 500 similar card candidates based on similarity, outputting the unique card identifier and the similarity score for each channel, ensuring sufficient recall of candidate samples from each modality.
[0085] Furthermore, all similar card candidates recalled from the three channels are merged and deduplicated according to the unique card identifier, and the similarity score of each candidate in each channel is retained to form a candidate set containing multi-dimensional scores.
[0086] Specifically, for the similar card candidates recalled by each of the three channels, a merging and deduplication process is performed based on the unique card identifier. All candidate entries output by the three channels are traversed, and entries with the same unique card identifier are merged, retaining the similarity score of that candidate in each corresponding channel. If a candidate is only recalled in some channels, the corresponding similarity score for the unrecalled channels is recorded as 0. After merging, a multi-dimensional score candidate set is formed, containing the global semantic similarity score, local visual similarity score, and textual semantic similarity score for each candidate.
[0087] Furthermore, according to the preset channel weight coefficients, the multi-dimensional similarity scores of each candidate in the candidate set are weighted and calculated to obtain the fusion retrieval score of each candidate. The candidates are then sorted in descending order of the fusion retrieval scores to obtain the aggregated candidate card data.
[0088] Specifically, weight coefficients for three retrieval channels are pre-configured. In this embodiment, the weight coefficient for the global semantic channel is set to 0.3, the weight coefficient for the local visual channel is set to 0.3, and the weight coefficient for the text semantic channel is set to 0.4, with the sum of the three weight coefficients being 1. For each candidate in the candidate set, its similarity score for each of the three channels is multiplied by the corresponding channel's weight coefficient and then summed to calculate the fusion retrieval score for each candidate. All candidates are sorted in descending order according to their fusion retrieval scores, and the top 100 candidates are selected as the aggregated candidate card data to complete the aggregation of the first-level coarse screening results.
[0089] This application's embodiments construct independent retrieval channels for three types of features and establish an approximate nearest neighbor index to adapt to the retrieval needs of different feature dimensions, achieving high retrieval efficiency. Using cosine similarity as a metric, candidates are recalled in parallel across channels, ensuring matching recall rates for all feature types and avoiding missed detections in a single dimension. The results from multiple channels are merged and deduplicated, retaining the similarity scores for each dimension. A comprehensive retrieval score is obtained through weighted fusion with preset weights, balancing the contributions of each feature dimension. The candidate set is then output in sorted order, achieving efficient coarse screening, effectively narrowing the processing range for subsequent fine matching, and improving overall recognition speed.
[0090] In some embodiments, visual fine matching processing and special identifier filtering processing are performed on the candidate card data. The candidate card data is then filtered based on the visual matching results and the special identifier matching results to obtain the filtered candidate card data. This includes: for each candidate card in the candidate card data, extracting local feature points and feature descriptors of the front view image of the card to be identified and the corresponding candidate card image, and performing feature point pairing matching; calculating the homography matrix based on the successfully paired feature point pairs and performing geometric consistency verification to obtain the visual matching score corresponding to each candidate card.
[0091] Specifically, the Super Point local feature extraction network is used to extract feature points and descriptors. This network employs a VGG-style convolutional shared encoder structure. The front end consists of multiple convolutional and pooling layers, which progressively downsample and extract basic features from the input image. The back end is divided into two parallel output branches: the keypoint detection branch outputs the pixel coordinates and response intensity of feature points in the image, and the descriptor branch outputs a 256-dimensional feature descriptor corresponding to each feature point. The extracted features possess illumination invariance and affine invariance. For each candidate card in the candidate card data, the front view image of the card to be recognized and the front view image of the corresponding candidate card are converted into single-channel grayscale images, and the size is uniformly adjusted to 240×320 pixels before being input into the Super Point network. The network outputs the basic feature map of the image through the shared encoder, and then outputs the set of feature point coordinates and the corresponding 256-dimensional descriptor set of the image through the two branches respectively. Feature point pairing is performed using the nearest neighbor distance ratio matching algorithm: For each feature descriptor of the image to be identified, the two descriptors with the closest and second closest Euclidean distances are found in the descriptor set of the candidate images. The ratio of the nearest distance to the second closest distance is calculated. When the ratio is less than a preset ratio threshold of 0.7, it is determined to be a valid pair of paired feature points, resulting in several pairs of paired feature points. Based on all paired feature point pairs, the homography matrix between the two images is calculated using the random sampling consensus algorithm. The specific process is as follows: Four non-collinear point pairs are randomly selected from all paired point pairs, and a 3×3 homography matrix is solved; all paired point pairs are substituted into the homography matrix to calculate the reprojection coordinates, and the number of interior points with a reprojection error less than a preset pixel threshold of 2 pixels is counted; the above sampling, solving, and interior point counting process is repeated for a total of 200 iterations, and the homography matrix with the most interior points is selected as the final projection transformation matrix. The ratio of the number of inliers corresponding to the final homography matrix to the total number of paired points is used as the inlier rate. Combined with the average reprojection error, the result is normalized to obtain a visual matching score ranging from 0 to 1. The higher the score, the higher the visual geometric consistency between the two images.
[0092] Furthermore, the special visual feature vectors corresponding to each candidate card are extracted and compared with the special visual feature vectors of the card to be identified. The matching results of anti-counterfeiting mark category, background texture type and surface texture attribute are combined to obtain the special feature matching degree of each candidate card.
[0093] Specifically, a 512-dimensional special visual feature vector is extracted from the multi-layer feature data of the cards, corresponding to each candidate card. The cosine similarity is calculated between this vector vector and the special visual feature vector of the card to be identified, yielding a vector-level matching score. Simultaneously, consistency is verified using the semantic attribute results output by the multi-task visual recognition model: the three semantic labels of anti-counterfeiting mark category, background texture type, and surface texture attribute are compared between the card to be identified and the candidate cards. Each match is scored as 1 point, and a mismatch as 0 points, resulting in an attribute matching score, with a maximum of 3 points. A weighted fusion method is used to calculate the special feature matching degree: the vector-level matching score is weighted at 0.6, and the attribute matching score, after normalization, is weighted at 0.4. The weighted sum yields a special feature matching degree ranging from 0 to 1, comprehensively representing the overall similarity of the special visual features.
[0094] Furthermore, the candidate cards are sorted and filtered based on their visual matching scores and special feature matching degrees. Candidate cards that do not meet the preset conditions for geometric consistency or whose special feature matching degree is lower than the preset threshold are removed, resulting in the filtered candidate card data.
[0095] Specifically, preset conditions for geometric consistency and a preset threshold for special feature matching are established: the geometric consistency preset condition is an inlier rate greater than or equal to 0.3 and an average reprojection error less than or equal to 3 pixels; the special feature matching threshold is set to 0.6. All candidate cards are traversed. First, the geometric consistency condition is verified, and candidate cards that do not meet the condition are removed. Then, the special feature matching degree of the remaining candidate cards is verified, and candidate cards with a matching degree lower than the preset threshold are removed. For the finally retained candidate cards, a comprehensive screening score is calculated with a weight of 0.5 for both visual matching score and special feature matching degree. The cards are then sorted in descending order of the comprehensive screening score to obtain the filtered candidate card data.
[0096] This application's embodiments achieve pixel-level visual precision matching by extracting and pairing local feature points, combined with homography matrix for geometric consistency verification. The matching results possess affine invariance and are robust to changes in angle and scale. By combining vector similarity with semantic attribute verification, the matching degree of special features is calculated, fully leveraging the filtering role of differentiated features such as anti-counterfeiting, background patterns, and textures. Through dual screening using geometric consistency conditions and matching degree thresholds, candidate cards that do not meet the requirements are eliminated, effectively excluding interference from similar card types, reducing the probability of misidentification, and improving the accuracy of subsequent final judgment.
[0097] In some embodiments, a comprehensive similarity determination is performed on the screened candidate card data to obtain card recognition results, and a robotic arm is controlled to sort the cards to be sorted to the corresponding positions based on the card recognition results. This includes: for each screened candidate card, the visual matching score, special feature matching degree and multi-channel retrieval similarity score are fused to calculate the comprehensive similarity score corresponding to each candidate card.
[0098] Specifically, for each candidate card after screening, a weighted fusion calculation is performed using three similarity indicators: the fusion retrieval score output from the multi-channel retrieval stage, the visual matching score output from the visual fine matching stage, and the special feature matching degree output from the special identifier filtering stage. The values of all three scores have been normalized to the range of 0 to 1. Pre-configured weight coefficients for the three indicators are: 0.4 for the fusion retrieval score, 0.35 for the visual matching score, and 0.25 for the special feature matching degree, with a sum of 1. For each candidate card, the three scores are multiplied by their respective weight coefficients and then summed to obtain the comprehensive similarity score for that candidate card. The comprehensive similarity score ranges from 0 to 1, with a higher value indicating a higher degree of matching between the card to be identified and the candidate card.
[0099] Furthermore, all candidate cards are sorted in descending order according to their comprehensive similarity scores, and the candidate card ranked first is selected as the optimal matching candidate.
[0100] Specifically, all filtered candidate cards are sorted in descending order according to their overall similarity scores. If multiple candidate cards have the same overall similarity score, their visual matching scores are further compared, with candidates having higher visual matching scores ranked higher. The candidate card ranked first is selected as the optimal matching candidate, and its unique identifier, card category information, and corresponding overall similarity score are recorded.
[0101] Furthermore, the comprehensive similarity score of the optimal matching candidate is compared with a preset multi-level threshold to generate a corresponding recognition result; when the comprehensive similarity score is greater than or equal to the first preset threshold, a successfully matched recognition result is generated; when the comprehensive similarity score is between the first preset threshold and the second preset threshold, a vague recognition result awaiting review is generated; when the comprehensive similarity score is less than the second preset threshold, an unknown abnormal recognition result is generated.
[0102] Specifically, two preset threshold levels are set: a first preset threshold of 0.85 and a second preset threshold of 0.70. These thresholds can be dynamically adjusted based on actual sorting accuracy requirements. The comprehensive similarity score of the optimal matching candidate is compared sequentially with the two preset threshold levels to generate corresponding recognition results: When the comprehensive similarity score is greater than or equal to the first preset threshold of 0.85, the matching confidence level meets the automatic sorting requirements, a successfully matched recognition result is generated, and the unique card identifier and card category information corresponding to the optimal matching candidate are output; when the comprehensive similarity score is between the first preset threshold of 0.85 and the second preset threshold of 0.70, the matching confidence level is insufficient, posing a risk of confusion with similar card types, and a vague recognition result awaiting verification is generated, outputting the optimal matching candidate and the information of the top three candidate cards for manual verification; when the comprehensive similarity score is less than the second preset threshold of 0.70, no matching card is found in the feature library, an unknown abnormal recognition result is generated, and an abnormal card marker is output.
[0103] Furthermore, based on the generated recognition results, sorting control instructions are output to the robotic arm, which then moves the cards to be sorted to the corresponding positions. Successfully matched cards are moved to the corresponding category sorting slot, while cards with unclear information requiring verification or unknown anomalies are moved to the manual verification slot.
[0104] Specifically, the generated recognition results are sent to the robotic arm controller via an industrial Ethernet communication interface. The controller then calls a pre-stored motion trajectory program based on the recognition results, controlling the four-degree-of-freedom Cartesian coordinate robotic arm to perform sorting actions. A vacuum suction cup assembly at the end of the robotic arm first moves to directly above the cards to be sorted, then connects a negative pressure air source to suck up the cards. For successfully matched cards, the position coordinates of the corresponding sorting slot are mapped according to the card category information, and the robotic arm is controlled to move the card to the top of the corresponding category's sorting slot, then the negative pressure is disconnected to release the card. For cards with unclear information requiring verification or unknown anomalies, the robotic arm is controlled to move them to the manual verification slot for release. After completing the transfer, the robotic arm returns to the standby station, triggering the image acquisition and recognition process for the next card, completing the full sorting cycle for a single card.
[0105] This application embodiment calculates comprehensive similarity by integrating multi-dimensional matching scores to comprehensively measure the degree of card matching, resulting in a more objective and accurate judgment. It achieves graded judgment through two-level preset thresholds, automatically sorting high-confidence results and transferring low-confidence results to manual review, maximizing the proportion of automatic processing while ensuring sorting accuracy. Based on the recognition results, it directly controls the robotic arm to perform corresponding sorting actions, realizing closed-loop execution of image recognition and mechanical sorting, adapting to the continuous operation requirements of automated production lines, and improving overall sorting efficiency and operational reliability.
[0106] While this application provides the method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-inventive labor. The order of steps listed in this embodiment is merely one possible execution order among many and does not represent the only execution order. In actual device or client product execution, the methods shown in this embodiment or the accompanying drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment).
[0107] like Figure 3 As shown in the illustration, this application also provides a smart card sorting device 300. The device includes: The acquisition module 301 is used to acquire the original image of the card to be sorted, perform size scaling and brightness equalization processing on the original image, and input the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. The binary mask is then subjected to morphological processing and contour extraction to obtain the target card contour.
[0108] The processing module 302 is used to determine the edge lines of the four sides of the card based on the target outline of the card, determine the four corner points of the card based on the intersection of adjacent edge lines, determine the card clipping area based on the four corner points of the card, and clip the card clipping area from the original image to obtain the front view image of the card.
[0109] The processing module 302 is also used to extract global semantic features, local visual features, text semantic features and special visual features of the card based on the card's front view image, and associate the global semantic features, local visual features, text semantic features and special visual features with the card identifier to obtain multi-layer feature data of the card.
[0110] The processing module 302 is also used to store the multi-layer feature data of the card into the vector database respectively, and perform multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified, and aggregate the multi-channel retrieval results to obtain candidate card data.
[0111] The processing module 302 is also used to perform visual fine matching processing and special identifier filtering processing on the candidate card data, and to filter the candidate card data based on the visual matching results and special identifier matching results to obtain the filtered candidate card data.
[0112] The judgment module 303 is used to perform a comprehensive similarity judgment on the screened candidate card data, obtain the card recognition result, and control the robotic arm to sort the cards to be sorted to the corresponding positions according to the card recognition result.
[0113] Some modules in the apparatus described in this application can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0114] The apparatus or module described in the above embodiments can be implemented by a computer chip or physical entity, or by a product with a certain function. For ease of description, the above apparatus is described by dividing it into various modules according to their functions. When implementing the embodiments of this application, the functions of each module can be implemented in one or more software and / or hardware. Of course, a module that implements a certain function can also be implemented by combining multiple sub-modules or sub-units.
[0115] The methods, apparatus, or modules described in this application can be implemented in a computer-readable program code manner. The controller can be implemented in any suitable manner, such as a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of a memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code manner, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included within it for implementing various functions can also be considered as structures within the hardware component. Alternatively, the device used to implement various functions can be viewed as either a software module implementing the method or a structure within a hardware component.
[0116] This application also provides an apparatus, the apparatus comprising: a processor; a memory for storing processor-executable instructions; wherein, when the processor executes the executable instructions, it implements the method described in this application.
[0117] This application also provides a non-volatile computer-readable storage medium storing a computer program or instructions thereon, which, when executed, enables the method described in this application embodiment to be implemented.
[0118] Furthermore, in the various embodiments of the present invention, each functional module can be integrated into a processing module, or each module can exist independently, or two or more modules can be integrated into a single module.
[0119] The aforementioned storage media include, but are not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), Cache, Hard Disk Drive (HDD), or Memory Card. The memory can be used to store computer program instructions.
[0120] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary hardware. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, or it can be embodied in the process of data migration. The computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, mobile terminal, server, or network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments of this application.
[0121] The various embodiments described in this specification are presented in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. All or part of this application can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, mobile communication terminals, multiprocessor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices, etc.
[0122] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of this application.
Claims
1. A smart card sorting method, characterized in that, include: The original image of the card to be sorted is obtained, the original image is scaled and brightness equalized, and the processed image is input into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. The binary mask is then processed morphologically and the contour is extracted to obtain the target card contour. Based on the target outline of the card, the edge lines of the four sides of the card are determined. The four corner points of the card are determined according to the intersection points of adjacent edge lines. The card cropping area is determined according to the four corner points of the card. The card cropping area is cropped from the original image to obtain the front view image of the card. Based on the card's front view image, global semantic features, local visual features, textual semantic features, and special visual features of the card are extracted, and the global semantic features, local visual features, textual semantic features, and special visual features are associated with the card identifier to obtain multi-layer feature data of the card; The multi-layer feature data of the card is stored in a vector database, and multi-channel similarity retrieval is performed based on the multi-layer feature data of the card to be identified. The multi-channel retrieval results are then aggregated to obtain candidate card data. The candidate card data is subjected to visual fine matching processing and special identifier filtering processing. The candidate card data is then filtered based on the visual matching results and special identifier matching results to obtain the filtered candidate card data. The selected candidate card data are subjected to a comprehensive similarity determination to obtain card recognition results. Based on the card recognition results, the robotic arm is controlled to sort the cards to be sorted to the corresponding positions.
2. The method according to claim 1, characterized in that, The process involves acquiring the original image of the card to be sorted, scaling and equalizing the brightness of the original image, and then inputting the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain a binary mask corresponding to the target card. Morphological processing and contour extraction are then performed on the binary mask, including: The original image is scaled to a preset input size, and the scaled image is then subjected to brightness equalization to obtain the image to be segmented. The image to be segmented is input into the pre-trained instance segmentation network to perform pixel-level segmentation of the target card in the image to be segmented, thereby obtaining the binary mask corresponding to the target card. The binary mask is subjected to morphological closing operations to fill the holes and cracks inside the binary mask and smooth the mask edges, resulting in the processed binary mask. The processed binary mask is subjected to contour extraction to obtain multiple connected region contours. The contours are then filtered according to the area of each connected region contour, and the connected region contour with the largest area is taken as the target contour of the card. Isolated noise regions are removed according to a preset area threshold.
3. The method according to claim 1, characterized in that, The process of determining the edge lines of the four sides of the card based on the target outline of the card, determining the four corner points of the card based on the intersection points of adjacent edge lines, determining the card cropping area based on the four corner points of the card, and cropping the card cropping area from the original image to obtain a front view image of the card includes: The minimum bounding rectangle algorithm is used to calculate the target outline of the card to obtain the initial reference orientation and position of the four sides of the card. All pixels on the outline are assigned according to their distance from the four thick sides to obtain four outline point sets corresponding to the four sides of the card. For each set of contour points, calculate the projection position of each point in the set onto the straight line of the corresponding edge, retain only the mid-section contour points whose projection positions are within a preset range of the midpoint of the corresponding edge, and discard the contour points close to both ends of the edge to obtain the filtered mid-section contour point set of each edge. For each set of mid-section contour points, a random sampling consensus algorithm or the least squares method is used to fit a straight line to obtain the equations of the four stable edge lines corresponding to the four sides of the card. Based on the equations of the four stable edge lines, calculate the coordinates of the intersection points of each pair of adjacent edge lines to obtain four intersection points, which are then used as the four corner points of the card. The cropping area of the card in the original image is determined based on the coordinates of the four corner points. The image corresponding to the cropping area is then cropped from the original image to obtain the front view image of the card.
4. The method according to claim 1, characterized in that, The process involves extracting global semantic features, local visual features, textual semantic features, and special visual features from the card's front view image, and associating these features with the card identifier to obtain multi-layered feature data for the card, including: The front view image of the card is input into the pre-trained convolutional neural network backbone to extract the global semantic feature vector; The card's front view image is subjected to adaptive cropping of the core region. The cropped local image is then input into a visual feature extraction network to extract local visual feature vectors. The card's front view image is subjected to full-face text recognition and semantic encoding to extract text semantic feature vectors; The card's front view image is input into a pre-trained multi-task visual recognition model to extract special visual feature vectors containing anti-counterfeiting marks, background textures, and surface texture information. The global semantic feature vector, the local visual feature vector, the text semantic feature vector, and the special visual feature vector are bound and associated with the unique identifier of the corresponding card to obtain multi-layer feature data of the card.
5. The method according to claim 1, characterized in that, The process involves storing the multi-layer feature data of the card into a vector database, performing multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified, and aggregating the multi-channel retrieval results to obtain candidate card data, including: The global semantic feature vector, local visual feature vector, and text semantic feature vector are each constructed into three independent retrieval channels, which are then stored in three independent approximate nearest neighbor index structures in the vector database. The feature vector in each retrieval channel is associated with the unique identifier of the corresponding card. Extract the global semantic feature vector, local visual feature vector, and textual semantic feature vector of the card to be identified, and input them into the three corresponding retrieval channels of the vector database. Use cosine similarity as the metric to perform similarity search, and each channel independently recalls a preset number of similar card candidates. All similar card candidates recalled from the three channels are merged and deduplicated according to the unique card identifier, and the similarity score of each candidate in each channel is retained to form a candidate set containing multi-dimensional scores. According to the preset weight coefficients of each channel, the multi-dimensional similarity scores of each candidate in the candidate set are weighted and calculated to obtain the fusion retrieval score of each candidate. The candidates are then sorted in descending order of the fusion retrieval scores to obtain the aggregated candidate card data.
6. The method according to claim 1, characterized in that, The process of performing visual matching and special identifier filtering on the candidate card data, and filtering the candidate card data based on the visual matching results and special identifier matching results, yields the filtered candidate card data, including: For each candidate card in the candidate card data, local feature points and feature descriptors are extracted from the front view image of the card to be identified and the corresponding candidate card image, and feature point pairing matching is performed; based on the successfully paired feature point pairs, the homography matrix is calculated and geometric consistency is checked to obtain the visual matching score corresponding to each candidate card. Extract the special visual feature vectors corresponding to each candidate card, compare them with the special visual feature vectors of the card to be identified, and combine the matching results of anti-counterfeiting mark category, background texture type and surface texture attribute to obtain the special feature matching degree of each candidate card. The candidate cards are sorted and filtered based on their visual matching scores and special feature matching degrees. Candidate cards that do not meet the preset conditions for geometric consistency or whose special feature matching degree is lower than the preset threshold are removed, resulting in the filtered candidate card data.
7. The method according to claim 1, characterized in that, The step of performing a comprehensive similarity determination on the screened candidate card data to obtain card recognition results, and controlling the robotic arm to sort the cards to be sorted to the corresponding positions based on the card recognition results, includes: For each candidate card after screening, the visual matching score, special feature matching degree and multi-channel retrieval similarity score are combined to calculate the comprehensive similarity score corresponding to each candidate card. All candidate cards are sorted in descending order according to their comprehensive similarity scores, and the candidate card ranked first is selected as the optimal matching candidate. The comprehensive similarity score of the best matching candidate is compared with a preset multi-level threshold to generate the corresponding recognition result; when the comprehensive similarity score is greater than or equal to the first preset threshold, a successful matching recognition result is generated; when the comprehensive similarity score is between the first preset threshold and the second preset threshold, a fuzzy recognition result awaiting review is generated; when the comprehensive similarity score is less than the second preset threshold, an unknown anomaly recognition result is generated. Based on the generated recognition results, the robot arm is given sorting control instructions to move the cards to be sorted to the corresponding positions. Cards that are successfully matched are moved to the corresponding category sorting slot, while cards that are ambiguous and need to be reviewed or are of unknown anomaly are moved to the manual review slot.
8. A smart card sorting device, characterized in that, include: The acquisition module is used to acquire the original image of the card to be sorted, perform size scaling and brightness equalization processing on the original image, and input the processed image into a pre-trained instance segmentation network for pixel-level segmentation of the card region to obtain the binary mask corresponding to the target card. The binary mask is then subjected to morphological processing and contour extraction to obtain the target card contour. The processing module is used to determine the edge lines of the four sides of the card based on the target outline of the card, determine the four corner points of the card based on the intersection points of adjacent edge lines, determine the card cropping area based on the four corner points of the card, and crop the card cropping area from the original image to obtain a front view image of the card. The processing module is also used to extract global semantic features, local visual features, text semantic features and special visual features of the card based on the front view image of the card, and associate the global semantic features, the local visual features, the text semantic features and the special visual features with the card identifier to obtain multi-layer feature data of the card; The processing module is also used to store the multi-layer feature data of the card into a vector database respectively, and perform multi-channel similarity retrieval based on the multi-layer feature data of the card to be identified, and aggregate the multi-channel retrieval results to obtain candidate card data. The processing module is also used to perform visual fine matching processing and special identifier filtering processing on the candidate card data, and to filter the candidate card data according to the visual matching results and special identifier matching results to obtain the filtered candidate card data. The judgment module is used to perform a comprehensive similarity judgment on the filtered candidate card data to obtain the card recognition result, and control the robotic arm to sort the cards to be sorted to the corresponding positions according to the card recognition result.
9. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.
