A medicine code assignment whole-process intelligent monitoring method and system
Patent Information
- Application Number
- CN202611510871.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-28
- Publication Date
- 2026-10-30
AI Technical Summary
当包装单元因输送位姿变化而在图像中发生旋转或平移时,这类位姿变化容易被误判为码缺失或粘贴偏差;同时视觉判定、实际剔除及数据库码状态也可能不同步,易出现视觉判定为不合格但未实际剔除、实际已剔除但数据库状态未同步或判定、剔除与装箱复核结果相互矛盾等数据不同步问题,因此需要以单品赋码信息连续约束图像检测、物理处置和追溯状态的在线监控技术
[0015]本发明实施例中的上述一个或多个技术方案,至少具有如下技术效果之一:
Smart Images

Figure CN123015559A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pharmaceutical packaging traceability and machine vision inspection technology, and in particular to a method and system for intelligent monitoring of the entire process of pharmaceutical coding. Background Technology
[0002] Drug traceability codes are typically printed online or affixed to drug packaging units such as small boxes, aluminum foil, or inner bags. During high-speed transport, the packaging units undergo translation, rotation, vibration, and reflective changes, causing pose changes and grayscale fluctuations in the acquired traceability code images. Currently, the industry mainly relies on two methods to confirm the quality of the coding: one is manual sampling, where operators visually judge whether the traceability code is clear, complete, and correctly positioned; the other is online decoding based on barcode readers or ordinary cameras, using successful decoding or correct decoding content as the only criterion for acceptance, which makes it difficult to simultaneously detect affixing deviations, partial missing parts, deformation, and content mismatches.
[0003] In existing coding and inspection systems, code templates, inspection channel selection, geometric correction, and handling records are typically handled by independent modules or processes. When packaging units rotate or translate in the image due to changes in transport posture, these posture changes can easily be misjudged as missing codes or pasting deviations. Simultaneously, visual judgment, actual rejection, and database code status may be asynchronous, leading to data asynchrony issues such as visually determined non-conforming codes not being actually rejected, actual rejections being made but the database status not being synchronized, or discrepancies between rejection and packing verification results. Therefore, online monitoring technology is needed to continuously constrain image detection, physical handling, and traceability status using individual item coding information. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in related technologies. To this end, this invention provides a method and system for intelligent monitoring of the entire process of drug coding. By using a single-item template as a common reference for channel selection, coordinate correction, and pixel difference, and binding the single-item status determined by the joint anomaly score, the traceability code content of the corrected image, preset coding information, and the single-item status, rejection command, execution feedback, and pre-packaging verification to the same single-item identifier, this invention solves the problems of misjudgment of code status caused by image pose fluctuations under high-speed transportation conditions, as well as the asynchrony of detection, handling, and traceability data.
[0005] This invention provides a method for intelligent monitoring of the entire process of drug coding, comprising: S1: Assign individual product identification and preset coding information to the drug packaging unit, and generate a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. S2: Obtain the image to be tested of the drug packaging unit, convert the image to be tested to the HSV color space, select the detection channel in the HSV color space according to the pre-marked code foreground area and template background area in the single product standard traceability code digital image template, and obtain the detection channel image; S3: Perform rotation and translation correction on the image to be tested and the detection channel image. Calculate the differential mask based on the corrected detection channel image and the corrected image to be tested. Calculate the joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. S4: Determine the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, generate a removal control instruction and send the removal control instruction when the predicted time to reach the removal position is within the execution feedback window. S5: Compare the execution result of the rejection control command with the rejection control command character by character, and write the comparison result and the traceability code content of the item status and the corrected image into the same item traceability record; S6: Read the individual product traceability record before the drug packaging unit enters the outer box, and compare the individual product traceability record with the preset coding information. If the comparison result between the individual product traceability record and the preset coding information is abnormal, packing is prohibited.
[0006] Furthermore, the detection channel is the candidate channel with the largest absolute difference in pixel median values between the foreground region of the code and the background region of the template in the H, S, and V candidate channels of the single-item standard traceability code digital image template.
[0007] Furthermore, rotation and translation corrections are performed on the image to be tested and the image of the detection channel, including: The test image and the detection channel image are subjected to frequency domain transformation and amplitude spectrum logarithmic polar coordinate transformation to obtain a logarithmic polar coordinate graph. Phase-related rotation is performed on the logarithmic polar coordinate graph to obtain rotation correction parameters. The test image and the detection channel image are rotated and corrected according to the rotation correction parameters. The frequency domain transformation of the rotation-corrected test image is performed to obtain the spectrum of the rotation-corrected test image; the frequency domain transformation of the rotation-corrected detection channel image is performed to obtain the spectrum of the rotation-corrected detection channel image. The normalized cross power spectrum is calculated based on the spectrum of the image under test after rotation correction and the spectrum of the detection channel image after rotation correction. The normalized cross-power spectrum is inversely transformed, and the peak position of the inverse transformation result corresponds to the translation correction parameter. The image under test and the detection channel image after rotation correction are translated using translation correction parameters to obtain the corrected image under test and the corrected detection channel image.
[0008] Furthermore, the differential mask is obtained by comparing the absolute value of the pixel difference between the corrected image to be tested and the detection channel image with the detection channel threshold, and the detection channel threshold is determined based on the noise statistics of the template background region.
[0009] Furthermore, the joint anomaly score is calculated based on the traceability code content of the differential mask and the corrected image under test, including: The offset displacement relative to the allowable pasting boundary is calculated by the connected region located outside the code boundary in the differential mask. The offset bit is removed to allow the maximum allowable displacement of the pasting boundary, and the position deviation sub-score is obtained. Divide the area of the differentially connected region within the code foreground region by the area of the code foreground region to obtain the integrity sub-score; Read the traceability code content of the corrected image to be tested; when the parsed traceability code content is consistent with the preset code information and the verification bit verification passes, the content difference sub-score is 0, otherwise it is 1; The location deviation sub-score, integrity sub-score, and content difference sub-score are weighted and fused to obtain a joint anomaly score.
[0010] Furthermore, the status of a single item includes release, rejection, and pending review. When all inputs are valid, the combined anomaly score does not exceed the preset single item handling threshold, and the parsed content of the traceability code in the corrected image is consistent with the preset coding information, the status of the single item is release. When all inputs are valid but the combined anomaly score exceeds the preset single-item handling threshold, or when the parsed content of the traceability code in the corrected image is inconsistent with the preset coding information, the single item status is to be removed. When the location deviation sub-score, integrity sub-score, or content difference sub-score cannot be calculated or eliminated due to insufficient accessibility caused by image quality or template matching failure, the item status is "pending review".
[0011] Furthermore, the reachability of the removal is determined based on the predicted time of arrival at the removal position, the response time of the removal execution mechanism, and the execution window; A time when the predicted arrival time at the removal point is no earlier than the response time of the removal execution mechanism and no later than the end time of the execution window is considered a removal reachable. If the predicted arrival time at the rejection point is earlier than the rejection execution mechanism's response time but later than the execution window's end time, then rejection is considered unreachable. The predicted arrival time at the rejection position is estimated based on the encoder position sequence and a unified timestamp to determine the current conveying speed, and is obtained by dividing the difference between the current encoder position and the rejection position by the current conveying speed. The encoder position sequence is obtained by the conveyor line encoder at a fixed sampling period.
[0012] Furthermore, the rejection control command includes a single item identifier, a command identifier, a rejection terminal selection, an execution amplitude generated by the currently active rejection terminal configuration, an execution time, a duration, and a flow path pointing to the scrap channel.
[0013] Furthermore, the execution feedback window starts at the execution time of the rejection control command and ends at the predicted time when the corresponding drug packaging unit leaves the rejection position after the duration of the rejection control command ends.
[0014] This invention also provides a fully intelligent monitoring system for the entire process of drug coding, used to execute the above-mentioned fully intelligent monitoring method for the entire process of drug coding, including: The template generation module assigns individual product identification and preset coding information to the drug packaging unit, and generates a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. The channel selection module acquires the image to be tested from the drug packaging unit, converts the image to be tested to the HSV color space, and selects the detection channel in the HSV color space according to the pre-marked code foreground area and template background area in the single product standard traceability code digital image template to obtain the detection channel image. An anomaly score calculation module performs rotation and translation correction on the image to be tested and the detection channel image, calculates a differential mask based on the corrected detection channel image and the corrected image to be tested, and calculates a joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. The joint determination module determines the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, a removal control instruction is generated, and the removal control instruction is sent when the predicted time of reaching the removal position is within the execution feedback window. The feedback comparison module compares the execution result of the rejection control command with the rejection control command character by character, and writes the comparison result and the traceability code content of the single item status and the corrected image into the same single item traceability record. The pre-packaging verification module reads the individual product traceability record before the drug packaging unit enters the outer box and compares the individual product traceability record with the preset coding information. If the comparison result between the individual product traceability record and the preset coding information is abnormal, packing is prohibited.
[0015] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects: This invention solves the problems of code status misjudgment caused by image pose fluctuations under high-speed transportation conditions and the asynchrony of detection, handling and traceability data by using a single-item template as a common reference for channel selection, coordinate correction and pixel difference, and binding the single-item status, rejection command, execution feedback and pre-packaging review determined by the joint anomaly score, the traceability code content of the corrected image, the preset coding information, and the single-item status, rejection command, execution feedback and pre-packaging review to the same single-item identifier.
[0016] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating a fully intelligent monitoring method for drug coding provided by the present invention.
[0019] Figure 2 This is a schematic diagram of the structure of a fully intelligent monitoring system for drug coding provided by the present invention.
[0020] Figure label: 101. Template generation module; 102. Channel selection module; 103. Anomaly score calculation module; 104. Joint judgment module; 105. Feedback comparison module; 106. Pre-packaging review module. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below. 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. The following embodiments are used to illustrate this invention but cannot be used to limit the scope of this invention.
[0022] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0023] The following is combined Figures 1 to 2 This invention describes a method and system for intelligent monitoring of the entire process of drug coding.
[0024] The production line of this invention includes a coding device, a high-speed linear scan camera, a conveying mechanism, a photoelectric trigger, an encoder, an edge computing controller, a rejection execution mechanism, a barcode scanner, and a production management system. After the coding device completes printing or pasting, the conveying mechanism continuously moves the product forward, and the photoelectric trigger triggers the high-speed linear scan camera to acquire images. The edge computing controller communicates with the production management system, the rejection execution mechanism, and the barcode scanner, and converts the camera trigger time and encoder pulses to a unified time base for the edge computing controller.
[0025] like Figure 1 As shown, a method for intelligent monitoring of the entire process of drug coding includes: S1: Assign individual product identification and preset coding information to the drug packaging unit, and generate a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. Before template generation, the production management system assigns individual product identifiers and preset coding information to each pharmaceutical packaging unit. The individual product identifiers are written to the template cache, test image records, rejection command objects, execution feedback records, and traceability records. If an individual product identifier is duplicated, missing, or inconsistent with the batch number, production date, or packaging level, automatic release is canceled and a pending review and handling record is generated.
[0026] Before automatic detection, a versioned reference configuration is established. The template reference configuration includes product identifier, batch number, production date, packaging level, traceability code content, code system, error correction level, preset layout, code foreground area, template background area, code boundary, and allowed pasting boundary; the registration reference configuration includes template detection channel image, minimum modulus of effective frequency points, and peak confidence threshold; the judgment reference configuration includes background noise statistics rules, channel threshold, product disposal threshold, and weights of three sub-scores; the elimination reference configuration includes elimination end selection and execution amplitude mapping, execution amplitude unit and safety range, elimination execution mechanism response time, and execution window. The minimum contrast and peak confidence threshold are taken as the lower limit of the current version of the confirmed samples, the product disposal threshold is taken as the upper limit of the confirmed sample joint anomaly score, the channel threshold is taken as the upper limit of the template background noise statistics plus the current version tolerance, and the minimum modulus of effective frequency points is taken as the near-zero denominator rejection limit under camera calibration; when the same configuration item has both a lower limit and an upper limit, the lower limit is not greater than the upper limit, and if the order is not met, missing, out of bounds, or the version is inconsistent, it will be transferred to pending review. All thresholds and mappings are frozen with the configuration version. The above configurations are reviewed and a new version is generated after batch change, code system change, camera recalibration, or template layout change; if any configuration is missing, version is inconsistent, or invalid, the current item will not be automatically released and will be put into a pending review state.
[0027] S2: Obtain the image to be tested of the drug packaging unit, convert the image to be tested to the HSV color space, select the detection channel in the HSV color space according to the pre-marked code foreground area and template background area in the single product standard traceability code digital image template, and obtain the detection channel image; A high-speed linear array camera acquires continuous row images of the drug packaging unit after being triggered by a photoelectric trigger, and stitches them together to form the image to be tested based on the photoelectric trigger time and encoder pulses; Each image to be tested carries a single item identifier, camera acquisition time, converted unified timestamp, and template version; the edge computing controller refuses to include images, templates, and traceability information with different single item identifiers or different template versions in the same judgment.
[0028] The image to be tested is converted to the HSV color space. The BGR pixel components of the image to be tested are normalized to the 0-1 value range. The maximum value max and minimum value min of the B, G and R components of each pixel are obtained, and the difference delta between the two is calculated. The maximum value (max) is directly used as the brightness (V). When max is not zero, the ratio of delta to max is taken as the saturation S; when max is zero, the saturation S is taken as 0. When delta is not equal to 0, the hue H is calculated based on the color channel to which the maximum value belongs, and delta equals 0. When delta equals 0, it means that the pixel is grayscale, so the hue H is set to 0. Then, the hue H, saturation S, and lightness V are mapped and scaled to the value range of an 8-bit image, completing the conversion of the image under test from the BGR color space to the HSV color space, resulting in an HSV image containing three channels: H, S, and V.
[0029] The code foreground area and template background area are read from the digital image template of the same single product standard traceability code. The detection channel is the candidate channel with the largest absolute difference in pixel midpoint values between the code foreground area and the template background area in the H, S, and V candidate channels of the single product standard traceability code digital image template. The calculation expression for the detection channel is: in, For testing channels, As a candidate channel, For hue candidate channels, Candidate channels for saturation For brightness candidate channels, The median value of the region pixels in the candidate channel. Foreground area of template code, This is the template background area. The value of the independent variable that makes the function reach its maximum value.
[0030] and Marked by the same single item template, for each Calculate separately The maximum value is selected after execution. ,Will Write this into the product's inspection record.
[0031] S3: Perform rotation and translation correction on the image to be tested and the detection channel image. Calculate the differential mask based on the corrected detection channel image and the corrected image to be tested. Calculate the joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. S31: Perform rotation and translation correction on the image to be tested and the detection channel image to obtain the corrected image to be tested and the corrected detection channel image; S311: Perform frequency domain transformation and amplitude spectrum logarithmic polar coordinate transformation on the image under test and the detection channel image to obtain a logarithmic polar coordinate graph. Perform phase-related rotation on the logarithmic polar coordinate graph to obtain rotation correction parameters. Perform rotation correction on the image under test and the detection channel image according to the rotation correction parameters. The position of the correlation peak is obtained by phase correlation operation on the logarithmic polar plot, and the rotation angle is determined by the position of the correlation peak as the rotation correction parameter.
[0032] S312: Perform frequency domain transformation on the rotated-corrected test image to obtain the spectrum of the rotated-corrected test image; perform frequency domain transformation on the rotated-corrected detection channel image to obtain the spectrum of the rotated-corrected detection channel image; S313: Calculate the normalized cross-power spectrum based on the rotation-corrected spectrum of the image under test and the rotation-corrected spectrum of the detection channel image. The expression for calculating the normalized cross-power spectrum is as follows: in, For the normalized cross-power spectrum, This is the spectrum of the detection channel image after rotation correction. The spectrum of the image under test after rotation correction is a dimensionless complex frequency domain quantity.
[0033] Only frequencies whose cross-power spectrum magnitude is greater than the minimum effective frequency magnitude are included in the normalization calculation.
[0034] S314: Perform inverse transformation on the normalized cross power spectrum, and the peak position of the inverse transformation result corresponds to the translation correction parameter; Peak confidence is calculated by the ratio of the peak value of the main peak to the peak value of the largest sidelobe outside the main peak of the inverse transform result. Under the current template version, camera calibration and transport speed conditions, the ratio is calculated using confirmed samples and the peak confidence threshold is determined. When there are insufficient effective frequency points, the ratio is lower than the peak confidence threshold, or the peak value of the main peak or side lobe is uncertain, the correction result is marked as pending review.
[0035] S315: Perform translation correction on the rotated image under test and the rotated detection channel image using translation correction parameters to obtain the corrected image under test and the corrected detection channel image.
[0036] S32: Calculate the differential mask based on the corrected detection channel image and the corrected image to be tested; The differential mask is obtained by comparing the absolute value of the pixel difference between the corrected image to be tested and the detection channel image with a detection channel threshold. The detection channel threshold is determined based on the noise statistics of the template background region, and the calculation expression is: in, for Differential mask at the location, The pixel values of the image under test after correction. To detect the pixel values of the channel image, To detect channel thresholds, As an indicator function, 1(∙) takes the value 1 if the condition is true, and 0 otherwise. Take either 0 or 1.
[0037] and They must be in the same template coordinate system and use the same pixel scale.
[0038] S33: Calculate the joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested; The offset displacement relative to the allowable pasting boundary is calculated through the connected region located outside the code boundary in the differential mask; the offset bit is removed to obtain the maximum allowable displacement of the allowable pasting boundary, and the position deviation sub-score is obtained. When the position deviation sub-score exceeds 1, it is taken as 1. The offset displacement is the shortest distance from the centroid of the differentially connected region outside the code boundary to the allowed pasting boundary. The code boundary, the allowed pasting boundary, and the maximum allowable displacement of the allowed pasting boundary are pre-marked by the single-item standard traceability code digital image template; The integrity sub-score is obtained by dividing the area of the differentially connected region within the code foreground region by the area of the code foreground region; the integrity sub-score ranges from 0 to 1. Read the traceability code content of the corrected image to be tested; when the parsed traceability code content is consistent with the preset code information and the verification bit verification passes, the content difference sub-score is 0, otherwise it is 1; The location deviation sub-score, integrity sub-score, and content difference sub-score are weighted and fused to obtain the joint anomaly score; the calculation expression for the joint anomaly score is as follows: in, For the joint anomaly score, As the position deviation weight, For the positional deviation sub-score, For integrity weight, For integrity sub-score, Weighting based on content differences Sub-scores for content differences; , and All are normalized to the dimensionless range of 0 to 1. , and All values are non-negative and sum to 1, determined by least squares method from confirmed samples under the same packaging material, coding system and conveying speed conditions.
[0039] 0≤ ≤1、0≤ ≤1, Take 0 or 1, 0≤ ≤1.
[0040] The pasting status is determined based on the area of the connected region near the template's allowable pasting boundary, boundary displacement, and edge continuity of the differential mask. When the pasting status is incomplete or deviated, an alarm signal is output, and the phase correlation peak value, joint anomaly score, and pasting status are written into the production management system as a record basis for operators to adjust the dock position, printing pressure, pasting mechanism timing, or conveyor speed. This alarm is only used for recording and manual adjustment prompts and does not automatically generate the aforementioned adjustment commands.
[0041] S4: Determine the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, generate a removal control instruction and send the removal control instruction when the predicted time to reach the removal position is within the execution feedback window. The status of a single item includes release, rejection, and pending review. When all inputs are valid, the combined anomaly score does not exceed the preset single item handling threshold, and the parsed content of the traceability code in the corrected image is consistent with the preset coding information, the status of the single item is release. When all inputs are valid but the combined anomaly score exceeds the preset single-item handling threshold, or when the parsed content of the traceability code in the corrected image is inconsistent with the preset coding information, the single item status is to be removed. When the position deviation sub-score, integrity sub-score, or content difference sub-score cannot be calculated or is removed due to image quality or template matching failure, the item status is pending review.
[0042] In the release state, the controller writes the item traceability record as pending review before packaging; in the rejection state and when rejection is reachable, the controller generates a rejection control command; in the pending review state, the controller marks the item traceability record as pending review and prohibits automatic release and automatic rejection.
[0043] Removal reachability is determined based on the predicted arrival time at the removal point, the response time of the removal execution agency, and the execution window.
[0044] The controller estimates the current conveying speed based on the encoder position sequence and its unified timestamp, and divides the difference between the current encoder position and the rejection position by the current conveying speed to obtain the predicted time of arrival at the rejection position; The predicted arrival time at the rejection point is not generated when the current conveying speed cannot be estimated or is not positive. A time when the predicted arrival time at the removal point is no earlier than the response time of the removal execution mechanism and no later than the end time of the execution window is considered a removal reachable. If the predicted arrival time at the rejection point is earlier than the rejection execution mechanism's response time but later than the execution window's end time, then rejection is considered unreachable. If the item is unreachable, no rejection control command is sent; instead, a single-item traceability record is generated and marked as pending review.
[0045] The rejection control command includes a single item identifier, a command identifier, a rejection terminal selection, an execution amplitude generated by the currently active rejection terminal configuration, an execution time, a duration, and a flow path pointing to the scrap channel.
[0046] The controller selects the currently active rejection end to execute the amplitude mapping configuration, reads the execution amplitude, its unit, and safety range; the rejection command object includes the item identifier, command identifier, rejection end selection, execution amplitude, execution time, execution feedback confirmation or duration expiration as the end condition, the flow path pointing to the waste channel, and the rejection execution mechanism execution end. If the mapping is missing, the amplitude exceeds the limit, or the execution end status is unavailable, the automatic rejection of the item is canceled and a pending review and disposal record is generated.
[0047] The execution feedback window starts at the execution time of the rejection control command and ends at the predicted time when the corresponding drug packaging unit leaves the rejection position after the duration of the rejection control command ends.
[0048] S5: Compare the execution result of the rejection control command with the rejection control command character by character, and write the comparison result and the traceability code content of the item status and the corrected image into the same item traceability record; The execution result of the control command is removed, which includes the item identifier, command identifier, feedback time, and actual execution status.
[0049] The controller compares the item identifier and command identifier in the rejection control command and the execution result of the rejection control command character by character, and writes the image address, judgment result, rejection command execution status and traceability code status into the same item traceability record.
[0050] If there is inconsistent labeling, duplicate feedback, late feedback, feedback outside the window, missing feedback, or if the actual execution status does not conform to the rejection control instruction, the automatic processing shall be stopped immediately and the system shall be transferred to the pending review status. The traceability code status shall be updated to the pending review or rejection execution unconfirmed status.
[0051] When multiple drug packaging units compete for the same rejection actuator, the controller sorts them according to the predicted arrival time at the rejection position and establishes mutual exclusion for each execution window using a command identifier. When the execution window of a later-arriving item overlaps with an already occupied window, the automatic rejection control command for the later-arriving item is canceled, it is not entered into the waiting execution queue, and an item traceability record is generated and marked as pending review. The execution window is released after the occupied command is completed, canceled, or times out.
[0052] The image address to be tested, template version, detection channel, correction parameters, differential mask, joint anomaly score, comparison result of the parsed content of the traceability code of the corrected image with the preset coding information, single item identifier, command identifier, traceability code status, rejection control command and execution status are bound and written into the same single item traceability record.
[0053] Successful execution is recorded as "removed"; failure or unconfirmed execution is recorded as "pending review" and not written as "qualified".
[0054] S6: Before entering the outer box, read the individual item traceability record and compare the individual item traceability record with the preset coding information. If the comparison result is abnormal, packing is prohibited.
[0055] Before the inner bag is filled and the item is placed into the outer carton, the individual item traceability code is read using a wired or wireless scanner. This code is then compared with the preset coding information, online detection status, and rejection execution status in the same individual item traceability record under a unified time benchmark. If the scanned content is inconsistent, or if the record is in an abnormal, pending review, rejection execution failed, or unconfirmed state, the pre-packaging review module prohibits packing and updates the individual item traceability record to a prohibited packing state. If the review passes, the record is updated to a permitted packing state. Packing is also prohibited and manual review is initiated if the pre-packaging scanner cannot read the code, the individual item identification is inconsistent, or the traceability record is missing.
[0056] Before the drug packaging unit enters the outer box, the traceability code content is read again and compared with the single product traceability record and preset code information. If the comparison is abnormal, pending review, rejection execution fails, or is not confirmed, packing is prohibited and a packing prohibition disposal record is generated.
[0057] like Figure 2 As shown, a fully intelligent monitoring system for the entire process of drug coding is used to execute the aforementioned fully intelligent monitoring method for drug coding, including: The template generation module 101 assigns individual product identification and preset coding information to the drug packaging unit, and generates a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. The channel selection module 102 acquires the image to be tested from the drug packaging unit, converts the image to be tested to the HSV color space, selects the detection channel in the HSV color space according to the code foreground area and template background area pre-marked in the single product standard traceability code digital image template, and obtains the detection channel image. The anomaly score calculation module 103 performs rotation and translation correction on the image to be tested and the detection channel image, calculates the differential mask based on the corrected detection channel image and the corrected image to be tested, and calculates the joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. The joint judgment module 104 determines the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, a removal control instruction is generated, and the removal control instruction is sent when the predicted time to reach the removal position is within the execution feedback window. The feedback comparison module 105 compares the execution result of the rejection control command with the rejection control command character by character, and writes the comparison result and the traceability code content of the single item status and the corrected image into the same single item traceability record. The pre-packaging verification module 106 reads the individual product traceability record before the drug packaging unit enters the outer box and compares the individual product traceability record with the preset coding information. If the comparison result between the individual product traceability record and the preset coding information is abnormal, packing is prohibited.
[0058] Through the collaborative work of the above modules, the single-item template is used as a common reference for channel selection, coordinate correction, and pixel difference. The single-item status, rejection command, execution feedback, and pre-packaging review determined by the joint anomaly score, the traceability code content of the corrected image, the preset coding information, and the rejection accessibility determination are all bound to the same single-item identifier. This solves the problems of code status misjudgment caused by image pose fluctuations under high-speed transportation conditions, as well as the asynchrony of detection, handling, and traceability data.
[0059] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention 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 of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for intelligent monitoring of the entire process of drug coding, characterized in that, include: S1: Assign individual product identification and preset coding information to the drug packaging unit, and generate a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. S2: Obtain the image to be tested of the drug packaging unit, convert the image to be tested to the HSV color space, select the detection channel in the HSV color space according to the pre-marked code foreground area and template background area in the single product standard traceability code digital image template, and obtain the detection channel image; S3: Perform rotation and translation correction on the image to be tested and the detection channel image. Calculate the differential mask based on the corrected detection channel image and the corrected image to be tested. Calculate the joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. S4: Determine the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, generate a removal control instruction and send the removal control instruction when the predicted time to reach the removal position is within the execution feedback window. S5: Compare the execution result of the rejection control command with the rejection control command character by character, and write the comparison result and the traceability code content of the item status and the corrected image into the same item traceability record; S6: Read the individual product traceability record before the drug packaging unit enters the outer box, and compare the individual product traceability record with the preset coding information. If the comparison result between the individual product traceability record and the preset coding information is abnormal, packing is prohibited.
2. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, The detection channel is the candidate channel with the largest absolute difference in pixel median values between the foreground region of the code and the background region of the template in the H, S, and V candidate channels of the single-item standard traceability code digital image template.
3. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, Rotation and translation correction of the image under test and the image of the detection channel includes: The test image and the detection channel image are subjected to frequency domain transformation and amplitude spectrum logarithmic polar coordinate transformation to obtain a logarithmic polar coordinate graph. Phase-related rotation is performed on the logarithmic polar coordinate graph to obtain rotation correction parameters. The test image and the detection channel image are rotated and corrected according to the rotation correction parameters. The frequency domain transformation of the rotation-corrected test image is performed to obtain the spectrum of the rotation-corrected test image; the frequency domain transformation of the rotation-corrected detection channel image is performed to obtain the spectrum of the rotation-corrected detection channel image. The normalized cross power spectrum is calculated based on the spectrum of the image under test after rotation correction and the spectrum of the detection channel image after rotation correction. The normalized cross-power spectrum is inversely transformed, and the peak position of the inverse transformation result corresponds to the translation correction parameter. The image under test and the detection channel image after rotation correction are translated using translation correction parameters to obtain the corrected image under test and the corrected detection channel image.
4. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, The differential mask is obtained by comparing the absolute value of the pixel difference between the corrected image to be tested and the detection channel image with the detection channel threshold, and the detection channel threshold is determined based on the noise statistics of the template background area.
5. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, The joint anomaly score is calculated based on the traceability code content of the differential mask and the corrected image under test, including: The offset displacement relative to the allowable pasting boundary is calculated by the connected region located outside the code boundary in the differential mask. The offset bit is removed to allow the maximum allowable displacement of the pasting boundary, and the position deviation sub-score is obtained. Divide the area of the differentially connected region within the code foreground region by the area of the code foreground region to obtain the integrity sub-score; Read the traceability code content of the corrected image to be tested; when the parsed traceability code content is consistent with the preset code information and the verification bit verification passes, the content difference sub-score is 0, otherwise it is 1; The location deviation sub-score, integrity sub-score, and content difference sub-score are weighted and fused to obtain a joint anomaly score.
6. The intelligent monitoring method for the entire process of drug coding according to claim 5, characterized in that, The status of a single item includes release, rejection, and pending review. When all inputs are valid, the combined anomaly score does not exceed the preset single item handling threshold, and the parsed content of the traceability code in the corrected image is consistent with the preset coding information, the status of the single item is release. When all inputs are valid but the combined anomaly score exceeds the preset single-item handling threshold, or when the parsed content of the traceability code in the corrected image is inconsistent with the preset coding information, the single item status is to be removed. When the position deviation sub-score, integrity sub-score, or content difference sub-score cannot be calculated or is removed due to image quality or template matching failure, the item status is pending review.
7. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, The reachability of the removal is determined based on the predicted time of arrival at the removal position, the response time of the removal execution mechanism, and the execution window. A time when the predicted arrival time at the removal point is no earlier than the response time of the removal execution mechanism and no later than the end time of the execution window is considered a removal reachable. If the predicted arrival time at the rejection point is earlier than the rejection execution mechanism's response time but later than the execution window's end time, then rejection is considered unreachable. The predicted arrival time at the rejection position is estimated based on the encoder position sequence and a unified timestamp to determine the current conveying speed, and is obtained by dividing the difference between the current encoder position and the rejection position by the current conveying speed. The encoder position sequence is obtained by the conveyor line encoder at a fixed sampling period.
8. The intelligent monitoring method for the entire process of drug coding according to claim 1, characterized in that, The rejection control command includes a single item identifier, a command identifier, a rejection terminal selection, an execution amplitude generated by the currently active rejection terminal configuration, an execution time, a duration, and a flow path pointing to the scrap channel.
9. The intelligent monitoring method for the entire process of drug coding according to claim 8, characterized in that, The execution feedback window starts at the execution time of the rejection control command and ends at the predicted time when the corresponding drug packaging unit leaves the rejection position after the duration of the rejection control command ends.
10. A fully intelligent monitoring system for the entire process of drug coding, characterized in that, To implement the intelligent monitoring method for the entire process of drug coding as described in any one of claims 1 to 9, comprising: The template generation module assigns individual product identification and preset coding information to the drug packaging unit, and generates a digital image template of the standard traceability code for the individual product based on the preset coding information and preset format. The channel selection module acquires the image to be tested from the drug packaging unit, converts the image to be tested to the HSV color space, and selects the detection channel in the HSV color space according to the pre-marked code foreground area and template background area in the single product standard traceability code digital image template to obtain the detection channel image. An anomaly score calculation module performs rotation and translation correction on the image to be tested and the detection channel image, calculates a differential mask based on the corrected detection channel image and the corrected image to be tested, and calculates a joint anomaly score based on the traceability code content of the differential mask and the corrected image to be tested. The joint determination module determines the status of a single item based on the joint anomaly score, the traceability code content of the corrected image to be tested, the preset coding information, and the accessibility of removal. When the status of a single item is removal and removal is accessible, a removal control instruction is generated, and the removal control instruction is sent when the predicted time of reaching the removal position is within the execution feedback window. The feedback comparison module compares the execution result of the rejection control command with the rejection control command character by character, and writes the comparison result and the traceability code content of the single item status and the corrected image into the same single item traceability record. The pre-packaging verification module reads the individual product traceability record before the drug packaging unit enters the outer box and compares the individual product traceability record with the preset coding information. If the comparison result between the individual product traceability record and the preset coding information is abnormal, packing is prohibited.
