Lens outer wall two-dimensional code detection method and device, storage medium and equipment
By using a coaxial main lens in conjunction with a tilted ring mirror, static full-circumference synchronous imaging of the QR code on the outer wall of the lens is achieved, which solves the problems of wear and low efficiency of mechanical rotation detection, improves the stability and efficiency of detection, and reduces costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN ZHUOJIAN INTELLIGENT MANUFACTURING CO LTD
- Filing Date
- 2026-04-07
- Publication Date
- 2026-07-10
Smart Images

Figure CN122366480A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial vision inspection technology, and in particular to a method, apparatus, storage medium and equipment for detecting QR codes on the outer wall of a lens. Background Technology
[0002] The QR code on the outer wall of the cylindrical lens is the core identifier for product traceability throughout the entire production line. Currently, mainstream detection methods typically rely heavily on mechanical rotation mechanisms, requiring motors or other drive components to rotate the lens under test or the scanning head, thereby scanning and stitching together the complete QR code image segment by segment.
[0003] However, this traditional mechanical rotation inspection method has significant inherent drawbacks. First, under long-term, high-frequency operation, rotating components are prone to mechanical wear, causing the positioning accuracy of the equipment to decrease over time, leading to workpiece misalignment and ultimately resulting in missed or incorrect QR code recognition, severely compromising the accuracy and reliability of product traceability. Second, this "segment-by-segment scanning plus image stitching" process is relatively cumbersome and time-consuming, directly limiting overall inspection efficiency and failing to meet the demands of modern production lines for high-speed, high-volume automated inspection. Furthermore, the complex rotating mechanism increases equipment purchase costs and requires regular maintenance to address wear issues, further raising the operating costs of the production line. Summary of the Invention
[0004] This application provides a method, device, storage medium, and program product for detecting QR codes on the outer wall of a lens, which is used to solve at least one of the above-mentioned technical problems.
[0005] In a first aspect, embodiments of this application provide a method for detecting QR codes on the outer wall of a lens, comprising: controlling a coaxial main lens to perform a single exposure to obtain an annular stretched original image of a cylindrical lens under test; the annular stretched original image is formed by the image of the circumferential outer wall of the cylindrical lens under test being reflected once by a continuous conical reflecting surface of an inclined annular mirror to the imaging target surface of the coaxial main lens; identifying the inner and outer annular contours in the annular stretched original image, and defining a double-ring region of interest containing a target QR code based on the inner and outer annular contours; extracting the annular image within the double-ring region of interest, and performing a reverse mapping reconstruction from polar coordinates to rectangular coordinates on the annular image to unfold the annular image into a planar image; locating the boundary of the target QR code in the planar image, and cropping the target QR code image from the planar image based on the located boundary for information recognition.
[0006] Secondly, embodiments of this application provide a lens outer wall QR code detection device, comprising: a coaxial main lens having an imaging target surface; the principal optical axis of the coaxial main lens is configured to be collinear with the central axis of the cylindrical lens under test; a tilted annular reflector having a continuous conical reflective surface, the tilted annular reflector being located in front of the entrance pupil of the coaxial main lens, and the central axis of the tilted annular reflector being arranged collinear with the principal optical axis; wherein, the interior of the tilted annular reflector defines a detection space for accommodating the cylindrical lens under test, the continuous conical reflective surface surrounding the detection space to reflect and converge an image of the circumferential outer wall of the cylindrical lens under test located in the detection space onto the imaging target surface in one go, so that the coaxial main lens can acquire an annular stretched original image containing the full circumferential information of the target QR code through a single exposure; and an image processing module, communicatively connected to the coaxial main lens, configured to receive the annular stretched original image and execute the lens outer wall QR code detection method as described above, to locate and identify the target QR code in the reconstructed planar image.
[0007] Thirdly, embodiments of this application provide a storage medium storing one or more programs including execution instructions, which can be read and executed by electronic devices (including but not limited to computers, servers, or network devices) to perform the steps of the methods described above in this application.
[0008] Fourthly, a computer device is provided, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the method described above in this application.
[0009] Fifthly, embodiments of this application also provide a computer program product, the computer program product including a computer program stored on a storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the steps of the above-described method.
[0010] The beneficial effects of the embodiments of this application are as follows: By employing a tilted ring-shaped reflector in conjunction with a coaxial main lens, the QR code information on the circumferential outer wall of the cylindrical lens under test can be transformed into a single-exposure, stretched ring-shaped original image. This transforms the traditional segment-by-segment scanning acquisition method, which relies on a mechanical rotation mechanism, into a static, full-circumference synchronous imaging method. Furthermore, by combining inner and outer ring contour recognition, double-ring region of interest delineation, and reverse mapping reconstruction from polar coordinates to rectangular coordinates of the ring image, effective unfolding and regularized representation of the cylindrical curved surface QR code image are achieved. Boundary positioning and cropping recognition in the planar image enhance the targeting accuracy of target extraction. This not only reduces the adverse effects of mechanical wear, positioning drift, and image stitching errors on the detection results, improving the stability and recognition accuracy of QR code detection, but also simplifies the processing flow, improves detection efficiency, and reduces equipment maintenance and operating costs. It is more suitable for lens outer wall QR code detection scenarios in high-cycle automated production lines. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 A flowchart illustrating an example of a lens outer wall QR code detection method according to an embodiment of this application is shown; Figure 2 A schematic diagram of a lens outer wall QR code optical imaging system according to an embodiment of this application is shown; Figure 3 An example of a stretched annular original image containing full-text QR code information obtained according to an embodiment of this application is shown; Figure 4 A flowchart illustrating an example of identifying and delineating a double-ring region of interest containing a target QR code in a method according to an embodiment of this application is provided. Figure 5 This illustration shows the actual processing effect of identifying and delineating the double-ring region of interest according to an embodiment of this application; Figure 6 A schematic diagram of a ring-shaped image containing only the target QR code, extracted after a double-ring masking operation according to an embodiment of this application, is shown. Figure 7 A schematic diagram of the delineation and masking process of the double-ring region of interest according to an embodiment of this application is shown; Figure 8 A flowchart illustrating an example of unfolding a ring-shaped image into a planar image according to an embodiment of this application is shown. Figure 9This illustration shows an example of reconstructing a circular image into a planar image according to an embodiment of this application; Figure 10 An example target QR code image cropped from a planar image according to an embodiment of this application is shown; Figure 11 A structural block diagram of an example of a lens outer wall QR code detection device according to an embodiment of this application is shown; Figure 12 A schematic diagram of the three-dimensional solid structure of a lens outer wall QR code optical imaging system according to an embodiment of this application is shown; Figure 13 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.
[0014] It should also be noted that, in this document, the terms "comprising" or "including" include not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0015] It should be noted that high-speed traceability inspection of product markings is crucial in automated production lines for cylindrical lenses in automotive, security, and consumer electronics industries. Current technologies typically require specialized positioning structures, meaning the lens under test must be precisely fixed to a specific rotating station during operation. This mechanical station-based operation mode demands that the scanning head precisely coordinate and synchronously acquire images of the outer wall from different angles simultaneously with the rotation mechanism's activation. Because this process heavily relies on rigid physical limits and electromechanical synchronization control, the adaptability of the inspection system to different product specifications is extremely limited. Furthermore, the complex clamping and positioning actions themselves constitute time consumption, further exacerbating the efficiency bottleneck in high-volume production, and consistently failing to truly meet the industry's urgent expectations for efficient, stable, and low-cost inspection solutions.
[0016] It should be understood that the above description of the relevant technologies is intended only to help the public better understand the inventive spirit and motivation of this application, and is not intended to limit this application. Furthermore, the technical solutions described in the above-mentioned relevant technologies are not prior art, and may also be undisclosed technical solutions, such as those under research or in the laboratory stage.
[0017] The technical solutions in this application, including the collection, storage, use, processing, transmission, provision, and disclosure of users' personal information, comply with relevant laws and regulations and do not violate public order and good morals.
[0018] Figure 1 A flowchart illustrating an example of a lens outer wall QR code detection method according to an embodiment of this application is shown. This method effectively replaces the traditional mechanical rotation detection mode through a hardware and software collaborative single imaging and algorithm correction framework.
[0019] Regarding the execution subject of the method in the embodiments of this application, it can be any controller or processor with computing or processing capabilities. In some examples, the method in the embodiments of this application can be integrated into an electronic device or terminal through software, hardware, or a combination of software and hardware, and the type of terminal or electronic device can be diverse, such as an industrial control computer, an embedded vision processing terminal, an industrial inspection equipment, an edge computing device, or other intelligent devices with image acquisition and image processing capabilities. Exemplarily, the execution subject of the method in the embodiments of this application can be an industrial vision controller, image processor, or machine vision inspection platform integrated into a QR code detection system on the outer wall of a lens, used to control the coaxial main lens to complete image acquisition, and perform contour recognition, region of interest extraction, coordinate mapping reconstruction, and QR code recognition on the acquired annular stretched original image.
[0020] like Figure 1 As shown, in step S110, the coaxial main lens is controlled to perform a single exposure to obtain the annular stretched original image of the cylindrical lens under test. Here, the annular stretched original image is formed by the image of the circumferential outer wall of the cylindrical lens under test being reflected once by the continuous conical reflecting surface of the tilted annular mirror to the imaging target surface of the coaxial main lens.
[0021] Here, this application no longer employs the image acquisition method of driving the workpiece by a motor or scanning segment by segment with a camera. Instead, it achieves one-time acquisition of information about the circumferential outer wall of the cylindrical lens under test through optical path design. Specifically, the coaxial main lens and the tilted ring mirror are positioned opposite each other, with the cylindrical lens under test located in the inner region of the tilted ring mirror. During the test, the coaxial main lens is controlled to perform a single exposure. During this exposure, image information from different positions of the circumferential outer wall of the cylindrical lens under test is simultaneously projected onto the continuous conical reflective surface of the tilted ring mirror. After being turned by the reflective surface, the image enters the imaging path of the coaxial main lens, ultimately forming a ring-shaped stretched original image containing the overall information of the circumferential outer wall of the cylindrical lens under test on the imaging target surface.
[0022] The above method allows for the acquisition of the overall imaging result of the outer wall of the cylindrical lens under test within a single frame image, providing a unified data foundation for subsequent region extraction and geometric unfolding. Compared to detection methods that rely on mechanical rotation and multiple sampling, this approach shortens the image acquisition cycle and reduces the adverse effects caused by multiple acquisitions, positional deviations, or fluctuations in mechanical operating conditions, thereby improving the stability and continuity of the detection process.
[0023] Figure 2 A schematic diagram of a lens outer wall QR code optical imaging system according to an embodiment of this application is shown.
[0024] like Figure 2 As shown, the optical imaging system mainly consists of a coaxial main lens, a tilting ring mirror, and a cylindrical lens under test. The tilting ring mirror has a fixed angle, and its central axis (the axis containing the center of the lens) is collinear with the principal optical axis of the coaxial main lens. In the actual testing workflow, the cylindrical lens under test is placed vertically at the inner center of the tilting ring mirror to ensure that images from all angles of the outer circumference of the cylindrical lens under test can be reflected by the mirror to the coaxial main lens.
[0025] Specifically, the tilted ring mirror used in this application is a continuous conical mirror, rather than a frustum-shaped structure composed of multiple plane mirrors. The core design of this tilted ring mirror lies in its smoothly transitioning continuous ring-shaped reflecting surface, which enables the redirection of the spatial light path. That is, the image of the side wall of the cylindrical lens under test, which is distributed in a ring, is seamlessly converged onto the imaging target surface of the coaxial main lens through a single reflection. It should be emphasized that this tilted ring mirror does not additionally perform physical correction of image distortion. The image stretching distortion caused by optical reflection will be eliminated in subsequent data processing using a polar coordinate correction algorithm.
[0026] Furthermore, such as Figure 2As indicated by "Min 18°" and "Max 35°", this optical imaging system defines a specific effective field of view in the longitudinal space. These two angular parameters represent the lowest and highest incident light angles that the optical path can cover on the outer wall of the cylindrical lens under test after being reflected by the tilted annular mirror. Based on this, the setting of the aforementioned field of view is actually controlled by three core spatial physical parameters of the imaging system: the physical outer diameter (Diameter) of the cylindrical lens under test, the effective height (Height) of the QR code area on the outer wall to be inspected, and the working distance (WD) between the bottom of the tilted annular mirror and the top of the cylindrical lens under test. Specifically, the working distance (WD) limits the axial spatial margin of the optical path reflection, which, together with the outer diameter (Diameter) and effective height (Height) of the cylindrical lens under test, constitutes the spatial boundary conditions of the target imaging area; based on the interaction of these three physical dimensional parameters, the specific angle values of the lowest and highest incident light rays are derived and constrained. By setting the field of view constraint based on the above spatial parameter coordination, it is ensured that the height area where the QR code is located can be completely captured, while avoiding the introduction of severe edge aberrations or longitudinal information truncation due to excessively large or small observation angles.
[0027] Based on the optical path steering characteristics and field of view configuration of the aforementioned continuous conical mirror, this solution eliminates the need to rotate the workpiece or scanning head. It only requires a single exposure by the coaxial main lens to capture a complete annular stretching image containing information about the outer wall in the entire circumference. From a hardware structure perspective, it completely avoids the inherent defects of mechanical wear and positioning deviation caused by long-term operation of traditional rotary scanning mechanisms, and can adapt to the needs of high-speed batch inspection on production lines.
[0028] Figure 3 An example of a stretched circular image containing full-text QR code information, obtained according to an embodiment of this application, is shown. It should be understood that QR codes are information-sensitive patterns, and the QR code pattern has been blurred in the accompanying drawings.
[0029] like Figure 3 As shown, by activating the coaxial main lens and image sensor, and based on the optical path design of the optical system described above, the system can obtain the original image of the annular stretching by taking a single shot of the outer wall of the cylindrical lens under test. The image completely preserves the full circumferential contour and positional features of the target QR code, without any blind spots or missed areas.
[0030] In step S120, the inner and outer ring contours in the original image of the ring stretching are identified, and a double-ring region of interest containing the target QR code is delineated based on the inner and outer ring contours.
[0031] It should be noted that the annular stretching original image obtained in step S110 may contain background areas, clamping structures, lens end faces, or other image information unrelated to QR code recognition, in addition to the effective imaging content of the outer wall of the cylindrical lens under test. Therefore, in this embodiment, the annular stretching original image is first analyzed to identify the inner and outer boundaries formed by the imaging of the outer wall of the cylindrical lens under test, thereby extracting the corresponding inner and outer annular contours.
[0032] After identifying the inner and outer annular contours, these contours are used as the basis for spatial positioning. A double-ring region of interest (ROI) is delineated in the original image coordinate system, corresponding to the imaging area of the outer wall of the cylindrical lens under test. The double-ring ROI is located inside the outer ring and outside the inner ring, and its range corresponds to the effective information band of the outer wall where the target QR code is located. This confines the pixel information of the target QR code within this double-ring ROI. In this way, the effective outer wall imaging content in the original image can be separated from the surrounding irrelevant areas, preventing irrelevant background information from entering subsequent processing.
[0033] By using a dynamic delineation method based on inner and outer ring contours, the double-ring region of interest can be adaptively determined according to the actual imaging state in the current image, without relying on a pre-fixed clipping position. Therefore, even in practical applications where there are installation tolerances, workpiece placement offsets, or slight fluctuations in imaging position, the system can still stably extract the region where the target QR code is located based on the ring structure features in the current image.
[0034] In step S130, the annular image within the region of interest of the double ring is extracted, and the annular image is reconstructed by reverse mapping from polar coordinates to rectangular coordinates to unfold the annular image into a planar image.
[0035] Specifically, after defining the region of interest for the double rings, the valid ring image within that region is extracted from the original stretched ring image. Since this ring image is the result of the reflection of the circumferential outer wall information of the cylindrical lens being tested through the tilted ring mirror, the QR code pattern in it usually presents a ring distribution. Its geometric arrangement is not consistent with the conventional recognition input form of planar QR codes, and therefore it is not suitable for direct use in subsequent recognition processing.
[0036] Based on this, the steps in this embodiment further perform a reverse mapping reconstruction from polar coordinates to Cartesian coordinates on the extracted annular image. Specifically, a polar coordinate description is established based on the geometric center and radius distribution of the annular image, and the angular information distributed circumferentially and the positional relationships distributed radially in the annular image are mapped to the Cartesian coordinate grid of the target planar image. Through this mapping process, the originally closed annular image can be unfolded into a planar image, transforming the QR code pattern from a ring-shaped distribution into a planar distribution form more suitable for recognition.
[0037] In some implementations, a reverse mapping method can be used to reconstruct the pixel values by looking up the corresponding positions of the pixels in the target planar image in the original annular image point by point. This process reduces potential pixel gaps or local discontinuities during the unfolding process, improving the integrity and coherence of the unfolded results. Thus, geometric unfolding of the annular imaging result can be achieved without relying on multi-frame stitching.
[0038] In step S140, the boundary of the target QR code is located in the planar image, and the target QR code image is cropped from the planar image based on the located boundary for information recognition.
[0039] It should be noted that after the unfolding process in step S130, the obtained planar image represents the unfolded result of the circumferential outer wall of the cylindrical lens under test, while the target QR code usually only occupies a local area within it. Therefore, in this embodiment, the planar image is further subjected to boundary positioning processing to determine the actual range of the target QR code.
[0040] Specifically, the boundary of the target QR code in a planar image can be located based on the differences between the target QR code area and its surrounding areas in terms of grayscale variation, edge structure, or region contour, and its circumscribed range can be determined based on the location result. Subsequently, based on the determined boundary range, a local image containing the target QR code is cropped from the planar image to obtain the target QR code image. In this way, areas unrelated to the target QR code in the unfolded image can be further removed, making the image content entering the recognition stage more focused on the identifier itself.
[0041] After obtaining the target QR code image, it can be input into the QR code recognition module for information parsing, thereby outputting the corresponding encoded content. By adding boundary localization and local cropping processing before recognition, the influence of irrelevant image content on the recognition process can be reduced, and the effectiveness of the recognition input can be improved, thus enhancing the overall detection efficiency and stability of the recognition process.
[0042] In some examples of embodiments of this application, controlling the coaxial main lens to perform a single exposure to obtain the annular stretched original image of the cylindrical lens under test is performed under set anti-glare illumination conditions. Specifically, the anti-glare illumination conditions are established in the following manner: First, a ring-shaped diffuse reflection light source, independently mounted on the outside of the tilted ring mirror, is activated to generate an illumination beam with a diffuse reflection distribution.
[0043] In actual industrial production lines, the outer wall of the cylindrical lens under test is usually made of a smooth material or has undergone special surface treatment, exhibiting strong specular reflection characteristics. If conventional point light sources or strong directional light sources are used for illumination during imaging, bright, highly reflective spots are easily generated locally on the outer wall of the lens under test, causing irreversible loss of the QR code dot matrix information in that area due to local overexposure. Based on this, this embodiment independently mounts a ring-shaped diffuse reflection light source on the physical outside of the tilted ring-shaped reflector. This light source does not encroach on the core imaging field of view inside the reflector in terms of spatial layout. At the same time, the beam emitted by it, after diffuse reflection diffusion treatment, can be evenly and softly spread on the three-dimensional circumferential outer wall of the cylindrical lens under test. Thus, the high reflectivity of the lens material itself is effectively weakened, providing a uniform external light field environment for panoramic imaging.
[0044] Furthermore, the beam illumination angle of the annular diffuse reflection light source is set so that the beam illumination angle is less than the tilt angle of the inclined annular reflector.
[0045] It should be noted that in a coaxial panoramic imaging architecture, the tilted ring mirror used for optical path steering is itself a highly reflective mirror optical element. If the illumination angle of the ring diffuse reflection light source is greater than or equal to the tilt angle of the mirror, the light beam will not only illuminate the lens under test, but also a large amount of light will directly illuminate the surface of the ring mirror. After being reflected by the mirror, this direct light will rush directly into the entrance pupil of the coaxial main lens, forming a large area of severe glare on the final imaging target surface, and may even cause partial blinding of the camera sensor.
[0046] To avoid the aforementioned optical crosstalk trap, this embodiment uses precise geometric angle constraints to ensure that the beam projection path of the light source spatially avoids the reflection-sensitive area of the reflective mirror. Specifically, by utilizing the defined angular difference that "the beam illumination angle is less than the arrangement tilt angle," the direct path of the illumination beam to the continuous conical reflective surface of the tilted ring mirror is directly blocked from the physical geometric optical path. Based on the above optical settings, the effective illumination light emitted by the light source can only be projected onto the outer wall of the cylindrical lens under test, and only the light carrying clear QR code image information after diffuse reflection from the outer wall of the lens can be effectively captured by the tilted ring mirror and reflected back to the coaxial main lens.
[0047] In this embodiment, by independently setting up a ring-shaped diffuse reflection light source and strictly setting the geometric constraint that "the beam illumination angle is less than the tilt angle of the reflector arrangement," a highly efficient anti-glare and optical path decoupling mechanism is constructed at the optical physics level. This not only successfully suppresses the specular highlighting phenomenon on the smooth outer wall of the cylindrical lens under test but also cuts off overexposure interference caused by direct ambient lighting onto the main imaging system. Thus, based on the optical spatial configuration, a pure light field with an extremely high signal-to-noise ratio is created at the instant of a single exposure of the main lens, eliminating destructive optical noise such as light spots and glare.
[0048] Figure 4 A flowchart illustrating an example of identifying and delineating a double-ring region of interest containing a target QR code in a method according to an embodiment of this application is shown.
[0049] like Figure 4 As shown, in step S410, edge detection processing is performed on the original annular stretched image to extract the annular physical boundary imaged by the circumferential outer wall of the cylindrical lens under test, as the inner and outer annular contours.
[0050] In practical implementation, since the outer wall of the cylindrical lens under test often exhibits significant grayscale or image contrast differences with its surrounding background or internal aperture region during optical imaging, the system can utilize edge detection algorithms in image processing to perform gradient analysis on the input annularly stretched original image. By detecting the set of pixels in the image where pixel grayscale values undergo a step change, the closed annular edge formed by the natural imaging of the two ends of the circumferential outer wall of the cylindrical lens under test can be accurately delineated.
[0051] Here, the edge pixels accurately reflect the physical orientation and precise position of the lens under test within the current optical field of view. The system defines the extracted edge features as inner and outer annular contours, thereby transforming the complex original image into a clear boundary structure.
[0052] In step S420, the coordinates of the reference center of the inner and outer ring contours are determined, as well as the large ring radius and small ring radius corresponding to the outer ring and inner ring, respectively.
[0053] Here, after obtaining the inner and outer ring contours composed of discrete pixels, the system needs to convert them into standard optical geometric parameters. Specifically, based on the extracted inner and outer ring contour data points, the system automatically fits the center (i.e., the reference center coordinates) of the inner and outer rings, as well as the corresponding large and small ring radii, using the least squares method. For example, in a certain actual detection scenario, the fitted large ring center coordinates can be (1904.38, 2747.99) with a large ring radius of 1398.13, and the small ring center coordinates can be (1922.74, 2766.35) with a small ring radius of 804.867. It should be emphasized that the specific coordinate values mentioned in this application are only examples, and are not fixed values hardcoded in the actual algorithm program. The core logic revolves around the natural ring features after lens imaging, adaptively delineating the double-ring ROI region based on the fitted center and radius. The dynamic fitting mechanism eliminates the need for mechanical limits imposed by tooling fixtures. Even with minor adjustments to the camera's mounting position, it can accurately locate the valid information band containing the QR code, fundamentally avoiding positioning failures or patent circumvention risks caused by fixed coordinates.
[0054] Figure 5A schematic diagram illustrating the actual processing effect of identifying and delineating the double-ring region of interest according to an embodiment of this application is shown.
[0055] like Figure 5 As shown, using the coordinates of the reference circle center obtained by least squares fitting as the origin, and combining the calculated large and small ring radii, the system accurately defines the ring physical boundary of the target QR code in the original coordinate system.
[0056] In step S430, a double-ring region of interest is delineated using the point corresponding to the reference circle center coordinates as the center, and in combination with the radius of the large ring and the radius of the small ring, to define the range of the target QR code.
[0057] Specifically, based on the high-precision geometric parameters calculated in the aforementioned steps, the system dynamically generates a ring-shaped spatial constraint interval in the original image coordinate system, using the point corresponding to the center coordinate of the reference circle as the spatial origin, and the radius of the smaller ring as the lower limit of the inner diameter and the radius of the larger ring as the upper limit of the outer diameter. This constraint interval is the defined double-ring region of interest. Since this region is dynamically derived strictly based on the physical boundary of the real-time imaging of the lens under test, it can adaptively and appropriately encompass and define the actual location of the target QR code.
[0058] In this embodiment, an adaptive dynamic positioning of the effective annular region where the target QR code is located is achieved through a processing strategy that combines image edge feature extraction with geometric parameter model calculation. This eliminates the reliance on absolute physical limits of mechanical fixtures and fixed image cropping frames in traditional industrial inspection systems. Even in actual high-frequency production line operations where there are slight displacements in workpiece placement or micro-tolerances in camera mounting posture, the system can still accurately delineate the effective information band in real time by relying on the inherent annular structural features of the image itself, significantly improving the robustness of region positioning and the overall anti-interference capability of the system.
[0059] Regarding the implementation details of extracting the ring-shaped image within the double-ring region of interest in step S130, in some examples of embodiments of this application, the system achieves precise stripping of the effective image region by constructing and applying a double-ring mask. The specific implementation process is as follows: First, a double-ring mask is constructed based on the reference center coordinates, the radius of the large ring, and the radius of the small ring.
[0060] In some implementations, the dual-ring mask is essentially a two-dimensional logical matrix or spatial filter that matches the size of the original input image. The system utilizes the geometric feature parameters extracted in the preceding steps, using the reference circle center coordinates as the absolute geometric origin, and combining the spatial boundaries defined by the radii of the large and small rings to dynamically generate a ring-shaped Boolean scope in memory. Matrix elements within this scope (i.e., the space between the large and small rings) are assigned a "valid" or "retained" flag (e.g., logical value 1), while elements outside the scope are assigned a "removed" flag (e.g., logical value 0). Through this numerical geometric modeling, the system constructs a virtual mask that precisely fits the current physical orientation of the lens under test, without relying on any mechanical physical baffle.
[0061] Then, the double-ring mask is applied to the original image of the ring stretching, retaining the area between the large ring radius and the small ring radius as the effective information area.
[0062] In some implementations, at the pixel-level operation level, the system performs point-to-point spatial mapping and logical operations (e.g., mask multiplication) between the constructed double-ring mask matrix and the pixel matrix of the original stretched image. Through this spatial filtering mechanism, image pixels falling within the double-ring region of interest (i.e., the pixels corresponding to the outer wall region actually printed with the target QR code) are completely and losslessly preserved. These preserved pixel sets together constitute the core effective information region for subsequent polar coordinate unfolding and information recognition.
[0063] Furthermore, the pixel values of the regions located outside the large ring radius and inside the small ring radius in the original stretched image are forcibly set to a preset black mask value to remove background information and lens end face interference information in the original stretched image, thereby extracting the ring image containing the target QR code.
[0064] It should be noted that in a coaxial panoramic optical imaging system, the area outside the large ring radius typically contains diffuse stray light from the production line background, equipment casing, or tooling fixtures; while the area inside the small ring radius often corresponds to the top surface of the lens being tested or internal lens components, which are prone to strong optical reflections or images. Using masking logic, the system uniformly and forcibly modifies the pixel values corresponding to these two invalid areas to a preset black mask value (e.g., grayscale value 0, i.e., pure black). Furthermore, the extraction process here is not a traditional image grayscale subtraction or background difference operation (because the system does not have a standard background image); its essence is a "double-ring masking operation" based on a geometric model. Specifically, the system delineates two concentric rings, a large ring and a small ring, using an automatically fitted center and radius. Then, it forcibly modifies the pixel values of the areas outside the large ring radius (e.g., diffuse stray light background from the production line) and inside the small ring radius (e.g., reflections from the lens surface or internal lens) in the original image to a preset black mask value (e.g., pure black). Through the aforementioned forced pixel blackening process, all non-target structured features in the original image that could potentially cause algorithmic misjudgments are completely removed. After this filtering and rinsing process, the system ultimately extracts a ring-shaped image containing only the target QR code pixel data from the complex original optical field of view, achieving both physical-level and pixel-level blocking of background noise.
[0065] Figure 6 A schematic diagram of a ring-shaped image containing only the target QR code, extracted after a double-ring masking operation according to an embodiment of this application, is shown.
[0066] like Figure 6 As shown, through the above masking operation, the complex background noise in the original image is accurately removed, and only the highly pure QR code ring area is selected and retained, achieving both physical and pixel-level blocking of invalid information.
[0067] Figure 7 A schematic diagram of the delineation and masking process of the double-ring region of interest according to an embodiment of this application is shown.
[0068] like Figure 7 As shown, based on the extracted inner and outer ring contours, and the reference center determined therefrom, the system delineates a "double-ring region of interest" in the original image coordinate system to define the area where the target QR code is located. Specifically, this double-ring region of interest is the annular effective information band located between the inner ring contour (corresponding to the radius of the smaller ring) and the outer ring contour (corresponding to the radius of the larger ring) (as shown in the blank annular area between the two contours in the figure). The radial physical width of this effective information band strictly corresponds to the "calibrated height" of the subsequently unfolded planar image.
[0069] In addition, such as Figure 7As shown by the leader line of the "blackened masking area," in order to accurately extract the effective image and eliminate background noise, the system constructs a corresponding double-ring mask and forcibly modifies the pixel values of the area within the inner ring contour (as shown in the figure, the area with diagonal stripes and a pure black center, usually corresponding to interference reflections from the end face or internal aperture of the lens being tested) to a preset blackened masking value. Similarly, the background area outside the outer ring contour is also blackened (the outer blackening is not marked in the figure, but the logic is the same). Through the above mask blackening process, the system completely separates the effective outer wall imaging content from the peripheral irrelevant area in the original image at both the physical and pixel levels, thereby extracting a high-purity ring image containing the target QR code.
[0070] In this embodiment, by constructing a geometrically parameter-driven dynamic double-ring mask and performing precise pixel-level blackening and masking processing, a data purification operation is preemptively completed before polar coordinate inverse mapping reconstruction. This not only effectively filters out the serious interference of lens end-face reflection and cluttered production line background on subsequent image unfolding and feature recognition, improving the image signal-to-noise ratio of the target QR code area, but also effectively reduces the amount of invalid pixel calculations faced by the system in the subsequent inverse mapping reconstruction stage. While ensuring high accuracy of panoramic recognition, it optimizes the overall algorithm execution efficiency and meets the stringent requirements of industrial production lines for high-speed and high-interference-resistance detection.
[0071] Regarding the implementation details of locating and cropping the target QR code image in step S140, in some examples of embodiments of this application, firstly, a secondary outer contour extraction is performed on the planar image to find the physical boundary of the target QR code.
[0072] It should be noted that the planar image generated after polar coordinate inverse mapping reconstruction represents the complete unfolded surface of the 360-degree circumferential outer wall of the cylindrical lens being tested. However, the effective dot matrix of the target QR code usually only occupies a local area of this wide planar image, with the remaining large area mostly being the blank background of the lens outer wall. Therefore, the system needs to perform secondary edge feature extraction on this planar image (different from the aforementioned extraction of the natural physical ring boundary of the original image). For example, it can combine the local contrast features of the image or morphological processing algorithms to identify the edge pixel crossing points of the densely distributed dot matrix area, thereby accurately finding and delineating the actual physical boundary of the target QR code in the planar image.
[0073] Next, based on the found physical boundaries, the minimum bounding rectangle surrounding the target QR code is generated.
[0074] Specifically, after locating the physical boundaries of the target QR code, these boundaries often appear as irregular sets of pixels due to minor deformations that may occur during actual printing or the initial unfolding and mapping process. To convert them into a regular geometric input form suitable for standard decoding algorithms, the system calculates and generates a minimum bounding rectangle that can completely enclose these physical boundaries based on the obtained boundary pixel coordinates. This minimum bounding rectangle establishes the external structural framework of the target QR code in the most compact geometric topology.
[0075] Then, the target QR code image is cropped from the planar image according to the vertex coordinate range of the smallest bounding rectangle.
[0076] In some implementations, the system performs an image cropping operation on the pixel matrix of the planar image based on the coordinates of the four vertices of the generated minimum bounding rectangle. This operation strictly extracts the pixel content within the rectangle according to the coordinate range, forming independent local image data, i.e., the target QR code image. Through precise cropping, large areas of blank background pixels in the wide planar image, as well as non-target noise such as blemishes and scratches that may be attached to other locations on the lens outer wall, are completely discarded, significantly reducing the volume of image data entering the decoding stage and reducing the risk of misjudgment by the decoding algorithm due to various background interferences.
[0077] Then, the cropped target QR code image is input into a standard QR code parsing engine for dot matrix data decoding to output the corresponding recognition result.
[0078] In practice, after acquiring a clean and compact target QR code image, the system directly hands it over to the backend standard QR code parsing engine for processing. Since severe annular stretching distortion has been eliminated through polar coordinate inverse mapping in the early stages, and most environmental interference has been eliminated through masking and precise cropping, the target QR code image at this point possesses an extremely high image signal-to-noise ratio and good geometric regularity. Therefore, the parsing engine does not need to be equipped with a large and time-consuming deep custom decoding model; it can quickly and accurately extract the character encoding information contained in the dot matrix using only conventional matrix decoding rules, and output the final product traceability identification result.
[0079] In this embodiment, a highly efficient target-targeting stripping strategy is constructed in the macroscopic planar unfolded image through a cascaded processing mechanism of secondary contour extraction, minimum bounding rectangle generation, and precise cropping. Before entering the core decoding stage, a large amount of invalid background redundant data and potential surface feature interference are effectively eliminated, so that the image data finally input to the parsing engine reaches a highly purified standard.
[0080] Figure 8 A flowchart illustrating an example of unfolding a ring-shaped image into a planar image according to an embodiment of this application is shown.
[0081] like Figure 8 As shown, in step S810, the calibration width and calibration height of the planar image to be generated are determined, and a target rectangular coordinate system is constructed based on the planar image. The grid coordinates of each target pixel in the planar image in the target rectangular coordinate system are set according to the calibration width and calibration height.
[0082] In some implementations, to losslessly convert a ring-shaped distribution of pixels into a standard rectangular array, the system can predefine a blank planar image. The calibration width and calibration height of this planar image can be adaptively set according to the actual physical perimeter and height ratio of the outer wall of the lens being measured, or in conjunction with the optimal resolution requirements of the subsequent recognition engine. Subsequently, a target Cartesian coordinate system is constructed with a specific location (e.g., the upper left corner) of this blank planar image as the absolute origin, so that the entire planar image to be generated is divided into a standard two-dimensional pixel grid consisting of horizontal rows and vertical columns. In this reference grid, each target pixel is assigned a unique horizontal and vertical grid coordinate.
[0083] In step S820, for each target pixel in the planar image, the polar coordinate angle corresponding to the target pixel in the polar coordinate system is calculated proportionally based on the target pixel's coordinates in the width direction and the calibration width; and the polar coordinate radius corresponding to the target pixel in the polar coordinate system is calculated proportionally within the interval formed by the large and small ring radii based on the target pixel's coordinates in the height direction, the calibration height, the large ring radius, and the small ring radius. Here, the polar coordinate system is established based on the ring image, and the pole of the polar coordinate system is the point corresponding to the coordinates of the reference circle center.
[0084] Here, after establishing the target pixel grid, the system employs an efficient reverse mapping mechanism, which starts from the coordinates of the target blank grid and traces back to the corresponding pixel spatial position in the source image. Specifically, the system iterates through each target pixel in the planar image, calculates the ratio of its coordinate value in the width direction to the overall calibration width, and linearly maps this ratio to a circumferential angle range, thereby proportionally calculating the polar coordinate angle corresponding to that point. Similarly, it calculates the ratio of its coordinate value in the height direction to the overall calibration height, and linearly maps this ratio to the difference range between the large ring radius and the small ring radius (i.e., the physical width of the effective information band), thereby calculating the polar coordinate radius corresponding to that point.
[0085] In this process, the polar coordinate system upon which the mapping relies is strictly established based on the original input annular image, and its poles are the points corresponding to the reference circle center coordinates calculated in the aforementioned steps. Through the linear scaling and transformation of the above dimensions, the horizontal and vertical coordinates of the target pixel in the orthogonal rectangular coordinate system are decoupled and converted into polar angle and polar radius parameters with real physical meaning in the polar coordinate space.
[0086] In step S830, based on the reference circle center coordinates, polar coordinate angles, and polar coordinate radii, and combined with trigonometric function relationships, the source rectangular coordinates corresponding to each target pixel point in the ring image are determined.
[0087] Here, after obtaining the polar coordinate angles and radii of each target pixel after mapping, the system needs to reunite these polar coordinate parameters into the physical pixel coordinate domain of the original annular image. Specifically, the system uses the pole (i.e., the coordinates of the reference center) as the absolute reference and calls standard trigonometric function relationships (i.e., cosine and sine functions) to calculate the relative horizontal and vertical offsets of the current polar radius and polar angle in the two-dimensional plane. By adding these offsets to the coordinates of the reference center, the source rectangular coordinates corresponding to each target pixel in the original annular image can be calculated and determined in reverse, thereby establishing a point-to-point topological mapping channel between the unfolded surface of the target rectangle and the original annular stretched surface.
[0088] In step S840, the corresponding source pixel values are obtained in the annular image according to the source rectangular coordinates, and the source pixel values are assigned to each corresponding target pixel point to reconstruct a planar image that eliminates the annular stretching distortion point by point.
[0089] Here, the system performs reverse pixel addressing within the extracted effective annular image matrix based on the calculated source Cartesian coordinates, extracting the source pixel value (such as grayscale or RGB color value) corresponding to that coordinate location. Subsequently, the read source pixel value is directly assigned to the target pixel in the planar image that issued the addressing request. After the system iterates through all target pixels in the planar image and completes all the above pixel assignment operations, the originally severely distorted annular pattern is reconstructed point by point and flattened into an orthogonally arranged planar image.
[0090] In this embodiment of the application, compared with the traditional forward mapping (i.e., calculating from the coordinates of the original image to the coordinates of the target image), the reverse mapping mechanism can ensure that every grid pixel in the generated planar image can be accurately traced and assigned a value, avoiding pixel holes, breaks and overlaps caused by coordinate discretization, floating-point rounding or scaling.
[0091] Regarding the implementation details of determining the polar coordinate angle corresponding to the target pixel in the polar coordinate system in step S820, in some examples of the embodiments of this application, the target pixel's coordinates in the width direction are mapped to the range of the redundancy angle threshold according to the ratio of the calibrated width to the coordinates of the target pixel in the width direction, so as to form information overlap areas at the beginning and end of the unfolded planar image; wherein, the redundancy angle threshold defines the maximum mapping angle of the polar coordinate angle greater than 360°.
[0092] It should be noted that in conventional polar coordinate unfolding, the system typically maps the overall width of the target planar image strictly and proportionally to the 360° range of a standard circle. However, in actual fully automated production lines, the circumferential rotation of the cylindrical lens to be inspected as it enters the inspection space is often completely random. This results in a high probability that the target QR code will exactly cross the 0° (i.e., 360°) mapping start seam. If the reconstruction and unfolding are strictly performed according to the 360° boundary, the complete dot matrix of the target QR code will be physically cut and scattered at the leftmost and rightmost ends of the unfolded planar image, causing severe structural breaks, leading the subsequent standard parsing engine to directly determine decoding failure.
[0093] To address the seam interruption issue caused by the aforementioned random posture, this embodiment introduces a redundant angle threshold during the coordinate conversion stage. This redundant angle threshold is set as a specific angle parameter larger than the standard circumference (360°) (for example, it can be preset to 370° or 380° based on the conventional physical width of the target QR code). During the mapping process, the system calculates the ratio of the target pixel's coordinate value in the width direction to the calibrated width in the planar image, and linearly maps this ratio to the interval [0, redundant angle threshold], thereby deriving the corresponding polar coordinate angle.
[0094] After performing the above-mentioned over-limit mapping, when the polar coordinate angle of the target pixel exceeds 360°, based on the optical physical cycle characteristics of circular space, the polar coordinate angle of the excess part actually wraps back to the 0° starting area of the cylindrical lens outer wall for pixel source tracing and sampling. Therefore, through this redundant mapping mechanism that exceeds the standard circumference, the system smoothly and seamlessly extends and reconstructs a redundant image content at the end of the final generated unfolded planar image that is exactly the same as the starting image, that is, constructing an information overlap area of a certain physical width in the planar image. Even if the actual position of the target QR code just crosses the mapping starting point, its continuous and complete form will inevitably be presented continuously and without loss within this information overlap area, and the system does not need to allocate additional computing power later to perform complex breakpoint image feature stitching and repair.
[0095] It should be noted that the core of pixel remapping is to realize the reverse mapping lookup from polar coordinates to Cartesian coordinates.
[0096] In some implementations, the calibration width of the target planar image to be generated is set to... (e.g., 5200 pixels), calibrated height is (For example, 1400 pixels). The grid coordinates of any target pixel in the target planar image are: The system needs to reverse-calculate its source rectangular coordinates in the original circular image. .
[0097] First, the coordinates of the target pixel. Convert to polar coordinate parameters (polar angles) With polar coordinate radius ): , .in, The aforementioned redundant angle threshold covers the entire annular area and has overlapping information at the beginning and end; and These correspond to the small loop radius and the large loop radius obtained from the fitting, respectively.
[0098] Through the embodiments of this application, a redundant angle threshold of more than 360° is introduced to perform over-the-horizon extension mapping of polar coordinate angles. The anti-truncation protection mechanism is internalized in the underlying coordinate space transformation stage, eliminating the risk of QR code cross-seam breakage caused by random workpiece loading posture. This ensures that the target QR code at any circumferential distribution position can maintain at least one complete dot matrix topology in the reconstructed and unfolded planar diagram, thereby enhancing the randomness tolerance and robustness of the detection system to the initial pose of the workpiece being tested.
[0099] Subsequently, regarding the details of converting the source rectangular coordinates in step S830, in some implementations, polar coordinate parameters are used. Calculate its source rectangular coordinates in the original image. : , .in, The coordinates of the reference circle center obtained by automatic fitting are used during calculation. It needs to be converted to radians. Through the above reverse mapping logic, the system accurately maps the pixel positions of the target planar image to the "angle + radius" domain of the original circular image, and then converts it back to the Cartesian coordinate system of the original image.
[0100] Furthermore, due to the source rectangular coordinates obtained after coordinate transformation Typically, the coordinates are floating-point numbers (i.e., non-integer sub-pixel coordinates). This embodiment uses bilinear interpolation to obtain the final source pixel value. Specifically, the coordinates are floating-point numbers. Centered on a target pixel, the four nearest integer pixels are selected, and a weighted average is calculated based on distance weights to assign the value to that pixel. Compared to nearest neighbor interpolation, bilinear interpolation effectively avoids jagged edges and mosaic effects in the unfolded image, ensuring the smoothness of the high-frequency dot matrix image of the QR code, thereby improving the subsequent decoding accuracy.
[0101] Figure 9 The illustration shows an example of reconstructing a circular image into a planar image according to an embodiment of this application.
[0102] like Figure 9As shown, through the above-mentioned precise underlying mathematical mapping and bilinear interpolation reconstruction, the planar image with a resolution of up to 5200×1400 pixels is adaptively unfolded, completely eliminating the severe annular stretching distortion caused by the original coaxial optical path, and restoring the originally distorted QR code to a standard long rectangular topological shape.
[0103] Regarding the implementation details of assigning source pixel values in step S840, in some examples of embodiments of this application, firstly, when the source rectangular coordinates are non-integer floating-point coordinates, multiple neighboring reference pixels located around the floating-point coordinates are located in the ring image.
[0104] It should be noted that, because the trigonometric function transformation between polar and rectangular coordinate systems involves continuous nonlinear mathematical operations, the source rectangular coordinates calculated by the system in reverse are usually expressed as non-integer floating-point coordinates with decimal parts. In other words, the coordinates of this reverse tracing do not directly correspond to a single physical pixel in the discrete physical pixel grid of the original circular image. To avoid image information loss or positional shift caused by simple coordinate rounding operations, the system employs a sub-pixel-level addressing strategy. Specifically, the system can use the floating-point coordinates in the pixel matrix of the circular image... Using the geometric center as the reference point, accurately retrieve and locate the four nearest integer discrete pixels that tightly surround it (i.e., those forming a 2×2 grid). The coordinates of these four neighboring reference pixels can be represented as follows: , , and ,in, , , , , This represents the floor operation.
[0105] Then, based on the spatial absolute distance relationship between the floating-point coordinates and each neighboring reference pixel, the distance weight corresponding to each neighboring reference pixel is calculated.
[0106] Here, after locking the aforementioned local neighborhood, the system needs to quantize the floating-point coordinates of the center for these four surrounding reference pixels. The degree of influence. Based on the principle of local continuity of image signals, the closer the pixels are, the stronger the correlation of their physical features. Therefore, the system accurately calculates the decimal offset (i.e., relative distance) of the floating-point coordinates in the horizontal and vertical directions, defining the horizontal offset as... The vertical offset is Subsequently, the system uses these relative distances to cross-combine and form distance weights that are inversely proportional to the corresponding neighboring reference pixels, objectively and realistically reflecting the gradual change trend of pixel grayscale in the local area of the source image.
[0107] Furthermore, the pixel values of each neighboring reference pixel are spatially interpolated and weighted according to the distance weight, and the calculated weighted average pixel value is used as the final shaped pixel value of the target pixel to smooth the edge details of the planar image and eliminate pixel jaggedness in the unfolded image.
[0108] In some implementations, the system extracts the true source pixel values (e.g., grayscale values) of the four neighboring reference pixels, and records them as follows: , , and Subsequently, strictly following the distance weights calculated in the previous steps, a weighted average of bilinear interpolation is performed on these discrete pixel values to fuse them and generate entirely new, smooth pixel values. The core calculation formula is as follows: The system will calculate the weighted average pixel value. The corresponding target pixel in the planar image that issues the addressing request is formally assigned.
[0109] Figure 10 An example target QR code image cropped from a planar image according to an embodiment of this application is shown.
[0110] like Figure 10 As shown, after edge detection and generating the minimum bounding rectangle of the unfolded planar image, the system crops a clean QR code local image without background interference based on the rectangle coordinates.
[0111] It should be noted that the target QR code image after polar coordinate correction and reconstruction may still have extremely slight residual aspect ratio distortion in physical space. However, extensive practical verification on industrial production lines shows that this slight distortion is well within the tolerance and error correction range of current mainstream standard QR code recognition algorithms (such as matrix decoding engines), and will not affect the integrity and recognizability of the dot matrix character information. Therefore, after acquiring the cropped target QR code image, the system directly hands it over to the parsing engine to complete data reading, without the need for additional complex secondary geometric correction operations such as perspective transformation and affine transformation. This is based on a deep consideration of balancing "recognition accuracy" and "algorithm execution efficiency," effectively omitting redundant secondary correction steps, significantly reducing the computing power consumption of the controller, and significantly shortening the detection calculation time for a single product, meeting the requirements of modern automated production lines for extremely high operating cycles.
[0112] In this embodiment, to address the unavoidable floating-point addressing problem in polar coordinate inverse mapping, a sub-pixel-level spatial interpolation mechanism based on spatial geometric distance weights is introduced. This eliminates the coordinate rounding error caused by the crude sampling of the traditional nearest neighbor rounding algorithm. By finely fusing the pixel features of the local neighborhood, the missing image data is accurately fitted, thus repairing the image tearing and edge abruptness defects that are easily caused during the nonlinear geometric distortion unfolding process. Without changing the physical hardware resolution accuracy, the high-frequency dot matrix details of the target QR code can be restored with extremely high fidelity.
[0113] Figure 11 A structural block diagram of an example of a lens outer wall QR code detection device according to an embodiment of this application is shown.
[0114] like Figure 11 As shown, the lens outer wall QR code detection device 1100 includes a coaxial main lens 1110, an inclined ring reflector 1120, and an image processing module 1130.
[0115] Specifically, the coaxial main lens 1110 has an imaging target surface, and the main optical axis of the coaxial main lens 1110 is configured to be collinear with the central axis of the cylindrical lens being tested.
[0116] In practical testing systems, the coaxial main lens 1110 serves as the core image acquisition hardware unit, typically integrating a high-resolution industrial-grade image sensor (such as a CCD or CMOS target) to record optical signals. By strictly aligning the principal optical axis with the central axis of the cylindrical lens under test, the device constructs a centrally symmetrical coaxial observation architecture in three-dimensional physical space. This collinear design ensures that the entrance pupil of the coaxial main lens 1110 maintains absolutely consistent optical depth of field and spatial magnification when facing the surface of the cylindrical lens under test in all circumferential directions.
[0117] The tilted ring mirror 1120 has a continuous conical reflecting surface. The tilted ring mirror 1120 is located in front of the entrance pupil of the coaxial main lens, and the central axis of the tilted ring mirror 1120 is arranged collinearly with the principal optical axis. The interior of the tilted ring mirror 1120 defines a detection space for accommodating the cylindrical lens under test. The continuous conical reflecting surface surrounds the detection space to reflect and converge the image of the circumferential outer wall of the cylindrical lens under test, located in the detection space, onto the imaging target surface in one exposure. This allows the coaxial main lens 1110 to acquire a stretched annular original image containing the full circumferential information of the target QR code in a single exposure.
[0118] It should be noted that, unlike traditional spliced polygonal prisms, the tilted ring mirror 1120 adopts a smooth-transition continuous conical reflective surface structure, ensuring that the reflected light path has no physical seams or optical blind spots in the 360-degree circumference. In operation, the tilted ring mirror 1120 and the coaxial main lens 1110 form a coaxial optical system, and its internal hollow area naturally forms a non-contact detection space that does not require rigid mechanical clamping.
[0119] When the cylindrical lens under test enters the testing space, due to the omnidirectional wrapping characteristic of the continuous conical reflective surface, the optical image at any angle on the circumferential outer wall of the lens under test can be directionally deflected through the reflective surface and directly converge into the coaxial main lens 1110 without obstruction, thus reducing the optical information of the three-dimensional cylindrical side to a two-dimensional planar ring image. Through the purely physical optical reflection design, the system is freed from dependence on external mechanical rotating drive components such as motors and gears, achieving panoramic imaging without moving parts, and giving the device extremely high response speed and mechanical stability.
[0120] The image processing module 1130 is communicatively connected to the coaxial main lens and is configured to receive the annularly stretched original image and perform the method described in any of the preceding claims of this application to locate and identify the target QR code in the reconstructed planar image.
[0121] In some implementations, the image processing module 1130 can establish a low-latency communication connection with the coaxial main lens 1110 through a high-speed data transmission interface (such as a gigabit Ethernet port, USB 3.0 or Camera Link interface, etc.) to acquire the original data of the annular stretch original image in real time at the moment a single exposure is completed.
[0122] Upon receiving the original image, the image processing module 1130, relying on its internal processor and storage medium, invokes and executes the data processing flow from the preceding embodiments. The image processing module 1130, through pure software calculation, replaces the cumbersome physical image stitching, achieving the unfolding of distorted images and targeted reading of feature information. The underlying algorithm logic, operational details, and beneficial technical effects of how the image processing module 1130 specifically performs mask delineation, polar coordinate inverse mapping reconstruction, and image cropping recognition have been fully and thoroughly described in the above method embodiments and will not be repeated here.
[0123] In some examples of embodiments of this application, the lens outer wall QR code detection device 1100 further includes an annular diffuse reflection light source (not shown) independently sleeved on the outside of the tilted annular reflector 1120, and the annular diffuse reflection light source is arranged coaxially and concentrically with the tilted annular reflector 1120.
[0124] In practical implementation, considering that the outer wall of the cylindrical lens under test is usually made of smooth plastic or metal, which has strong specular reflection characteristics, if conventional directional point light sources or parallel light sources are used for illumination, local bright spots are easily generated on the surface of the workpiece, causing the QR code features in that area to be lost due to overexposure. Therefore, this embodiment is specially configured with a ring diffuse reflection light source. By independently mounting it on the physical outside of the tilted ring reflector 1120 and maintaining a coaxial and concentric spatial layout, this light source can provide 360-degree circumferential uniform illumination to the internal detection space without obstructing the main imaging field of view. At the same time, the light emitted by the light source becomes soft and uniform after diffuse reflection treatment, effectively neutralizing the smooth reflective characteristics of the outer wall of the cylindrical lens under test, and providing a consistent and high-contrast external light field environment for panoramic imaging.
[0125] Specifically, the annular diffuse reflection light source is used to provide an illumination beam with a diffuse reflection distribution to the detection space, and the illumination angle of the annular diffuse reflection light source is configured to be smaller than the arrangement tilt angle of the tilted annular reflector.
[0126] In the coaxial panoramic optical architecture, the tilted ring mirror 1120 is a highly reflective mirror element. If the angle of illumination of the ambient light is not properly controlled, a large amount of light will directly illuminate the continuous conical reflective surface and enter the entrance pupil of the coaxial main lens 1110 through mirror reflection, thereby forming a serious global or local glare interference on the final imaging target surface.
[0127] To completely block this crosstalk path in the physical optical path, this embodiment proposes to constrain the projection direction of the annular diffuse reflection light source, making its beam illumination angle smaller than the arrangement tilt angle of the tilted annular reflector. Utilizing this defined angular difference to form a physical geometric barrier, the spatial extension path of the illumination beam perfectly avoids the reflection-sensitive area of the continuous conical reflector. Under this optical setting, the beam can only be directly projected onto the outer wall of the cylindrical lens under test within the detection space. Only the light carrying clear QR code pattern information after diffuse reflection from the lens outer wall can be effectively received by the tilted annular reflector 1120 and reflected back to the main lens. Thus, through this optical spatial configuration, the direct interference path from the light source to the main imaging optical path is cut off, creating a uniform and highly pure physical light field for the main lens during a single exposure, thereby improving the original image quality of the annular stretched original image.
[0128] In some examples of embodiments of this application, firstly, the tilt angle of the tilted annular reflector 1120 is configured as a fixed tilt angle between 30° and 60°.
[0129] In a coaxial panoramic reflective optical system, the tilt angle of the reflector directly determines the system's field of view (i.e., effective field of view) for observing the sidewall of a cylindrical workpiece, as well as the energy transmission efficiency of the reflected light path. If the tilt angle is too small (e.g., less than 30°), the reflected light path will tend to be more parallel to the central axis of the lens being measured. This will severely limit the effective observation height of the system in the vertical direction of the workpiece's sidewall, easily causing information truncation or excessive compression distortion of the QR code pattern in the longitudinal space. Conversely, if the tilt angle is too large (e.g., greater than 60°), the overall radial dimension of the ring reflector will expand sharply, not only significantly increasing the physical volume occupied by the detection device, but also potentially causing the light reflection angle to be too steep, thus triggering severe optical aberrations at the edge of the field of view.
[0130] Therefore, this embodiment strictly constrains the tilt angle within a fixed tilt angle range of 30° to 60° (e.g., 45°), forming the optimal physical balance point for optical path reflection. This allows the optical image of the circumferential outer wall of the cylindrical lens under test to be reflected uniformly, without dead angles, and with low distortion to the entrance pupil of the coaxial main lens 1110 at the most suitable incident and reflection angles. Simultaneously, the use of a fixed-tilt, non-moving component design eliminates structural vibrations caused by mechanical focusing or motor rotation, ensuring the absolute stability of the optical structure during long-term, high-frequency production line operation.
[0131] Secondly, the opening diameter of the tilted annular reflector 1120 near the entrance of the detection space is larger than the outer diameter of the cylindrical lens under test (not shown) to allow the cylindrical lens under test to extend into the inside of the tilted annular reflector 1120.
[0132] In some implementations, the spatial arrangement of physical dimensions constrains the opening diameter of the tilted annular reflector 1120 near the entrance of the detection space to be larger than the maximum outer diameter of the product to be tested (i.e. the cylindrical lens under test), thereby creating a physically non-interfering detection space with sufficient clearance inside the reflector.
[0133] In actual automated production line operations, an external robotic arm or conveyor mechanism only needs to smoothly insert the cylindrical lens under test into or axially pass through the inner center of the tilted annular reflector 1120 to instantly complete the optical pose preparation. Furthermore, due to the ample space in the opening size, the entire inspection process is transformed into a purely non-contact detection, allowing the product under test to smoothly enter the imaging area with a simple "plug and play" action. This design also eliminates the time loss caused by tight clamping and mechanical alignment operations in traditional inspection schemes, and prevents secondary risks of workpiece surface damage due to physical friction and clamping collisions.
[0134] Figure 12A schematic diagram of the three-dimensional physical structure of a lens outer wall QR code optical imaging system according to an embodiment of this application is shown.
[0135] like Figure 12 As shown, the imaging system, in terms of its physical hardware structure, is mainly composed of a CCD image sensor (used to acquire images of the object under test), a coaxial main lens, and a tilting ring mirror (i.e., the outer lens component shown in the diagram), all assembled coaxially in series from top to bottom. During actual inspection, the cylindrical lens under test (i.e., the lens material under test), with the target QR code printed on its outer wall, is directly conveyed and positioned within the inspection space directly below the tilting ring mirror. This solution achieves significant innovation in its underlying optical structure, employing a non-rotating optical design with a precise fit between the tilting ring mirror and the coaxial main lens. Through optical path reflection, a complete image of the entire circumference of the lens under test can be instantly acquired in a single imaging session, eliminating the need for a traditional mechanical rotating scanning structure.
[0136] Based on the full-circumference annular original image obtained from the aforementioned hardware, this embodiment further constructs a detection framework based on optical imaging algorithm correction. Specifically, on the software algorithm side: First, the system applies a dual-ring ROI region extraction strategy, constructing annular ROIs by dynamically setting large and small rings with specific geometric parameters, and accurately extracting the effective annular region containing the QR code using dual-ring mask difference operations, achieving deep filtering of invalid information such as background and end-face noise; subsequently, the system seamlessly connects to a polar coordinate correction algorithm, fitting a fixed polar coordinate center, defining the start and end angles and start and end radii, adaptively inversely mapping and unfolding the annular image with physical distortion into a standard planar image, completely eliminating optical stretching distortion from the algorithm layer.
[0137] This application's embodiments employ a static optical design combining a tilted ring mirror and a coaxial main lens with single-exposure imaging, eliminating the reliance on mechanical rotation mechanisms found in traditional solutions. By eliminating mechanical wear and vibration issues of moving parts at the physical source, it effectively avoids physical displacement of the workpiece during high-speed operation. Simultaneously, it deeply integrates dual-ring ROI precise extraction and polar coordinate correction algorithms, eliminating the need for workpiece rotation and multi-frame image cutting and stitching throughout the process. By adopting an integrated hardware and software framework, it significantly reduces the probability of QR code omissions or misidentifications caused by random workpiece posture or misaligned stitching, effectively meeting the stringent inspection requirements of high-speed modern industrial production lines and providing a solid guarantee for the traceability reliability of the manufacturing process.
[0138] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of combined actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Secondly, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application. In the above embodiments, the descriptions of each embodiment have their own emphasis; for parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0139] In some embodiments, this application also provides a computer program product, the computer program product including a computer program stored on a non-volatile computer-readable storage medium, the computer program including program instructions, which, when executed by a computer, cause the computer to perform any of the above-described lens outer wall QR code detection methods.
[0140] In some embodiments, this application also provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a lens outer wall QR code detection method.
[0141] The apparatus described in the embodiments of this application can be used to execute the lens outer wall QR code detection method of the embodiments of this application, and accordingly achieve the technical effects achieved by the lens outer wall QR code detection method of the embodiments of this application, which will not be elaborated here. In the embodiments of this application, the relevant functional modules can be implemented by a hardware processor.
[0142] Figure 13 This is a schematic diagram of the hardware structure of an electronic device for performing a method for detecting QR codes on the outer wall of a lens, as provided in another embodiment of this application. Figure 13 As shown, the device includes: One or more processors 1310 and memory 1320, Figure 13 Take the 1310 processor as an example.
[0143] The device for performing the method of detecting QR codes on the outer wall of a lens may also include: an input device 1330 and an output device 1340.
[0144] The processor 1310, memory 1320, input device 1330, and output device 1340 can be connected via a bus or other means. Figure 13 Taking the example of a connection between China and Israel via a bus.
[0145] The memory 1320, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the lens outer wall QR code detection method in the embodiments of this application. The processor 1310 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions, and modules stored in the memory 1320, thereby implementing the lens outer wall QR code detection method in the above-described method embodiments.
[0146] The memory 1320 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the device, etc. Furthermore, the memory 1320 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 1320 may optionally include memory remotely located relative to the processor 1310, and these remote memories may be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0147] Input device 1330 can receive input digital or character information and generate signals related to user settings and function control of the device. Output device 1340 may include display devices such as a display screen.
[0148] The one or more modules are stored in the memory 1320, and when executed by the one or more processors 1310, the lens outer wall QR code detection method in any of the above method embodiments is executed.
[0149] The above-described product can perform the methods provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for performing the methods. Technical details not described in detail in this embodiment can be found in the methods provided in the embodiments of this application.
[0150] The electronic devices in this application embodiments exist in various forms, including but not limited to: (1) Mobile communication devices: These devices are characterized by their mobile communication capabilities and primarily aim to provide voice and data communication. These terminals include: smartphones (e.g., iPhones), multimedia phones, feature phones, and low-end phones, etc.
[0151] (2) Ultra-mobile personal computer devices: These devices fall under the category of personal computers, possessing computing and processing capabilities, and generally also have mobile internet access features. These terminals include PDAs, MIDs, and UMPCs, such as the iPad.
[0152] (3) Portable entertainment devices: These devices can display and play multimedia content. This category includes audio and video players (such as iPods), handheld game consoles, e-book readers, as well as smart toys and portable car navigation devices.
[0153] (4) Server: A device that provides computing services. The components of a server include a processor, hard disk, memory, system bus, etc. Servers are similar to general computer architectures, but because they need to provide highly reliable services, they have higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.
[0154] (5) Other electronic devices with data interaction functions.
[0155] In some embodiments, this application also provides a mobile platform on which the computer device described in any embodiment of this application is installed. The mobile platform includes, but is not limited to, vehicles, tracked robots, bipedal robots, quadrupedal robots, etc., wherein the vehicle can be a passenger car, pickup truck, truck, etc. It should be noted that the above are merely examples, and this application does not limit the specific form of the mobile platform.
[0156] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0157] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable 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, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. 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 of the technical features. Such 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 this application.
Claims
1. A method for detecting QR codes on the outer wall of a lens, comprising: Control the coaxial main lens to perform a single exposure to obtain the original image of the annular stretching of the cylindrical lens under test; The annular stretching original image is formed by the image of the circumferential outer wall of the cylindrical lens under test being reflected once by the continuous conical reflecting surface of the tilted annular reflector to the imaging target surface of the coaxial main lens. Identify the inner and outer ring contours in the original stretched image, and delineate a double-ring region of interest containing the target QR code based on the inner and outer ring contours; Extract the annular image within the region of interest of the double rings, and perform a reverse mapping reconstruction from polar coordinates to rectangular coordinates on the annular image to unfold it into a planar image; The boundary of the target QR code is located in the planar image, and the target QR code image is cropped from the planar image based on the located boundary for information recognition.
2. The method according to claim 1, wherein, The control of the coaxial main lens to perform a single exposure to obtain the annular stretched original image of the cylindrical lens under test is performed under set anti-glare illumination conditions, which are established in the following way: A ring-shaped diffuse reflection light source independently mounted on the outside of the tilted ring mirror is activated to generate an illumination beam with a diffuse reflection distribution. The beam illumination angle of the annular diffuse reflection light source is set such that the beam illumination angle is smaller than the arrangement tilt angle of the tilted annular reflector.
3. The method according to claim 1, wherein, The step of identifying the inner and outer ring contours in the original stretched image and defining a double-ring region of interest containing the target QR code based on the inner and outer ring contours includes: Edge detection processing is performed on the original annular stretched image to extract the annular physical boundary imaged by the circumferential outer wall of the cylindrical lens under test, which serves as the inner and outer annular contours. Determine the coordinates of the reference center of the inner and outer annular contours, as well as the large and small ring radii corresponding to the outer and inner rings, respectively; Using the point corresponding to the reference circle center coordinates as the center, and combining the radius of the large ring and the radius of the small ring, a double-ring region of interest is delineated to define the range of the target QR code.
4. The method according to claim 3, wherein, The step of extracting the ring-shaped image within the double-ring region of interest includes: A double-ring mask is constructed based on the reference circle center coordinates, the radius of the large ring, and the radius of the small ring; The double-ring mask is applied to the original annular stretched image, and the area between the radius of the large ring and the radius of the small ring is retained as the effective information area; The pixel values of the regions located outside the radius of the large ring and inside the radius of the small ring in the original stretched annular image are forcibly set to a preset black mask value to remove background information and lens end face interference information in the original stretched annular image, thereby extracting the annular image containing the target QR code.
5. The method according to claim 3, wherein, The step of performing a reverse mapping reconstruction from polar coordinates to Cartesian coordinates on the annular image to unfold it into a planar image includes: Determine the calibration width and calibration height of the planar image to be generated, and construct a target Cartesian coordinate system based on the planar image. Set the grid coordinates of each target pixel in the planar image in the target Cartesian coordinate system according to the calibration width and the calibration height. For each target pixel in the planar image, the polar coordinate angle corresponding to the target pixel in the polar coordinate system is determined based on the coordinates of the target pixel in the width direction and the calibration width; and the polar coordinate radius corresponding to the target pixel in the polar coordinate system is calculated proportionally within the interval formed by the large ring radius and the small ring radius based on the coordinates of the target pixel in the height direction, the calibration height, the large ring radius, and the small ring radius; wherein, the polar coordinate system is established based on the annular image, and the pole of the polar coordinate system is the point corresponding to the coordinates of the reference circle center; Based on the reference circle center coordinates, the polar coordinate angles, and the polar coordinate radius, and combined with trigonometric function relationships, the source rectangular coordinates corresponding to each of the target pixels in the annular image are determined; The source pixel values are obtained in the annular image based on the source rectangular coordinates, and the source pixel values are assigned to each corresponding target pixel point to reconstruct a planar image that eliminates the annular stretching distortion point by point.
6. The method according to claim 5, wherein, The step of determining the polar coordinate angle of the target pixel in the polar coordinate system based on the coordinates of the target pixel in the width direction and the calibration width includes: Based on the ratio of the target pixel's coordinates in the width direction to the calibrated width, the coordinates are mapped to a range of redundancy angle thresholds to form information overlap regions at the beginning and end of the unfolded planar image; wherein, the redundancy angle threshold defines the maximum mapping angle of polar coordinates greater than 360°.
7. The method according to claim 5 or 6, wherein, The step of obtaining the corresponding source pixel value in the annular image based on the source rectangular coordinates and assigning the source pixel value to each corresponding target pixel point includes: When the source rectangular coordinates are non-integer floating-point coordinates, multiple neighboring reference pixels located around the floating-point coordinates are located in the annular image. Based on the spatial absolute distance relationship between the floating-point coordinates and each of the neighboring reference pixels, the distance weight corresponding to each of the neighboring reference pixels is calculated respectively. According to the distance weight, the pixel values of each neighboring reference pixel are spatially interpolated and weighted averaged. The calculated weighted average pixel value is then used as the final shaped pixel value of the target pixel to smooth the edge details of the planar image and eliminate pixel jaggedness in the unfolded image.
8. The method according to claim 1, wherein, The step of locating the boundary of the target QR code in the planar image and cropping the target QR code image from the planar image based on the located boundary for information recognition includes: A secondary outer contour extraction is performed on the planar image to find the physical boundary of the target QR code; Based on the found physical boundaries, generate the minimum bounding rectangle that surrounds the target QR code; The target QR code image is cropped from the planar image according to the vertex coordinate range of the minimum bounding rectangle; The cropped target QR code image is input into a standard QR code parsing engine for dot matrix data decoding to output the corresponding recognition result.
9. A lens outer wall QR code detection device, comprising: A coaxial main lens has an imaging target surface; the main optical axis of the coaxial main lens is configured to be collinear with the central axis of the cylindrical lens being tested. A tilted annular reflector has a continuous conical reflective surface. The tilted annular reflector is located in front of the entrance pupil of the coaxial main lens, and the central axis of the tilted annular reflector is arranged collinearly with the main optical axis. The inclined annular reflector defines a detection space for accommodating the cylindrical lens under test. The continuous conical reflective surface surrounds the detection space to reflect and converge the image of the circumferential outer wall of the cylindrical lens under test, which is located in the detection space, onto the imaging target surface in one go. This allows the coaxial main lens to acquire an annular stretched original image containing the full circumferential information of the target QR code through a single exposure. An image processing module, communicatively connected to the coaxial main lens, is configured to receive the annularly stretched original image and perform the method as described in any one of claims 1 to 8 to locate and identify the target QR code in the reconstructed planar image.
10. The apparatus according to claim 9, wherein, The lens outer wall QR code detection device also includes an annular diffuse reflection light source independently sleeved on the outside of the tilted annular reflector, and the annular diffuse reflection light source is arranged coaxially and concentrically with the tilted annular reflector. The annular diffuse reflection light source is used to provide a diffusely reflected illumination beam to the detection space, and the illumination angle of the annular diffuse reflection light source is configured to be smaller than the arrangement tilt angle of the tilted annular reflector.
11. The apparatus according to claim 9 or 10, wherein, The tilt angle of the tilted annular reflector is configured as a fixed tilt angle between 30° and 60°; The opening diameter of the tilted annular reflector near the entrance of the detection space is larger than the outer diameter of the cylindrical lens under test, so as to allow the cylindrical lens under test to extend into the inside of the tilted annular reflector.
12. A storage medium storing one or more programs including execution instructions, the execution instructions being readable and executable by an electronic device to perform the steps of the method of any one of claims 1-8.