Lamp bead position detection method and device as well as equipment and product
Through recursive segmentation method and image analysis technology, the spatial position and serial number matching of the lamp beads are identified, which solves the problems of color recognition errors, poor performance in complex scene processing, inefficient efficiency and poor scalability in the prior art, and achieves efficient and accurate matching of the lamp bead positions and serial number.
Patent Information
- Application Number
- CN202510104675.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-01-23
AI Technical Summary
The prior art has problems such as color recognition errors, poor performance in handling complex scenes, low efficiency and poor scalability when identifying the spatial position of the lamp beads matches the serial number.
The recursive segmentation method is used to process the lamp chain in segmentation. After each segmentation, the control segments present different apparent colors through lamp beads. The spatial position and apparent colors of the lamp beads are identified through image analysis, and the serial number range they belong to are determined, and the corresponding matching is achieved through the spatial position relationship and serial number relationship of adjacent lamp beads.
It significantly improves the accuracy and efficiency of matching lamp bead positions and serial numbers, can handle complex scenes and a large number of lamp beads, and has good scalability, adapting to lighting needs of different sizes and complexities.
Smart Images

Figure CN119533290B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of lighting control, and in particular to a method and device for detecting the position of a lamp bead, as well as equipment and products. Background Art
[0002] With the continuous development of intelligent lighting technology, light chains have evolved from traditional single-function lighting devices to intelligent devices that can be freely arranged according to user needs and create a variety of unique lighting effects. Users can control each lamp bead in the light chain through software to achieve personalized lighting effects. In order to achieve this precise control, an accurate spatial layout of the light chain is required, which can describe the serial position of each lamp bead in the light chain and its spatial position in physical space. The corresponding matching of the spatial position and serial position of the lamp bead is a difficult problem encountered in the industry.
[0003] In traditional technology, in order to identify the spatial position and serial number matching relationship of the lamp bead, a method of assigning a light control sequence consisting of multiple color codes to each lamp bead is usually adopted. Specifically, each lamp bead identifies itself by displaying a unique color coding sequence, and the camera unit then captures the image of the lamp bead during the light-emitting process. By analyzing these images, the identity of each lamp bead, that is, its serial number, and its position in the image space are determined. This method has some significant problems, including but not limited to:
[0004] First, the traditional technology of assigning a unique color coding sequence to each lamp bead has obvious limitations in practical applications. Since each lamp bead requires a unique color code, this requires the recognition device to be able to accurately recognize and distinguish a large number of color changes. This not only increases the difficulty of implementation, but also in actual environments, due to factors such as light interference and high color similarity, it is easy to cause color recognition errors. For example, in the case of dim ambient light or interference from other light sources, the camera unit may not be able to accurately capture the color code of the lamp bead, and thus cannot correctly identify the serial number of the lamp bead.
[0005] Secondly, traditional technologies perform poorly when dealing with complex scenes. When the lamp beads are arranged in a nonlinear or irregular manner, such as entangled, overlapping, or closely adjacent, it is difficult for traditional methods to accurately determine the position and serial number of each lamp bead. This is because traditional technologies usually assume that the lamp beads are relatively evenly distributed and independent of each other, but in complex scenes, this assumption is often not true. For example, when the lamp beads are closely arranged together, the color codes of adjacent lamp beads may interfere with each other, making it difficult for the camera unit to distinguish the colors of each lamp bead, resulting in serial number recognition errors.
[0006] Furthermore, the efficiency of traditional technology when processing a large number of lamp beads cannot be ignored. Since the serial number recognition of the entire lamp chain needs to be processed simultaneously, the amount of calculation increases sharply with the increase in the number of lamp beads. This not only leads to longer response times, but also may affect stability and reliability due to excessive consumption of computing resources on devices with limited resources. For example, in a large lamp chain system containing hundreds or even thousands of lamp beads, it may take several minutes or even longer to complete a complete serial number recognition, which is unacceptable for application scenarios that require real-time interaction.
[0007] In addition, traditional technologies have poor scalability. As the functions of smart light chain products continue to enrich and the application scenarios become increasingly diversified, the requirements for the number of lamp beads and control accuracy are also increasing. Due to its inherent design limitations, traditional technologies are difficult to adapt to these new requirements without large-scale system reconstruction. For example, when it is necessary to add more lamp beads to an existing light chain system or introduce more complex lighting effects, traditional technologies may need to redefine the color coding sequence of all lamp beads, which not only increases the workload but also may cause system compatibility issues.
[0008] These problems limit the application of smart light chain products in a variety of scenarios, especially in situations where fast and accurate matching of lamp bead positions and serial numbers is required. Therefore, a new technical solution is urgently needed to overcome these defects of traditional technology, so as to improve the accuracy and efficiency of lamp bead position and serial number matching, simplify the operation and reduce the risk of errors. Summary of the invention
[0009] The purpose of this application is to provide a method and device for detecting the position of a lamp bead, as well as equipment and products.
[0010] According to one aspect of the present application, a lamp bead position detection method is provided, including: sorting the lamp beads according to the total number of lamp beads in a lamp chain to determine the serial number of each lamp bead; recursively segmenting the light chain according to the serial number to obtain the serial number range of the lamp beads covered by the multiple segments, and after each segmentation, controlling each segment obtained in the current segmentation to present different apparent colors from other segments through the lamp beads; identifying the spatial position and apparent color of the luminous lamp beads in the real-shot image of the light chain collected corresponding to each segmentation, and determining the serial number range to which the luminous lamp beads in the image belong according to the segment to which the apparent color belongs; determining the mapping relationship between the spatial position and the serial number of each lamp bead according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, so as to achieve corresponding matching between the spatial position and the serial number of the lamp bead.
[0011] According to another aspect of the present application, a lamp bead position detection device is provided, including: a serial number setting module, configured to sort the lamp beads according to the total number of lamp beads in the lamp chain, and determine the serial number of each lamp bead; a recursive segmentation module, configured to recursively segment the lamp chain according to the serial number to obtain the serial number range of the lamp beads corresponding to the multiple segments, and after each segmentation, control each segment obtained in the current segmentation to present different apparent colors between other segments through the lamp beads; an image analysis module, configured to identify the spatial position and apparent color of the luminous lamp beads in the real-shot image of the lamp chain collected corresponding to each segmentation, and determine the serial number range to which the luminous lamp beads in the image belong according to the segment to which the apparent color belongs; a matching execution module, configured to determine the mapping relationship between the spatial position and the serial number of each lamp bead according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, so as to achieve corresponding matching between the spatial position and the serial number of the lamp bead.
[0012] According to another aspect of the present application, a computer device is provided, including a central processing unit and a memory, wherein the central processing unit is used to call and run a computer program stored in the memory to execute the steps of the lamp bead position detection method.
[0013] According to another aspect of the present application, a computer program product is provided, including a computer program or computer instructions, and when the computer program or computer instructions are called and executed by a central processing unit, the steps of the lamp bead position detection method are executed.
[0014] Compared with traditional technologies, the present application has more beneficial effects. Through recursive segmentation, the complexity of matching the position and serial number of lamp beads is significantly reduced, and the number of color changes that the system needs to process is reduced, thereby improving the accuracy and reliability of recognition. When processing complex scenes, recursive segmentation can gradually narrow the recognition range, effectively avoiding the recognition errors caused by the uneven distribution of lamp beads in traditional technologies. Even when the lamp beads are closely arranged or irregularly distributed, the position and serial number of each lamp bead can be accurately determined. In addition, the segmented processing method greatly improves the efficiency of processing a large number of lamp beads, shortens the response time, and enables the system to better adapt to real-time interactive application scenarios. At the same time, the present application has stronger scalability and can flexibly adapt to the increase in the number of lamp beads and the complexity of lighting effects. There is no need to reconstruct the entire system on a large scale, which reduces the workload and improves the compatibility and adaptability of the system. These advantages make the present application have important practical application value and broad development prospects in the field of intelligent lighting. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] Figure 1 This is a schematic diagram of the electrical structure of an exemplary ambient light device of the present application;
[0017] Figure 2 It is a flowchart of the lamp bead position detection method in the embodiment of the present application;
[0018] Figure 3 It is a structural schematic diagram of a lamp bead position detection device in an embodiment of the present application;
[0019] Figure 4 It is a schematic diagram of the structure of the computer device in the embodiment of the present application. DETAILED DESCRIPTION
[0020] The lamp bead position detection method of the present application can be implemented as a computer program product, installed and run in a computer device. The computer device can be in various forms, including but not limited to various types of mobile terminals, desktop computers, devices with other functions such as atmosphere lighting devices, etc. The computer device carries a camera unit for obtaining a preview video so as to shoot the light chain to form a live image required for constructing the spatial layout of the light chain. The mobile terminal mentioned here can be a personal device such as a smart phone or a tablet computer.
[0021] See also Figure 1 As can be seen from the structural schematic diagram of an atmosphere light device provided in an embodiment of the present application, the atmosphere light device includes a controller 1, a light chain 2, and an image acquisition interface. The light chain 2 is electrically connected to the controller 1 so as to accept the control of the computer program running in the controller 1 and work together to realize the lighting effect playback.
[0022] The controller 1 generally includes a control chip, a communication component, and a bus connector. In some embodiments, the controller 1 may also be configured with a power adapter, a control panel, a display screen, etc. as required.
[0023] The power adapter is mainly used to convert AC power into DC power to power the entire atmosphere light device. The control chip can be implemented using various embedded chips, such as Bluetooth SoC (System on Chip), WiFi SoC, MCU (Micro Controller Unit), DSP (Digital Signal Processing) and other types of chips. The control chip usually includes a central processing unit and a memory, which are used to store and execute program instructions respectively to achieve the corresponding functions. The above types of control chips can have their own communication components, or they can be configured with additional communication components as needed.
[0024] The communication component can be used to communicate with external devices, for example, it can communicate with mobile terminals such as personal computers or various smart phones, so that after the user issues various configuration instructions through his mobile terminal, the control chip of the controller 1 can receive the configuration instructions through the communication component and complete the basic configuration to control the light chain. In addition, the controller 1 can also obtain the interface image of the terminal device or the real-time preview image captured by the camera unit 3 through the communication component.
[0025] The bus connector is mainly used to connect the power supply to the light chain 2 connected to the bus and provide the lighting effect playing instruction, so the corresponding pins of the power bus and the signal bus are provided. Therefore, when the light chain 2 needs to be connected to the controller 1, it can be connected to the bus connector through the corresponding connector of the light chain 2. The control panel usually provides one or more buttons for implementing the on-off control of the controller 1, selecting various preset lighting effect control modes, etc.
[0026] The display screen can be used to display various control information so as to cooperate with the buttons in the control panel to support the realization of human-computer interaction functions. In some embodiments, the control panel and the display screen can be integrated into the same touch display screen.
[0027] The light chain 2 in the atmosphere light device can be a light strip or a light string, which is flexible and can be molded into any shape of display layout. Each light chain 2 includes a plurality of lamp beads 20 connected in series, each lamp bead 20 serves as a light-emitting unit, and the number of lamp beads 20 in each light chain 2 can be the same and arranged at equal intervals. The lamp beads 20 in the same light chain 2 transmit the working current through the same set of cables connected to the bus, and the lamp beads 20 in the same light chain 2 can be connected in parallel in terms of electrical connection.
[0028] The image acquisition interface can be either a hardware interface or a software interface implemented in the controller 1. When it is a hardware interface, the image acquisition interface can be implemented as a camera unit 3, and the controller 1 loads a corresponding driver to drive the camera unit 3 to work. In one application, the camera unit 3 can be used to shoot a light chain to obtain a live image required to determine the spatial layout of the light chain. The camera unit 3 can be used to capture the interface image required to generate the lighting effect control data.
[0029] When the camera unit 3 is aimed at the target screen, such as the display desktop of the terminal device, or the camera unit 3 is aimed at the physical space environment, the image is captured at a certain frame rate, and the interface image can be captured. When it is a software interface, the image acquisition interface can be an image acquisition program implemented on the controller 1 side with the help of the graphics infrastructure technology provided by the operating system of the terminal device. The controller 1 is connected to the terminal device through various cables such as HDMI and Type-C cables, and the interface image of the terminal device can be continuously obtained with the support of the graphics infrastructure technology; of course, if the controller 1 and the terminal device pre-establish a wireless screen projection protocol, the controller 1 can also obtain the interface image of the terminal device through wireless communication. The graphics infrastructure technology of the operating system varies depending on the type of operating system. For example, the Windows operating system provides a corresponding technology, namely: Microsoft DirectX Graphics Infrastructure, referred to as DXGI, which can achieve this function.
[0030] It can be seen that when the image acquisition interface is responsible for collecting environmental reference images, the specific environment for collecting images can be flexibly set by the user. For example, when the image acquisition interface is a camera unit 3, the user can aim the camera unit 3 at the graphical user interface of the computer to shoot to collect the corresponding interface image as the target image for playing the lighting effect, so that the light chain 2 can generate corresponding lighting effect description data based on the interface image; the user can also aim the camera unit 3 at a physical space environment such as an outdoor environment, and record the real scene image as an environmental reference image, so that the light chain 2 can generate lighting effect description data corresponding to the real scene.
[0031] When the atmosphere lighting device wants to play the lighting effect according to the lighting effect description data, its controller 1 needs to provide the serial number and spatial position of each light-emitting unit in its light chain 2 with the help of the spatial layout of the light chain, and parse the corresponding lighting effect description data into the control data of each light-emitting unit according to the spatial position of each light-emitting unit, and encapsulate the control data of each light-emitting unit into lighting effect control data in the order of the serial number, and then send the lighting effect control data to the corresponding light chain, and the control chip of each light-emitting unit in the light chain extracts its own corresponding control data, and controls each light-emitting element therein to emit corresponding color light according to the control data, so that the whole lighting effect can be played under the synergistic effect of the color light emitted by each light-emitting unit.
[0032] It is not difficult to understand that the computer device of the present application is equipped with a camera unit and a graphical user interface, wherein the camera unit 3 can be used to record the scene image to obtain a preview image, and generate the spatial layout of the light chain based on this. The spatial layout of the light chain describes the mapping relationship between the serial number of the lamp beads in the light chain and the spatial position of the light chain in the image space corresponding to the physical space in a preset mapping relationship table. Based on this, the computer device can also generate a corresponding light chain model based on the spatial position of each lamp bead in the light chain spatial layout and display it in the graphical user interface, so that the user can edit the control data of each lamp bead in the light chain model to construct the corresponding lighting effect. Then, the computer device can convert the lamp beads in the light chain model into the corresponding relationship between their spatial position and the serial number according to the information provided by the light chain spatial layout, and the light effect control data that can be parsed by the control chip of each lamp bead in the light chain is used to control the light chain to play the corresponding lighting effect.
[0033] See also Figure 2 In some embodiments, the lamp bead position detection method of the present application is described by taking the computer device used as a mobile terminal as an example for easy understanding. The method includes:
[0034] Step S5100, sorting the lamp beads according to the total number of lamp beads in the lamp chain, and determining the serial number of each lamp bead;
[0035] The total number of lamp beads in the light chain can be set manually or determined by querying the type of the light chain. According to the total number of lamp beads in the light chain, each lamp bead is numbered according to certain rules, so as to give each lamp bead a unique serial number. The "serial number" here refers to the order in which the lamp beads are arranged in the light chain, which can be sorted according to natural numbers.
[0036] For example, if a light chain contains 100 lamp beads, these lamp beads will be numbered from 1 to 100 in sequence. The numbering rule can be a simple linear sorting, that is, starting from one end of the light chain, each lamp bead is assigned an increasing serial number in turn. This sorting method is simple and intuitive, easy to implement, and can provide a clear basis for subsequent recursive segmentation.
[0037] Step S5200, recursively segmenting the light chain according to the serial number to obtain the serial number range of the lamp beads covered by the multiple segments, and after each segmentation, controlling each segment obtained by the current segmentation to present different apparent colors with other segments through the lamp beads;
[0038] The light chain is recursively segmented according to the serial number. Specifically, the light chain is divided into multiple segments according to the serial number of the lamp beads. Each segment contains the serial number of the lamp beads within a certain range, so the serial number range of each segment is determined. After each segmentation operation, the lamp beads in each segment obtained by the current segmentation are controlled to present different apparent colors, or at least each segment is controlled to present different apparent colors relative to other segments, so as to facilitate subsequent identification and distinction. The apparent color is the color that can be observed by the human eye when the lamp beads emit light or not emit light.
[0039] For example, suppose a light chain contains 100 lamp beads, which are numbered from 1 to 100. These 100 lamp beads can be first segmented into 5 segments with 20 lamp beads as a segment. The serial number range of the lamp beads in each segment is 1-20, 21-40, 41-60, 61-80, and 81-100. Then, the lamp beads in these 5 segments are controlled to display five different apparent colors: red, orange, yellow, green, and blue. In actual operation, a control signal can be sent to the lamp beads through a mobile terminal to make the lamp beads display according to the preset color.
[0040] This recursive segmentation method can be further refined. Based on the initial segmentation, each segment can be further segmented. Taking the first segment (1-20) as an example, it can be divided into two small segments, each of which contains 10 lamp beads, with serial number ranges of 1-10 and 11-20 respectively, and the lamp beads in these two small segments are controlled to display purple and pink respectively. In this way, the number of lamp beads in each segment can be gradually reduced until the preset termination condition is met, such as the number of lamp beads in the segment is less than or equal to 2, or the preset maximum number of segmentations is reached.
[0041] In the segmentation process, recursive segmentation refers to repeatedly segmenting the light chain according to certain rules, and each segmentation is based on the result segment of the previous segmentation. Apparent color control refers to sending a specific control signal to the lamp beads through the mobile terminal, so that the lamp beads corresponding to each serial number covered by the corresponding segment display the preset apparent color. The combination of these two technical means can accurately identify and distinguish the position and serial number of each lamp bead in a complex lamp bead layout.
[0042] In addition, the recursive segmentation strategy can be adjusted according to the actual application scenario. For example, the number and size of each segment can be determined according to the distribution density of the lamp beads, the shape of the light chain, or the expected recognition accuracy. In some application scenarios, only one or two segmentations may be required to achieve the recognition purpose; while in other complex application scenarios, multiple segmentations may be required. This flexibility enables the method to adapt to a variety of different smart light chain products and usage scenarios.
[0043] It should be pointed out that in the process of controlling the lamp beads of each segment to present different apparent colors, considering that the light-emitting control of each lamp bead of the light chain is usually implemented by providing corresponding color values for each lamp bead, for the lamp beads that do not need to emit light, information such as null values will also be filled in. In this case, such lamp beads will not emit the color of working with electricity, only their physical colors. According to this principle, the fact that the lamp beads do not use color values to emit light should also be understood as a special apparent color achieved by controlling the lamp beads not to emit light through the technical solution of the present application using means such as null values. Accordingly, in some embodiments, a certain segment can be controlled to emit light using color values to display a color, while one or more other segments do not emit light and display their physical colors, so that the former segment and the other multiple segments present different apparent colors, and the latter can be understood as using "dark colors". When identifying the segment whose light emission is controlled using color values, since the other segments use "dark colors", it is less likely to cause interference to the former, which can improve the recognition efficiency of the former.
[0044] In one embodiment, for a lamp chain with a large number of lamp beads, such as a lamp chain with thousands of lamp beads, the serial numbers of the lamp beads can be processed by interval grouping, for example, the first group is a lamp group with an odd serial number, and the second group is a lamp group with an even serial number. Then, the recursive segmented recognition process of this step is applied to the two lamp groups respectively, and the role is the same as that of not grouping, as long as the interval relationship between the serial numbers is properly handled. Such processing can improve recognition efficiency by increasing parallelism.
[0045] Step S5300, identifying the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determining the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs;
[0046] In this step, it is necessary to collect and analyze real-life images of the light chain so as to identify the spatial position and apparent color of the light-emitting lamp beads in the real-life images of the light chain at different segmentation stages through the real-life images, and thereby determine the serial number range to which the light-emitting lamp beads in the image belong.
[0047] First, use the camera unit to collect real-time images of the light chain at different segmentation stages. The camera unit can be a camera of a mobile terminal or a dedicated image acquisition device. When collecting images, ensure that the parameter settings of the camera unit (such as exposure, aperture, etc.) can optimize the recognition effect of the lamp beads. For example, the exposure or aperture can be adjusted to ensure that the brightness of the lamp beads is clear enough while avoiding color distortion caused by overexposure.
[0048] Next, the spatial position of each light-emitting lamp bead in the image and the apparent color displayed by it are identified from the real-shot image. This can be achieved through image processing technology. In one embodiment, the functions in the OpenCV library are used for image analysis. Specifically, the image can be preprocessed first, including grayscale, binarization and other operations to highlight the luminous outline of the light-emitting lamp bead, and determine the selection box and corresponding regional image corresponding to its luminous outline. Then, a color recognition algorithm, such as color threshold segmentation based on the HSV color space, is used to identify the apparent color of the lamp bead through the regional image of the light-emitting lamp bead. For example, for red lamp beads, a specific HSV threshold range can be set to identify the pixels in the image that belong to this range as red lamp beads. In another embodiment, an image target recognition model implemented based on a basic model such as Yolo can be used for special pre-training, and then the real-shot image can be inferred through the image target recognition model to obtain the selection box of the regional image of each light-emitting lamp bead, and then the apparent color is determined by calculation based on the pixel value of the regional image. Since a selection box can be obtained in these embodiments, the selection box actually also gives the spatial position of the light-emitting lamp bead in the real-shot image. In a typical embodiment, the geometric center position of each selection box can be used as the specific spatial position of the light-emitting lamp bead.
[0049] According to the apparent color of the light-emitting lamp beads in the real-shot image, each light-emitting lamp bead is classified into the corresponding segment. Since the lamp beads in each segment are controlled to present different apparent colors in the segmentation step, by identifying the color of the lamp beads, it is possible to determine which segment the lamp bead belongs to, and then determine its serial number range. For example, if a red lamp bead is identified in the real-shot image, and according to the segmentation control, red represents the first segment (1-20), then it can be determined that the serial number of this lamp bead is between 1 and 20.
[0050] In addition, in order to improve the accuracy of recognition, a combination of multiple image recognition technologies can be used. For example, in addition to color recognition, shape recognition, brightness analysis and other methods can also be combined. In terms of shape recognition, the circular feature of the lamp bead can be used to assist in identifying the lamp bead by detecting the circular outline in the image. In terms of brightness analysis, the characteristic balance attributes of the lamp bead, such as the brightness range, radius, and approximation of the circle, can be calculated to further confirm the position and color of the lamp bead.
[0051] In practical applications, some special situations can be handled in combination, such as color interference between lamp beads, the influence of ambient light, etc. In order to solve these problems, some advanced image processing technologies can be used, such as adaptive binarization, contour recognition, feature extraction, etc. For example, adaptive binarization can better adapt to images under different lighting conditions and improve the recognition rate of lamp beads. Contour recognition can accurately locate the boundaries of lamp beads, and can accurately identify them even when there is partial overlap between lamp beads. Feature extraction can quantitatively analyze the shape, color, brightness and other characteristics of lamp beads, thereby improving the accuracy and reliability of recognition.
[0052] It should be pointed out that since there are usually multiple lamp beads in each segment, and the number of luminous lamp beads identified in the actual image corresponding to this segment is usually multiple, in this case, no association has been established between the spatial position of each lamp bead in the actual image and the logical serial number in the same segment, and corresponding matching has not been achieved, so it is necessary to continue processing through subsequent steps.
[0053] Step S5400, determine the mapping relationship between the spatial position and serial number of each lamp bead based on the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, so as to achieve a corresponding match between the spatial position and serial number of the lamp bead.
[0054] By determining the mapping relationship between the spatial position and serial number of each lamp bead, the corresponding matching between the serial number and the spatial position of the lamp bead can be achieved. This needs to be achieved by reasoning based on the spatial position relationship of adjacent lamp beads in the real-shot image and the serial number range to which they belong. Specifically, the spatial position of each lamp bead in the real-shot image is first obtained, and these spatial positions are obtained through the image processing technology disclosed in the previous article.
[0055] Since step S5300 is segmented according to the recursive principle, the granularity of the last segmentation is the smallest, which can reach the amplitude of one or two lamp beads. At this time, when the recursive segmentation reaches the minimum granularity, for example, each segment contains only one lamp bead, its spatial position and serial number must be uniquely matched; when two lamp beads are reached, their corresponding matching relationship can be determined by comparing the spatial position and serial number relationship of these two lamp beads with the adjacent matched lamp beads. For example, if the serial numbers of the lamp beads in the adjacent segments are known to be 15 and 18, and the two lamp beads in the current segment are located between the two known lamp beads, then the serial numbers of the two lamp beads can be inferred to be 16 and 17 in combination with their proximity relationship in the real-shot image. Since the spatial positions of the two lamp beads have been determined, the serial number and spatial position of each lamp bead are directly mapped to achieve their corresponding matching.
[0056] According to the recursive principle, through recursive backtracking, the corresponding matching relationship of each lamp bead in the upper segment can be inferred and determined based on the corresponding matching relationship of each lower segment of the upper segment. Once the matching relationship of the lamp beads with the smallest granularity is determined, it can be traced back upward to gradually determine the matching relationship of the lamp beads in the larger segment. This process is similar to building a decision tree, from the leaf node (the segment with the smallest granularity) to the root node (the entire lamp chain). For the upper segment, if its lower segment has achieved corresponding matching lamp beads, but there are still missing ones, the corresponding inference can also be made to determine the matching relationship between the serial number and spatial position of the missing lamp beads.
[0057] That is to say, for each segment, in addition to using the lamp beads with the smallest granularity for matching, you can also use some of the lamp beads that have achieved corresponding matching to deduce the corresponding matching relationship between the serial number and spatial position of the lamp bead to be identified. For example, if the serial number and spatial position of some lamp beads in a segment are known, the serial number of the lamp bead to be identified can be inferred by analyzing the spatial distance and arrangement order between the lamp bead to be identified and these known lamp beads. This method is particularly effective when dealing with situations where some lamp beads cannot be directly identified due to obstruction or failure.
[0058] In actual operation, a variety of specific embodiments can be used to determine this mapping relationship. For example, when there are a large number of lamp beads with known spatial positions in a segment, the valid lamp beads can be verified directly by comparing the relative spatial positions between the lamp beads, and then their serial numbers and spatial positions can be determined to achieve corresponding matching. If there are a small number of lamp beads with known spatial positions in a segment, a linear fitting method can be used to predict the spatial position and serial number of unknown lamp beads based on the spatial position and serial number of the corresponding matched lamp beads to achieve corresponding matching. In addition, the brightness, color and other characteristics of the lamp beads can be combined to improve the accuracy of the matching through machine learning algorithms.
[0059] The mapping relationship data between the spatial position and serial number of the corresponding matching lamp beads can be added to the mapping relationship table. After the mapping relationship table is finalized, it can be used as the spatial layout of the light chain and can be used as the basis for interpreting the lighting effects, so that the light chain can parse and play the lighting effects according to the spatial layout of the light chain.
[0060] In some embodiments, after completing the entire recursive process, the spatial position and serial number of the lamp beads in the mapping relationship table can be constructed into a representation vector, and then these representation vectors are clustered with the help of clustering algorithms such as K-means and DBScan. After clustering, the lamp beads corresponding to the outlier representation vectors are excluded. Then, the mapping relationship data of the lamp beads in the mapping relationship table are fully checked to see if they are complete. If they are incomplete, step S5400 can be repeated to re-infer the spatial position of the missing lamp beads, and finally determine their corresponding serial numbers, and establish a corresponding matching relationship between the spatial position and the serial number. Finally, the construction of the entire mapping relationship table is completed. This method helps to reduce the error rate of lamp bead matching and improve the accuracy.
[0061] In other embodiments, the spatial positions of incorrectly matched lamp beads can be eliminated by detecting whether the straight-line distance between adjacent lamp beads in the mapping relationship table satisfies a preset statistical distance, and then step S5400 is reapplied to infer the missing lamp beads, thereby finally completing the construction of the mapping relationship table.
[0062] According to the above embodiments, the present application has significant advantages over the conventional technology in many aspects, including but not limited to:
[0063] First, the present application adopts a recursive segmentation method to segment the light chain according to the serial number of the lamp beads. After each segmentation, each segment is controlled to present a different apparent color, which effectively reduces the complexity of recognition, because in each segmentation step, only the lamp beads in the current segment need to be focused on, rather than the entire light chain. Compared with the traditional technology that requires defining a unique color coding sequence for each lamp bead, this greatly reduces the number of color changes that need to be processed, thereby reducing the difficulty of implementation and the possibility of error.
[0064] Secondly, this application performs well in dealing with complex scenes. Through recursive segmentation, even if the lamp beads are arranged in a nonlinear or irregular manner, such as entangled, overlapping, or closely adjacent, the recognition range can be gradually narrowed, and the position and serial number of each lamp bead can be accurately determined. This is because after each segmentation, the distribution of lamp beads in each small segment can be analyzed more carefully, avoiding the recognition errors caused by uneven distribution of lamp beads in traditional technologies.
[0065] Furthermore, the efficiency of this application in processing a large number of lamp beads has been significantly improved. Due to the use of segmented processing, the amount of calculation no longer increases sharply with the increase in the number of lamp beads. After each segmentation, only the lamp beads in the current segment need to be processed, which greatly shortens the response time and improves real-time performance.
[0066] In addition, the present application is more scalable. Due to the recursive segmentation method, when more lamp beads need to be added to the existing lamp chain system or more complex lighting effects need to be introduced, adjustments can be made flexibly without redefining the color coding sequence of all lamp beads. This not only reduces the workload, but also improves the compatibility and adaptability of the system.
[0067] On the basis of any embodiment of the method of the present application, the lamp chain is recursively segmented according to the serial number to obtain the serial number range of the lamp beads covered by the multiple segments, and after each segmentation, each segment obtained by the current segmentation is controlled to present different apparent colors with other segments through the lamp beads, including:
[0068] Step S5230, dividing the lamp beads of the target segment in the lamp chain into multiple segments according to the serial number, and each segment is associated with a different apparent color;
[0069] The target segment is determined according to the serial number range passed in by the recursive function. It can be the range covered by all the lamp beads in the entire lamp chain, or the range determined after a certain segment or interval grouping after segmentation. To facilitate the recursion, the recursive function can independently and orderly number the passed serial number range, or although it is not independently numbered, the grouping interval number must be clearly defined so that the change relationship between adjacent serial numbers can be clarified according to the grouping interval number, so as to facilitate subsequent operations.
[0070] Thus, the target segment is determined, that is, the part of the light chain that needs to be segmented. The target segment can be the entire light chain or a segment obtained after the previous segmentation. For example, if the light chain has a total of 100 lamp beads, numbered from 1 to 100, then the initial target segment is these 100 lamp beads.
[0071] Next, the lamp beads of the target segment are divided into multiple lower-level segments according to the preset number of segments based on the serial number. The basis for division can be equal division, or unequal division based on the distribution density of the lamp beads or other specific rules. For example, the target segment can be divided into two lower-level segments. If the target segment is lamp beads 1 to 100, it can be divided into two lower-level segments 1 to 50 and 51 to 100. Alternatively, if the lamp beads are densely distributed in certain areas, the number of lower-level segments in these areas can be appropriately increased.
[0072] Each sub-segment is associated with a different apparent color, which is used to distinguish different segments in subsequent steps. The choice of color should ensure that it can be clearly distinguished in the real-life image. For example, basic colors such as red, green, and blue can be used, or more complex color combinations such as purple, pink, etc. The color assignment can be pre-defined or dynamically generated, as long as the color of each sub-segment is unique.
[0073] Step S5240: according to the apparent color of each segment obtained by the current division, control each lamp bead of the corresponding segment in the light chain to emit the apparent color corresponding to the segment, so as to collect the real shot image;
[0074] Each lamp bead in the corresponding segment of the light chain is controlled to emit a preset apparent color. Different segments can be distinguished by different apparent colors. Real-time images of the light chain in the luminous state of these segments are collected, which can be used to identify the spatial position of the luminous lamp bead in the real-time images.
[0075] For each segment obtained by each recursive division, according to the apparent color of each segment obtained by the current division, a control signal is sent to the light chain to instruct the lamp beads of the corresponding segment in the light chain to emit a specified color. For example, the corresponding control instruction can be sent to the light chain through an exemplary mobile terminal. The control instruction should include the serial number and apparent color of the lamp beads of each segment. When the light chain receives the control instruction, it can control the corresponding lamp beads to emit the specified apparent color according to the specified serial number.
[0076] In a specific embodiment, if a segment is assigned red, then all the lamp beads in the segment will be controlled to display red. This can be achieved by sending a control instruction containing a color code to the lamp beads. The color code can be a predefined color index or a specific RGB value. For example, red can be represented by an RGB value (255, 0, 0), which will be sent to the specified lamp bead to make it emit red light.
[0077] On the other hand, after the control instruction is issued, the camera unit can also be automatically called to collect real-life images of the light chain as a basis for identifying the spatial positions of the lamp beads in step S5300.
[0078] Step S5250, check whether each segment obtained by the current segmentation meets the preset termination condition. If not, take the current segment being detected as the next target segment to iterate the above process to continue recursive segmentation. The termination condition is that all the lamp beads in the current segment are suitable for determining their spatial position and serial number to achieve corresponding matching, or the number of lamp beads in the current segment is less than or equal to two.
[0079] The recursive process requires a preset termination condition to ensure that the segmentation operation can be stopped at the appropriate time to avoid infinite recursion. In this application, the termination condition can include the following two or any one of them: one is that all the lamp beads in the current segment are suitable for determining the corresponding matching relationship between their spatial position and serial number; the other is that the number of lamp beads in the current segment is reduced to two or less. These two conditions ensure that the recursive segmentation process can be sufficiently refined to accurately identify the spatial position and serial number of each lamp bead, and can be stopped in time after reaching sufficient accuracy, avoiding unnecessary calculations and waste of resources.
[0080] In actual operation, after each segmentation, each newly generated segment is automatically checked to see if it meets the above termination conditions. If the number of lamp beads in a newly generated segment as the current segment has been reduced to two or less, then this segment will no longer be segmented. For example, if a segment has only two lamp beads left in the last level of the segment after multiple recursive segmentation, then these two lamp beads will directly match the spatial position and serial number without further segmentation. This is because when the number of lamp beads in a segment is small, their serial numbers and positional relationships can be determined through simple comparison and inference, without the need for complex segmentation operations.
[0081] On the other hand, if in a certain segmentation step, the spatial position and serial number matching relationship of all lamp beads can be accurately inferred through the current segmentation information, then the recursive segmentation process of this segment will also stop. For example, if after one segmentation, the lamp beads in a certain segment are very evenly distributed, and have obvious position and color distinctions from the lamp beads in the adjacent segments, and the number of luminous lamp beads detected in the real-shot image corresponds one-to-one to the number of lamp beads defined by the serial number range of the current segment, then it can be considered that the position and serial number of the lamp beads in this segment have been accurately determined, and no further segmentation is required.
[0082] If the termination condition is not met, the segment currently being detected will be used as the target segment for the next recursive segmentation, and the above segmentation and color control process will continue. This process will be repeated until all segments meet the termination condition. For example, if a segment still contains a large number of lamp beads after the first segmentation, and the position and serial number of each lamp bead cannot be directly determined, then this segment will be divided into smaller segments again, and different apparent colors will be assigned to each new segment, and recursive segmentation will continue.
[0083] In this way, the recursive segmentation process can flexibly adapt to the layout of lamp beads of different complexity, which not only ensures the recognition accuracy in complex scenes, but also improves the processing efficiency in simple scenes. This method fully utilizes the advantages of the recursive algorithm, gradually refines the segmentation, gradually narrows the recognition range, and finally achieves accurate matching of the position and serial number of each lamp bead.
[0084] After executing the above embodiments, the significant technical advantages achieved by the present application are mainly reflected in the following aspects. First, through the recursive segmentation method, the complex lamp bead layout problem can be decomposed into multiple smaller and more manageable sub-problems. This method not only reduces the complexity of the problem, but also enables each sub-problem to be processed independently, thereby improving the processing efficiency and accuracy of the entire system. Secondly, the preset termination condition ensures the timely stop of the recursive process, avoids unnecessary calculations and waste of resources, and further improves the efficiency of the system. In addition, by assigning different apparent colors to each segment, it not only enhances the distinguishability between the lamp beads, but also provides an intuitive basis for subsequent spatial position and serial number matching, further improving the accuracy and reliability of the matching. Finally, the flexibility of this method enables it to adapt to lamp bead layouts of various complexities. Whether it is a simple linear layout or a complex nonlinear layout, it can achieve accurate identification and matching by gradually refining the segmentation, thereby improving the versatility and applicability of the system. In summary, the technical advantages achieved by the above-mentioned embodiments of the present application not only improve the efficiency and accuracy of lamp bead position and serial number matching, but also enhance the flexibility and adaptability of the system, providing strong technical support for the development and application of smart light chain products.
[0085] Based on any embodiment of the method of the present application, before dividing the lamp beads of the target segment in the lamp chain into multiple segments according to the serial number, the method includes:
[0086] Step S5210: group the serial numbers of the lamp beads in the lamp chain according to a preset interval rule to obtain a serial number set corresponding to each group;
[0087] The serial numbers of the lamp beads in the light chain are grouped according to the preset interval rules. The "interval rule" here refers to dividing the serial numbers of the lamp beads into different groups according to a certain rule. For example, the lamp beads with odd numbers can be grouped into one group, and the lamp beads with even numbers can be grouped into another group. This grouping method is simple and intuitive, easy to implement, and can ensure that the number of lamp beads in each group is roughly equal, providing a good foundation for subsequent parallel processing. In addition to odd-even grouping, grouping can also be performed according to other rules, such as determining the interval of the grouping according to the distribution density of the lamp beads, the shape of the light chain, or the expected recognition accuracy. For example, if the lamp beads are densely distributed in certain areas, the number of groups in these areas can be appropriately increased to improve the recognition accuracy.
[0088] Step S5220, start the corresponding thread for each group, input the lamp bead serial number set and spacing rule in each group into the thread, and the thread uses the corresponding group as the target segment and performs recursive segmentation on the target segment.
[0089] Next, start the corresponding thread for each group. Each thread is responsible for processing the lamp beads in a group, and uses the lamp bead sequence number set and interval rules in the group as input, for example, in the form of group interval number, and recursively segmenting the group as the target segment. This parallel processing method can make full use of the multi-core processor resources of modern computers. Each thread can perform segmentation and color control operations independently, thereby speeding up the entire lamp bead position detection process. For example, if there are 1,000 lamp beads in the light chain, each group has 500 lamp beads after being grouped according to odd and even numbers. Start a thread for each group, and each thread processes the recursive segmentation of 500 lamp beads respectively, which can shorten the processing time by half.
[0090] When implementing recursive segmentation, each thread operates according to the same recursive method as described above. That is, the lamp beads of the target segment are divided into multiple lower-level segments according to the serial number, and each lower-level segment is associated with a different apparent color. Then, each lamp bead of the corresponding segment in the light chain is controlled to emit the corresponding apparent color of the segment, so as to collect real-time images. Finally, it is detected whether each segment obtained by the current segmentation meets the preset termination condition. If not, the recursive segmentation continues until all segments meet the termination condition.
[0091] After executing the above embodiments, the significant technical advantages achieved by the present application are mainly reflected in the following aspects. First, by grouping the serial numbers of the lamp beads according to the preset interval rules, the large-scale lamp bead data set can be effectively decomposed into multiple smaller and more manageable subsets. This processing method reduces the density of lamp beads in each group, helps to reduce the color mixing interference between the light-emitting lamp beads, and improves the recognition accuracy. This grouping strategy not only simplifies the complexity of data processing, but also provides a basis for subsequent parallel processing, so that each group can be processed independently, thereby improving the processing efficiency. Secondly, the corresponding thread is started for each group for recursive segmentation processing, which makes full use of the multi-core processor resources of modern computers and realizes parallel computing. This parallel processing method significantly reduces the processing load of a single thread, speeds up the speed of lamp bead position detection, and improves the response time. In addition, since each thread independently processes a group, the dependence and synchronization overhead between threads are reduced, and the stability and reliability of the system are further improved. Finally, this strategy based on grouping and parallel processing has good scalability and can adapt to light chain systems of different sizes. Regardless of the size of the light chain, the performance can be optimized by appropriately adjusting the grouping rules and the number of threads to meet the needs of different application scenarios.
[0092] On the basis of any embodiment of the method of the present application, identifying the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determining the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs, includes:
[0093] Step S5310: using a camera unit to collect real-shot images of the light chain at different segmentation stages, wherein the lamp beads of each segment in the real-shot images display the corresponding apparent color of the segment;
[0094] By utilizing a camera unit to capture images of the light chain at different segmentation stages, the lamp beads in each segment in these images will display the corresponding apparent color of that segment, providing a basis for subsequent image analysis and lamp bead identification.
[0095] The camera unit can be called up in advance so as to obtain a preview image of the light chain through the user's cooperation operation. Then, the computer program pre-implemented in the present application identifies the high-definition image frame corresponding to the switch of the apparent color from the preview image as the real-shot image. Each switch of the apparent color actually corresponds to the sending of an apparent color control instruction to the light chain after each segmentation. This relationship can be used to delay a preset period of time after each control instruction is issued to cooperate with the light chain to complete the driving of the light to emit light and extract the real-shot images corresponding to each switch. These real-shot images are constructed into an image sequence, and the luminous lamp beads can be identified based on this image sequence.
[0096] In order to ensure that the collected images can accurately reflect the status of the lamp beads, the parameters of the camera unit include exposure, aperture size, ISO sensitivity, etc., which together affect the image quality and the recognition effect of the lamp beads. These parameters can be pre-set or dynamically adjusted to obtain high-quality real-life images.
[0097] Step S5320: Identify the spatial position of each light-emitting lamp bead in the real-shot image and the apparent color displayed by each light-emitting lamp bead in the real-shot image from the real-shot image;
[0098] Identifying the spatial position and apparent color of each light bead in the real-shot image is the key to realizing the detection of the position of the light bead. This can be achieved through two main technical approaches: one is the image processing method based on the OpenCV library function, and the other is the method based on the pre-trained image target recognition model. These two methods have their own advantages and can be selected according to specific application scenarios and needs.
[0099] OpenCV provides a wealth of image processing functions that can be used for image preprocessing, feature extraction, and object recognition. In this application, OpenCV functions can be used to perform preprocessing operations such as grayscale, binarization, and edge detection on the real-shot image to enhance the features of the lamp beads in the image. Then, the contour detection function is used to identify the contour of each luminous lamp bead in the image to determine its spatial position in the real-shot image. In addition, the color space conversion function can be used to convert the image from the RGB color space to the HSV color space in order to more accurately identify the apparent color of the lamp beads. By setting a specific color threshold, pixels in the image that belong to a specific color range can be identified as lamp beads of the corresponding color.
[0100] The method based on a pre-trained image target recognition model is a deep learning-based technology. This method first requires collecting a large amount of image data with the position and color of the lamp beads annotated, and then using this data to train an image target recognition model, such as a model based on a convolutional neural network (CNN). The trained model can automatically learn the characteristics of the lamp beads in the image and identify the spatial position and apparent color of each luminous lamp bead in a given real-shot image. In practical applications, the real-shot image is input into the trained model, and the model outputs the position coordinates and color label of each lamp bead in the image. The advantage of this method is that it can handle complex image backgrounds and changes in the shape of lamp beads, and has high recognition accuracy and robustness.
[0101] When identifying the spatial position of the light-emitting lamp beads, the coordinates of the center point of each lamp bead can be used as a representative of its spatial position. Through the above two methods, the coordinates of the center point of each light-emitting lamp bead in the real-shot image can be accurately determined, thereby providing accurate data support for the subsequent lamp bead position and serial number matching.
[0102] Step S5330: classify each light-emitting lamp bead into a corresponding segment according to the apparent color of the light-emitting lamp bead in the real-shot image, and determine that the serial number of the light-emitting lamp bead belongs to the serial number range of the segment.
[0103] According to the apparent color of each light-emitting lamp bead identified in the real-shot image, these lamp beads can be classified. Since the lamp beads of each segment are controlled to present different apparent colors in the segmentation step, by identifying the apparent color of the lamp bead, it is possible to determine which segment the lamp bead belongs to. For example, if a red lamp bead is identified in the real-shot image, and according to the segmentation control, red represents the first segment, then it can be determined that the lamp bead belongs to the first segment.
[0104] Next, determine whether the serial number of the light-emitting lamp bead belongs to the serial number range of the segment. Since each segment has determined the lamp bead serial number range it covers when it is segmented, once the lamp bead is classified into a specific segment, the range of its serial number can be directly determined.
[0105] After executing the above embodiments, the significant technical advantages achieved by the present application are mainly reflected in the following aspects. First, by using the camera unit to capture images of the light chain at different segmentation stages, accurate basic data is provided for subsequent image analysis and lamp bead recognition. This image acquisition method not only ensures the real-time and accuracy of the data, but also improves the image quality by optimizing the parameter settings of the camera unit, thereby enhancing the effect of lamp bead recognition. Secondly, by adopting an image processing method based on the OpenCV library function and a deep learning technology based on a pre-trained image target recognition model, high-precision recognition of the spatial position and apparent color of the luminous lamp beads is achieved. The combination of these two methods not only improves the accuracy and robustness of recognition, but also can adapt to different application scenarios and complex image backgrounds. In addition, by classifying the lamp beads into corresponding segments according to the apparent color and determining their serial number range, a preliminary match between the lamp bead position and the serial number is achieved, laying a solid foundation for the final accurate matching. This process not only improves the matching efficiency, but also reduces the possibility of false matching and improves the overall performance of the system.
[0106] On the basis of any embodiment of the method of the present application, according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, the mapping relationship between the spatial position and the serial number of each lamp bead is determined to achieve the corresponding matching between the spatial position and the serial number of the lamp bead, including:
[0107] Step S5310: For each segment, when the number of lamp beads in the segment is less than or equal to two, the serial number of the lamp bead and its spatial position in the actual image are inferred and determined based on the serial number relationship and spatial position relationship between the lamp bead and the adjacent segments of the segment to achieve corresponding matching.
[0108] In this embodiment, when the number of lamp beads in each segment is reduced to two or less, a specific strategy can be used to determine the mapping relationship between the spatial position and serial number of these lamp beads. The key to this strategy is to use the information of the corresponding matching lamp beads in the known adjacent segments, and to infer the specific position and serial number of the lamp beads in the current segment by analyzing the serial number relationship and spatial position relationship.
[0109] Specifically, when the number of lamp beads in a segment is reduced to two, considering that the serial number range of the adjacent segments of this segment is known and determined, the position and serial number of the two lamp beads can be determined by the end serial number in the serial number range of the adjacent segments. For example, if the serial numbers of the end adjacent lamp beads in the adjacent segments are 15 and 18 respectively, and the two lamp beads in the current segment are located between these two known lamp beads, then it can be inferred that the serial numbers of the lamp beads in the current segment are 16 and 17. By analyzing the relative positions of the two lamp beads in the real-shot image, their specific spatial positions can be further determined. If a lamp bead is closer to the lamp bead with serial number 15, then it can be matched as the lamp bead with serial number 16; conversely, if a lamp bead is closer to the lamp bead with serial number 18, then it can be matched as the lamp bead with serial number 17. When the number of lamp beads in a segment is one, since there is only one serial number in the serial number range of the segment, at this time, the spatial position of this lamp bead and the serial number must achieve corresponding matching.
[0110] The effectiveness of this method lies in that it utilizes the physical arrangement order of the lamp beads on the lamp chain and the known matching information. Through simple comparison and inference, it can accurately determine the position and serial number of a small number of lamp beads. This not only improves the efficiency of recognition, but also reduces the errors that may occur when processing large amounts of data. In addition, this method does not require complex calculations or additional equipment, but can be implemented by using existing image data and matched lamp bead information.
[0111] In practical applications, this inference method based on neighbor relationships can be applied to a variety of situations. For example, when part of the light chain is blocked or damaged, making it impossible to directly identify some lamp beads, the position and serial number of these lamp beads can be inferred by analyzing the information of the surrounding identifiable lamp beads. Similarly, when the layout of the light chain is more complex, such as bends or intersections, this method can also work effectively because it relies on relative position relationships rather than absolute coordinate positions.
[0112] On the basis of any embodiment of the method of the present application, according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, the mapping relationship between the spatial position and the serial number of each lamp bead is determined to achieve the corresponding matching between the spatial position and the serial number of the lamp bead, including:
[0113] Step S5320: for each segment, compare the number of lamp beads that have been identified and whose spatial positions are determined in the real-shot image with the number of lamp beads to be identified obtained by dividing the segment, to obtain a comparison result;
[0114] For each segment, firstly, the number of lamp beads whose spatial positions have been determined in the real-shot image (the number of lamp beads that have been identified) needs to be compared with the number of lamp beads that should be included in the segment according to the division (the number of lamp beads to be identified). This comparison process is to determine the identification status of the lamp beads in the current segment so as to adopt the corresponding matching strategy.
[0115] Specifically, the number of recognized lamps refers to the number of lamp beads that have been successfully recognized in the real-shot image through image processing technology (such as color recognition, shape recognition, etc.). The number to be recognized is the number of lamp beads preset when dividing the segments, that is, the number of lamp beads that the segment should theoretically contain. By comparing these two numbers, a comparison result can be obtained, which can be obtained by subtracting the number of recognized lamps from the number of lamps to be recognized for characterization and to guide subsequent matching operations.
[0116] For example, if the number of lamps to be identified in a segment is 10, and the number of lamps identified in the real-shot image through image processing technology is also 10, it means that all lamp beads in the segment have been successfully identified. In this case, the next step of matching can be performed directly.
[0117] If the number of identified lamps is less than the number to be identified, this may indicate that some lamp beads were not identified in the real-life image, possibly due to occlusion, damage, or other interference factors. In this case, a specific method is needed to infer the location of the missing lamp beads, such as using information such as the average spacing of known lamp beads.
[0118] On the contrary, if the number of identified lamps exceeds the number to be identified, this may mean that there are lamp beads that do not belong to the current segment in the real-shot image (for example, caused by mirror reflection), or the same lamp bead is repeatedly identified. In this case, it is necessary to exclude redundant lamp beads by analyzing the common features of the same segment (such as color consistency, distribution similarity, etc.).
[0119] Step S5330: When the comparison result shows that the identified number is the same as the number to be identified, the spatial position of each lamp bead belonging to the segment in the real-shot image is matched with each serial number within the serial number range of the segment;
[0120] When the number of identified lamp beads in a segment in the real-shot image is the same as the number of lamp beads to be identified in the segment, it means that all lamp beads in the segment have been successfully identified. In this case, the spatial position of the lamp beads and the serial number can be directly matched one by one. This process ensures that the position information of each lamp bead can be accurately associated with its serial number, providing accurate data support for subsequent lighting effect control and layout planning.
[0121] In the specific implementation, since the spatial position of each lamp bead in the real-shot image, that is, its coordinates in the real-shot image, has been clearly defined in advance, and at the same time, the serial number that each lamp bead in the segment should have can be known according to the serial number range obtained when the segment is divided. Next, the spatial position of each lamp bead is matched with the corresponding serial number according to the arrangement order of the lamp beads in the real-shot image. For example, if the number of lamp beads to be identified in a segment is 10, and the number of identified lamp beads identified by image processing technology is also 10, then the spatial position of the first identified lamp bead can be matched with serial number 1 according to the order of the lamp beads from left to right or from top to bottom in the image, and the second can be matched with serial number 2, and so on, until all lamp beads are matched.
[0122] This one-to-one matching method is simple and direct because it is based on the premise that all lamp beads have been accurately identified and there are no missing or redundant identification results. This can complete the matching task quickly and accurately under ideal conditions and is an important part of the lamp bead position detection process. However, in actual applications, various interference factors may be encountered, resulting in inconsistencies between the number of identified and the number to be identified. Therefore, in addition to this ideal matching method, corresponding strategies are also needed to deal with the situation of missing or misidentified lamp beads to ensure the robustness and accuracy of the entire lamp bead position detection process.
[0123] Step S5340: When the comparison result shows that the difference between the number of identified lamps and the number to be identified does not exceed the preset threshold, the spatial position of the missing lamp beads of the segment is inferred based on the average spacing of all adjacent lamp beads that have achieved corresponding matching, and the spatial position of each lamp bead belonging to the segment in the real-shot image is matched one by one with each serial number within the serial number range of the segment;
[0124] When the number of identified lamp beads in a segment of the real-shot image is less than the number of lamp beads to be identified in the segment, and the difference does not exceed the preset threshold, it indicates that some lamp beads may not be successfully identified in the real-shot image. This situation may be caused by a variety of factors, such as lamp beads being blocked, insufficient light, reflection interference or other imaging problems. In response to this situation, corresponding processing can be performed according to the following embodiments.
[0125] First, we need to calculate the average spacing between the identified lamp beads. This can be achieved by measuring the center-to-center distance between adjacent identified lamp beads in the real-shot image. For example, if the coordinates of the identified lamp beads in the image are (x1, y1) and (x2, y2), the distance d between them can be calculated using the Euclidean distance formula:
[0126]
[0127] After calculating the distances between all adjacent identified pairs of lamp beads, take their average value as the average spacing.
[0128] Next, use this average spacing to infer the spatial position of the missing bead. Assume that the positions of two adjacent identified beads A and B are known, and based on the average spacing, it is inferred that there should be a missing bead C between the two beads. If the spatial position of bead A is (xA, yA) and the spatial position of bead B is (xB, yB), the position of the missing bead C can be estimated by linear interpolation. For example, if beads A and B are on a straight line, and the missing bead C should be located between A and B, the position of C can be estimated as:
[0129]
[0130] In addition, the arrangement pattern of the lamp beads can be considered to further improve the accuracy of the inference. For example, if the lamp beads are arranged in a certain geometric pattern (such as a circle, spiral, etc.), the characteristics of this pattern can be used to adjust the position estimate of the missing lamp bead. For the lamp beads arranged in a circle, the center and radius of the identified lamp beads can be calculated, and then the spatial position of the missing lamp bead can be determined based on the expected angular position of the missing lamp bead.
[0131] After determining the spatial position of the missing lamp beads, the number of segments to be identified is consistent with the number of identified lamp beads, and the corresponding matching between the spatial position of each lamp bead within the serial number range of the segment can be achieved in the manner disclosed in step S5330. For example, if the number of segments to be identified is 10 and the number of identified lamp beads is 8, after the positions of the two missing lamp beads are inferred by the above method, the corresponding matching of the 10 lamp beads can be achieved according to the arrangement order of the lamp beads in the real shot image.
[0132] It should be pointed out that when the step comparison results show that the difference between the number of identified and the number to be identified has exceeded the preset threshold, the problem can be gradually subdivided by continuing to segment and infer the missing lamp beads in the lower-level segments.
[0133] The advantage of this method is that it can infer the position of missing lamp beads through known information when some lamp beads cannot be directly identified, thereby achieving a complete match between the lamp bead position and the serial number. This not only improves the robustness of lamp bead position detection, but also ensures that accurate lamp bead layout information can be obtained even under imperfect imaging conditions.
[0134] Step S5350: When the comparison result shows that the number of identified lamps exceeds the number to be identified, the redundant lamp beads of the segment in the real-shot image are excluded based on the common features of the same segment, and the spatial positions of the various lamp beads belonging to the segment in the real-shot image are matched one-to-one with the various serial numbers within the serial number range of the segment.
[0135] When the number of recognized lamp beads in a segment of the real-shot image exceeds the number of lamp beads to be recognized in the segment, it indicates that there may be lamp beads that do not belong to the current segment in the real-shot image, or the same lamp bead is recognized repeatedly. This situation may be caused by a variety of factors, such as mirror reflection, image processing errors or other interference factors. In response to this situation, corresponding processing can be performed according to the following embodiments.
[0136] First, it is necessary to analyze the common features of the same segment to identify and exclude redundant lamp beads. The common features of the same segment refer to the common characteristics that all lamp beads in the current segment should have. These characteristics can include color consistency, distribution similarity, shape similarity, etc. For example, if all lamp beads in a segment should display the same color, then any lamp beads that display different colors can be considered redundant. Similarly, if the lamp beads should be distributed in a certain pattern within the segment, such as uniform distribution or a specific geometric arrangement, then any lamp beads that do not conform to this pattern can also be identified as redundant.
[0137] In specific implementation, the following embodiments can be used to eliminate redundant lamp beads:
[0138] The first embodiment can use color consistency to check: by analyzing the apparent color of each lamp bead in the real shot image and comparing it with the preset apparent color of the segment. If the color of a lamp bead is significantly different from the preset color, it can be identified as a redundant lamp bead and excluded. For example, if all the lamp beads in a segment should be displayed red, and a blue lamp bead appears in the real shot image, then this blue lamp bead can be excluded.
[0139] The second embodiment can use distribution similarity for analysis: calculate the average spacing between identified lamp beads and check whether each lamp bead conforms to this distribution pattern. If the position of a lamp bead deviates significantly from the expected distribution pattern, it can be identified as a redundant lamp bead and excluded. For example, if the lamp beads of a segment should be evenly distributed and the average spacing has been calculated to be 50 pixels, and the distance between a lamp bead and its neighbor is significantly less than or greater than 50 pixels, then this lamp bead can be excluded.
[0140] The third embodiment can use shape similarity for verification: by analyzing the shape of each lamp bead in the real shot image and comparing it with the standard shape of the lamp bead. If the shape of a lamp bead is significantly different from the standard shape, it can be identified as a redundant lamp bead and excluded. For example, if the standard shape of a lamp bead is round, and an elliptical "lamp bead" appears in the real shot image, then this elliptical "lamp bead" can be excluded.
[0141] After excluding redundant lamp beads, when the number of identified lamp beads is equal to the number to be identified, the spatial position of each lamp bead belonging to the segment in the real-shot image and each serial number within the serial number range of the segment can be matched one by one. Specifically, referring to the method disclosed in step S5330, the spatial position of each lamp bead is matched with the corresponding serial number according to the arrangement order of the lamp beads in the real-shot image.
[0142] The advantage of this method is that it can identify and exclude incorrect lamp beads by analyzing the common features of the same segment in the case of misidentification or redundant identification, thereby ensuring the accuracy and completeness of the matching results of the lamp bead position and serial number. This not only improves the robustness of lamp bead position detection, but also ensures that accurate lamp bead layout information can be obtained even under complex imaging conditions.
[0143] After executing the above embodiments, the comprehensive technical advantages achieved by the present application are mainly reflected in the following aspects. First, by comparing the number of identified lamp beads in the real-shot image with the number to be identified, the identification status of the lamp beads in the current segment can be quickly and accurately determined, providing clear guidance for subsequent matching strategies. This comparison method is not only simple and efficient, but also can promptly detect abnormal situations in the identification process, such as missing or misidentified lamp beads, thereby ensuring the accuracy and reliability of the entire identification process. Secondly, when the number of identified lamp beads is the same as the number to be identified, the spatial position of the lamp beads is directly matched with the serial number. This method is simple and direct, can quickly complete the matching task, and improves the processing efficiency of the entire system. In addition, when the number of identified lamp beads is less than the number to be identified, the spatial position of the missing lamp beads is inferred by calculating the average spacing between the identified lamp beads. This inference method based on known information can not only effectively solve the problem that some lamp beads cannot be directly identified, but also obtain accurate lamp bead layout information under imperfect imaging conditions, thereby enhancing the robustness of the system. Finally, when the number of identified lamps exceeds the number to be identified, redundant lamp beads are excluded by analyzing the common features of the same segment. This method can effectively identify and exclude misidentified or duplicated lamp beads, ensuring the accuracy and completeness of the matching results. It can be seen that the comprehensive technical advantages achieved by the above embodiments of the present application not only improve the efficiency and accuracy of lamp bead position and serial number matching, but also enhance the robustness and adaptability of the system, providing strong technical support for the development and application of smart light chain products.
[0144] Based on any embodiment of the method of the present application, the spatial position of the missing lamp bead of the segment is inferred based on the average spacing of all adjacent lamp beads that have achieved corresponding matching, including:
[0145] Step S5341, calculating the average spacing between adjacent lamp beads according to the straight-line distance between the spatial positions of adjacent lamp beads with consecutive serial numbers that have achieved corresponding matching in the real-shot image;
[0146] In order to infer the spatial position of the missing lamp beads in a certain segment of the real-shot image, it is first necessary to calculate the average spacing between adjacent lamp beads with continuous serial numbers that have achieved corresponding matching. This can be done by measuring the straight-line distance between the lamp beads with known spatial positions in the real-shot image. Specifically, adjacent lamp beads with continuous serial numbers refer to adjacent lamp beads in the light chain that have determined spatial positions and serial numbers. For example, if the serial numbers of the lamp beads are 1, 2, 3..., then the lamp beads with serial numbers 1 and 2, the lamp beads with serial numbers 2 and 3, etc. constitute continuous adjacent pairs of lamp beads.
[0147] For these adjacent lamp beads, by measuring the straight-line distance between their spatial positions in the real-shot image, a series of straight-line distance data can be obtained. These straight-line distance data reflect the actual interval between adjacent lamp beads. Next, these distance data are statistically analyzed to calculate the average value between these straight-line distances, that is, the average spacing. The purpose of calculating the average spacing is to obtain a reference value, which represents the average distance that should be maintained between adjacent lamp beads under normal circumstances.
[0148] Step S5342, performing linear fitting on the lamp beads whose spatial positions have been determined in the corresponding segment to determine the linear distribution relationship of the lamp beads;
[0149] In order to determine the spatial position of the missing lamp beads in a segment of the real-shot image, linear fitting can be performed on the lamp beads with determined spatial positions in the segment to determine the linear distribution relationship of the lamp beads. This step is based on the assumption that in most cases, the distribution of lamp beads on the light chain is approximately linear, and even when the light chain is bent or arranged in a specific shape, the distribution of lamp beads in the local area can still be considered linear or approximately linear.
[0150] In the specific implementation, firstly, the coordinate data of all the lamp beads at the known spatial positions of the segment are collected. Next, the coordinate data are linearly fitted using mathematical methods. The purpose of linear fitting is to find a straight line that minimizes the sum of the distances from the coordinate points of all the lamp beads at the known spatial positions to the straight line. This can be achieved through mathematical optimization techniques such as the least squares method.
[0151] The result of linear fitting is a straight line equation that describes the linear distribution trend of the lamp beads in the real-shot image. This straight line can be regarded as the "skeleton" of the lamp bead distribution, which provides a reference frame for inferring the position of the missing lamp beads. Through this straight line, the spatial position of the lamp bead at any given serial number position can be predicted. For example, if the coordinates of two adjacent lamp beads are known to be ( x 1, y 1) and ( x 2, y 2), linear fitting can give a straight line equation y = mx + b, where m is the slope and b is the intercept. Using this equation, we can calculate x When the coordinates are arbitrary values, the corresponding y Coordinates to determine the position of the lamp beads.
[0152] In addition, linear fitting can also help identify and correct abnormal data caused by imaging errors or lamp bead damage. If the position of a lamp bead deviates significantly from the straight line obtained by linear fitting, the data of this lamp bead may be inaccurate and requires further verification or correction.
[0153] Step S5343: determine the spatial position of the missing lamp beads in the segment in the real-shot image based on the linear distribution relationship and the average spacing.
[0154] Based on the equation that reflects the linear distribution relationship, combined with the average spacing calculated previously, the position of the missing lamp bead can be further accurately determined. If it is known that there should be a lamp bead at a certain position, but it is not detected in the actual image, it can be judged by checking whether the distance between the lamp beads before and after the position is close to twice the average spacing. If so, then there is a high probability that a lamp bead is missing at this position. For example, if the average spacing is 10 pixels and the distance between two known lamp beads is 28 pixels, then there is a high probability that a lamp bead is missing between the two lamp beads, and the spatial position of the missing lamp bead can be determined at the midpoint of the two known lamp beads.
[0155] In addition, if the linear distribution relationship shows that the lamp beads should be evenly distributed, but the spacing between lamp beads in a certain area is significantly greater than the average spacing, it can also be inferred that there are missing lamp beads in that area. By calculating how many lamp beads there should be in the area, the specific location of each missing lamp bead can be further determined. For example, if the length of an area is 100 pixels and the average spacing is 10 pixels, then there should be 10 lamp beads in this area. If only 6 are actually detected, then it can be inferred that 4 lamp beads are missing, and their spatial positions can be determined based on the same principle of finding missing lamp beads as above, based on the linear distribution relationship and the average spacing.
[0156] After executing the above embodiments, the comprehensive technical advantages achieved by the present application are mainly reflected in the following aspects. First, by calculating the average spacing between adjacent lamp beads with continuous serial numbers that have achieved corresponding matching, the distribution characteristics of the lamp beads on the light chain can be accurately described based on the lamp beads with known spatial positions in the real-shot image. Secondly, by using linear fitting to determine the linear distribution relationship of the lamp beads, the approximate linear distribution of the lamp beads on the light chain can be effectively processed, and the position of the lamp beads can be accurately predicted even when the light chain is bent or arranged in a specific shape. Finally, the spatial position of the missing lamp beads is determined by combining the linear distribution relationship and the average spacing, and the complete distribution of the lamp beads can be accurately reconstructed. Not only is the accuracy and completeness of the lamp bead position detection improved, but also the robustness to incomplete or damaged data is enhanced. In this way, the present application can effectively use the existing lamp bead position information and statistical analysis results to infer the position of the missing lamp beads, thereby achieving complete reconstruction of the lamp bead position, providing a solid technical guarantee for the precise control and layout planning of smart light chain products.
[0157] Based on any embodiment of the method of the present application, excluding redundant lamp beads of the segment in the real shot image according to the common features of the segment includes:
[0158] Step S5351, calculating the average spacing and standard deviation of the straight-line distances between consecutive pairs of lamp beads with corresponding matching serial numbers;
[0159] In order to exclude redundant lamp beads in a certain segment of the real-shot image, it is first necessary to calculate the straight-line distance between the consecutive pairs of lamp beads with corresponding serial numbers that have achieved corresponding matching, and calculate the average spacing and standard deviation based on this, so as to determine a reasonable deviation threshold by analyzing the distance distribution between known matching lamp beads, and then identify and exclude those lamp beads that do not conform to this distribution.
[0160] Specifically, the lamp bead pairs with continuous serial numbers refer to the adjacent lamp beads in the light chain with determined spatial positions and serial numbers. For example, if the serial numbers of the lamp beads are 1, 2, 3..., then the lamp beads with serial numbers 1 and 2, the lamp beads with serial numbers 2 and 3, etc. constitute continuous lamp bead pairs. For these point pairs, a series of straight-line distance data can be obtained by measuring the distance between their spatial positions in the real-shot image.
[0161] Next, these straight-line distance data are statistically analyzed to calculate their average value (average spacing) and standard deviation. The average spacing reflects the average level of distance between pairs of lamp beads, while the standard deviation indicates the degree of dispersion of these distance data, which is determined by the difference between each straight-line distance and the average spacing. The smaller the standard deviation, the more concentrated the straight-line distance data is and the more evenly the distribution of the lamp beads is; conversely, the larger the standard deviation, the more dispersed the straight-line distance data is and the more unevenly the distribution of the lamp beads is.
[0162] Step S5352: take the average spacing plus at least one standard deviation as the deviation threshold as the common feature of the same segment, and traverse to detect whether the straight-line distance between any pair of lamp beads in the segment exceeds the deviation threshold. If it does not exceed the deviation threshold, mark the corresponding pair of lamp beads as a credible pair;
[0163] In order to exclude redundant lamp beads in a certain segment of the real-shot image, it is necessary to set a deviation threshold using the calculated average spacing and standard deviation. This deviation threshold can be used as a common feature of the same segment to identify and exclude lamp beads that do not conform to the normal distribution.
[0164] In specific implementation, the average spacing is added to at least one standard deviation, for example, two standard deviations can be added to the average spacing, and the resulting value is used as the deviation threshold. The setting of this threshold is based on statistical principles, and is intended to include most of the distance data that conforms to the normal distribution, while filtering out those data that obviously deviate from the normal range. For example, if the calculated average spacing is 50 pixels and the standard deviation is 5 pixels, then the deviation threshold can be set to 50 + 5 * 2 = 60 pixels. This threshold means that if the straight-line distance between any two lamp beads exceeds 55 pixels, the distance between the pair of lamp beads is considered abnormal and may contain redundant lamp beads.
[0165] Next, the straight-line distance between any pair of lamp beads in the segment is traversed and detected. For each pair of lamp beads, the straight-line distance between them is calculated and compared with the deviation threshold. If the straight-line distance between a pair of lamp beads does not exceed the deviation threshold, then the pair of lamp beads is considered to be credible and marked as a credible point pair. Then the lamp beads that are never included in the credible point pair will naturally be identified as suspicious point pairs. This process ensures that only those lamp bead pairs that conform to the normal distribution are retained, providing a reliable data basis for further analysis and matching.
[0166] Step S5353: After the traversal is completed, all the redundant lamp beads that are not included in the credible point pairs in the segment of the real-shot image are deleted, and the lamp beads that belong to the credible point pairs are retained.
[0167] After completing the comparison of the straight-line distance between the lamp bead point pairs in the real-shot image and the deviation threshold, the lamp bead data in the real-shot image can be cleaned up to ensure that only those lamp beads that meet the preset statistical characteristics are retained, thereby removing inaccurate data caused by various reasons (such as reflection, ghosting or misrecognition).
[0168] In the specific operation, first review the previously marked reliable point pairs. These point pairs are considered reliable based on the fact that the straight-line distance between them does not exceed the preset deviation threshold. After confirming the reliable point pairs, review the lamp beads in the entire segment of the real-shot image. Any lamp beads not included in the reliable point pairs are considered redundant or misidentified lamp beads. These lamp beads may not be correctly identified due to poor imaging conditions, lamp bead damage, occlusion or other interference factors. In order to ensure the purity of the data, these redundant lamp beads will be deleted from the dataset.
[0169] After the deletion operation is completed, the remaining lamp beads are verified lamp beads that meet the preset statistical characteristics. These lamp beads are not only accurate in spatial position, but their distribution also conforms to the expected pattern. This step ensures the data quality of subsequent processing and analysis, and provides a solid foundation for the precise location and serial number matching of lamp beads.
[0170] After executing the above embodiments, the comprehensive technical advantages achieved by the present application are mainly reflected in the following aspects. First, by accurately calculating the average spacing and standard deviation of the straight-line distance between the matched lamp bead point pairs, a reliable statistical model can be established based on actual data, thereby accurately describing the distribution characteristics of the lamp beads in the real-shot image. Secondly, by using the deviation threshold set by the average spacing and standard deviation as the common feature of the same segment, it is possible to effectively distinguish between normally distributed lamp beads and abnormal lamp beads. By comparing the straight-line distance between each pair of lamp beads with the deviation threshold, those lamp bead point pairs that do not conform to the normal distribution can be quickly identified and then marked as credible point pairs. Finally, by deleting the redundant lamp beads that are not included in the credible point pairs, the data in the real-shot image can be cleaned up to ensure that only those lamp beads that meet the preset statistical characteristics are retained. Not only does it improve the purity of the data, but it also provides high-quality data support for subsequent lamp bead position and serial number matching. In this way, the present application can effectively improve the accuracy and reliability of lamp bead recognition, reduce matching errors caused by misidentification or interference factors, and thus provide a solid technical guarantee for the precise control and layout planning of smart light chain products.
[0171] Based on any embodiment of the method of the present application, excluding redundant lamp beads of the segment in the real shot image according to the common features of the segment includes:
[0172] Step S5354, determining the average color value of the regional image of each lamp bead with a determined spatial position in the segment in the real-shot image;
[0173] In order to exclude extra lamp beads in a certain segment of the real-shot image, it is first necessary to determine the average color value of the regional image of each lamp bead with a determined spatial position in the segment in the real-shot image. In this way, the color characteristics of each lamp bead are obtained so that abnormal lamp beads can be identified and excluded later through color consistency.
[0174] Specifically, each lamp bead occupies a certain area in the real-shot image, and the pixel set in this area constitutes the regional image of the lamp bead. The regional image can be determined by the selection box output by the image analysis technology disclosed in the previous article, such as the OpenCV library function or the image target recognition model. By averaging the color values of all pixels in this regional image, the average color value of the lamp bead can be obtained. Color values can usually be represented by the RGB (red, green, blue) color model, so the average color value of each lamp bead is also an RGB value. For example, if the average red component of all pixels in the regional image of a lamp bead is 120, the average green component is 150, and the average blue component is 200, then the average color value of the lamp bead is (120, 150, 200).
[0175] Step S5355, averaging the average color values of each lamp bead to obtain a re-average value, and determining the absolute error between each average color value and the re-average value as a common feature of the same segment;
[0176] Next, the average color value of each lamp bead is averaged to obtain the re-average value. This re-average value represents the average color characteristics of all lamp beads in the segment. Then, the absolute error between the average color value of each lamp bead and the re-average value is calculated. The absolute error reflects the degree of deviation of the color of each lamp bead from the overall average color. For example, if the re-average value is (130, 160, 210) and the average color value of a lamp bead is (120, 150, 200), then the absolute error of the lamp bead is |120-130| + |150-160| + |200-210| = 30.
[0177] Step S5356: According to the number of lamp beads defined by the serial number range of the segment, select and retain the lamp beads with the smallest absolute error as valid lamp beads, and delete the remaining lamp beads in the actual image.
[0178] After determining the absolute error between the average color value of each lamp bead and the re-average value, the next step is to screen and retain valid lamp beads based on these error values, while deleting the remaining lamp beads in the real-shot image. This process is based on the assumption that, given that the same segment uses the same apparent color to control the light emission of the lamp beads, under normal circumstances, the colors of the lamp beads in the same segment should be consistent, so their average color value should be close to the re-average value. Those lamp beads that deviate greatly from the re-average value may be abnormal lamp beads caused by imaging errors, lamp bead damage, or other interference factors.
[0179] In the specific operation, first determine the number of valid lamp beads that need to be retained based on the number of lamp beads defined by the serial number range of the segment. For example, if the serial number range of a segment is 1 to 10, then this segment should theoretically contain 10 lamp beads. Next, sort the absolute errors of all lamp beads in the determined spatial positions of the segment. Select the top 10 lamp beads with the smallest absolute error as valid lamp beads, because the colors of these lamp beads are closest to the overall average color, and thus are most likely to be correct lamp beads. The remaining lamp beads are considered redundant or misidentified lamp beads and are deleted from the data set.
[0180] After executing the above embodiments, the comprehensive technical advantages achieved by the present application are mainly reflected in the following aspects. First, by accurately calculating the average color value of the regional image of each lamp bead in the real-shot image, the color characteristics of each lamp bead can be obtained based on the actual image data. Secondly, by using the average color value of each lamp bead to calculate the average value, and determining the absolute error between each average color value and the average value, the lamp beads with abnormal colors can be effectively identified. In this way, color deviations caused by imaging errors, lamp bead damage or other interference factors can be quickly identified, thereby ensuring that the retained lamp bead data has a high degree of consistency and reliability. Finally, by screening and retaining the lamp beads with the smallest absolute error as valid lamp beads, and deleting the remaining lamp beads, the data in the real-shot image can be cleaned up to ensure that only those lamp beads that meet the preset color characteristics are retained. In this way, the present application can effectively improve the accuracy and reliability of lamp bead identification, reduce matching errors caused by misidentification or interference factors, and thus provide a solid technical guarantee for the precise control and layout planning of smart light chain products.
[0181] See also Figure 3Another embodiment of the present application further provides a lamp bead position detection device, which includes a sequence number setting module 5100, a recursive segmentation module 5200, an image analysis module 5300, and a matching execution module 5400, wherein the sequence number setting module 5100 is configured to sort the lamp beads according to the total number of lamp beads in the lamp chain and determine the serial number of each lamp bead; the recursive segmentation module 5200 is configured to recursively segment the lamp chain according to the serial number to obtain the serial number range of the lamp beads covered by multiple segments, and after each segmentation, control the relationship between each segment obtained in the current segmentation and other segments. Different apparent colors are presented by lamp beads; the image analysis module 5300 is configured to identify the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determine the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs; the matching execution module 5400 is configured to determine the mapping relationship between the spatial position and the serial number of each lamp bead according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, so as to achieve corresponding matching between the spatial position and the serial number of the lamp bead.
[0182] Based on any embodiment of the device of the present application, the recursive segmentation module 5200 includes: a target segmentation module, which is configured to divide the lamp beads of the target segment in the light chain into multiple segments according to the serial number, and each segment is associated with a different apparent color; a lighting control module, which is configured to control the lamp beads of the corresponding segment in the light chain to emit the corresponding apparent color of the segment according to the apparent color of each segment obtained by the current division, so as to collect the real-shot image; a recursive decision module, which is configured to detect whether each segment obtained by the current segmentation meets the preset termination condition. If not, the current segment being detected is used as the next target segment to iterate the above process to continue to implement recursive segmentation. The termination condition is that all the lamp beads in the current segment are suitable for determining their spatial position and serial number to achieve corresponding matching, or the number of lamp beads in the current segment is less than or equal to two.
[0183] On the basis of any embodiment of the device of the present application, before dividing the lamp beads of the target segment in the light chain into multiple segments according to the serial numbers, it includes: a grouping processing module, which is configured to group the serial numbers of the lamp beads in the light chain according to a preset interval rule to obtain a set of serial numbers corresponding to each group; a parallel processing module, which is configured to start a corresponding thread for each group, input the set of lamp bead serial numbers and the interval rule in each group into the thread, and the thread takes the corresponding group as the target segment and performs recursive segmentation on the target segment.
[0184] Based on any embodiment of the device of the present application, the image analysis module 5300 includes: an image extraction module, which is configured to use a camera unit to collect real-shot images of the light chain at different segmentation stages, and the lamp beads in each segment in the real-shot images display the corresponding apparent color of the segment; an identification execution module, which is configured to identify the spatial position of each light-emitting lamp bead in the real-shot image and the apparent color displayed by it from the real-shot image; an association processing module, which is configured to classify each light-emitting lamp bead into a corresponding segment according to the apparent color of the light-emitting lamp bead in the real-shot image, and determine that the serial number of the light-emitting lamp bead belongs to the serial number range of the segment.
[0185] Based on any embodiment of the device of the present application, the matching execution module 5400 includes: a bottom segment processing module, which is configured to, for each segment, when the number of lamp beads in the segment is less than or equal to two, infer and determine the serial numbers of the two lamp beads and their spatial positions in the actual image based on the serial number relationship and spatial position relationship between the lamp beads and the adjacent segments of the segment to achieve corresponding matching.
[0186] Based on any embodiment of the device of the present application, the matching execution module 5400 includes: a quantity comparison module, which is configured to compare, for each segment, the identified number of lamp beads whose spatial positions are determined in the real-shot image of the segment with the number of lamp beads to be identified obtained by dividing the segment to obtain a comparison result; an identical matching module, which is configured to match the spatial positions of each lamp bead belonging to the segment in the real-shot image with each serial number within the serial number range of the segment one by one when the comparison result shows that the identified number is the same as the number to be identified; a missing matching module, which is configured to match the spatial positions of each lamp bead belonging to the segment in the real-shot image with each serial number within the serial number range of the segment when the comparison result shows that the identified number is less than When the difference in the number to be identified does not exceed the preset threshold, the spatial position of the missing lamp beads in the segment is inferred based on the average spacing between all adjacent lamp beads that have achieved corresponding matching, and the spatial position of each lamp bead belonging to the segment in the actual image is matched one-to-one with each serial number within the serial number range of the segment; the redundant matching module is configured to exclude the redundant lamp beads of the segment in the actual image based on the common features of the same segment when the comparison result shows that the identified number exceeds the number to be identified, and the spatial position of each lamp bead belonging to the segment in the actual image is matched one-to-one with each serial number within the serial number range of the segment.
[0187] Based on any embodiment of the device of the present application, the missing matching module includes: a spacing calculation module, which is configured to calculate the average spacing between adjacent lamp beads based on the straight-line distance between the spatial positions of consecutive adjacent lamp beads with corresponding serial numbers that have achieved corresponding matching in the real-shot image; a linear fitting module, which is configured to perform linear fitting on the lamp beads with determined spatial positions in the corresponding segment to determine the linear distribution relationship of the lamp beads; and a missing calibration module, which is configured to determine the spatial position of the missing lamp beads in the segment in the real-shot image based on the linear distribution relationship combined with the average spacing.
[0188] Based on any embodiment of the device of the present application, the redundant matching module includes: a distance statistics module, which is configured to calculate the average spacing and standard deviation based on the straight-line distance between consecutive pairs of lamp bead points with serial numbers that have achieved corresponding matching; a detection and verification module, which is configured to use the average spacing superimposed on at least one standard deviation as a deviation threshold as a common feature of the same segment, and traverse to detect whether the straight-line distance between any lamp bead point pairs in the segment exceeds the deviation threshold. When it does not exceed, the corresponding lamp bead point pair is marked as a credible point pair; a redundant deletion module, which is configured to delete all redundant lamp beads that are not included in the credible point pairs in the segment in the real-shot image after completing the traversal, and retain the lamp beads belonging to the credible point pairs.
[0189] Based on any embodiment of the device of the present application, the redundant matching module includes: a pixel statistics module, which is configured to determine the average color value of the regional image of each lamp bead with a determined spatial position in the segment in the real-shot image; an error determination module, which is configured to average the average color values of each lamp bead to obtain a re-average value, and determine the absolute error between each average color value and the re-average value as a common feature of the same segment; a screening and deletion module, which is configured to screen and retain the lamp beads with the smallest absolute error as valid lamp beads according to the number of lamp beads defined by the serial number range of the segment, and delete the remaining lamp beads in the real-shot image.
[0190] Based on any embodiment of this application, please refer to Figure 4 Another embodiment of the present application further provides a computer device, which can be used as a controller in an atmosphere light device, such as Figure 4As shown, a schematic diagram of the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. Among them, the computer-readable storage medium of the computer device stores an operating system, a database, and a computer program encapsulating computer-readable instructions. The database may store a control information sequence. When the computer-readable instructions are executed by the processor, the processor may implement a lamp bead position detection method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor may execute the lamp bead position detection method of the present application. The network interface of the computer device is used to connect and communicate with a terminal. Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0191] In this embodiment, the processor is used to execute Figure 3 The memory stores the program code and various data required to execute the above modules or submodules. The network interface is used to transmit data between user terminals or servers. The memory in this embodiment stores the program code and data required to execute all modules / submodules in the lamp bead position detection device of this application, and the server can call the program code and data of the server to execute the functions of all submodules.
[0192] The present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the lamp bead position detection method described in any embodiment of the present application.
[0193] The present application also provides a computer program product, including a computer program / instruction, which, when executed by one or more processors, implements the steps of the lamp bead position detection method described in any embodiment of the present application.
[0194] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments of the present application can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a computer-readable storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0195] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
[0196] In summary, the technical solution of the present application has significant application advantages in smart light chain products. Through the recursive segmentation method, the spatial position and serial number of the lamp beads can be efficiently identified and matched, and the identification task can be completed quickly and accurately even when the distribution of the lamp beads is complex or the number is large. This not only improves the convenience of product operation, but also enhances the flexibility of users in designing and controlling personalized lighting effects. In addition, the high accuracy and low error rate of the solution ensure the consistency and stability of the lighting effects and enhance the user experience. At the same time, good scalability enables the product to easily adapt to lighting needs of different scales and complexities, extending the service life of the product and reducing maintenance costs. Overall, the technical solution of the present application brings higher performance, better user experience and stronger market competitiveness to smart light chain products.
Claims
1. A method for detecting the position of a lamp bead, characterized in that: include: Sort the lamp beads according to the total number of lamp beads in the lamp chain and determine the serial number of each lamp bead; Recursively segmenting the light chain according to the serial number to obtain the serial number range of the lamp beads covered by the multiple segments, and after each segmentation, controlling each segment obtained by the current segmentation to present different apparent colors with other segments through the lamp beads; Identify the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determine the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs; According to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, a mapping relationship between the spatial position of each lamp bead and the serial number is determined to achieve a corresponding match between the spatial position of the lamp bead and the serial number, including: For each segment, the number of identified lamp beads whose spatial positions are determined in the real-shot image of the segment is compared with the number of lamp beads to be identified obtained by dividing the segment to obtain a comparison result; When the comparison result shows that the identified number is the same as the number to be identified, the spatial position of each lamp bead belonging to the segment in the real shot image is matched with each serial number within the serial number range of the segment; When the comparison result shows that the difference between the number of identified lamps and the number to be identified does not exceed the preset threshold, the spatial position of the missing lamp beads in the segment is inferred based on the average spacing of all adjacent lamp beads that have achieved corresponding matching, and the spatial position of each lamp bead belonging to the segment in the real-shot image is matched one by one with each serial number within the serial number range of the segment; When the comparison result shows that the number of identified lamps exceeds the number to be identified, the redundant lamp beads of the segment in the real-shot image are excluded based on the common features of the same segment, and the spatial positions of each lamp bead belonging to the segment in the real-shot image are matched one by one with each serial number within the serial number range of the segment.
2. The lamp bead position detection method according to claim 1, characterized in that: The lamp chain is recursively segmented according to the serial number to obtain the serial number range of the lamp beads covered by the multiple segments, and after each segmentation, each segment obtained by the current segmentation is controlled to present different apparent colors with other segments through the lamp beads, including: Divide the lamp beads of the target segment in the light chain into multiple segments according to the serial number, and associate and match different apparent colors to each segment; According to the apparent color of each segment obtained by the current division, control each lamp bead of the corresponding segment in the light chain to emit the corresponding apparent color of the segment, so as to collect the real shot image; Check whether each segment obtained by the current segmentation meets the preset termination condition. If not, take the current segment being tested as the next target segment to iterate the above process to continue recursive segmentation. The termination condition is that all the lamp beads in the current segment are suitable for determining their spatial position and serial number to achieve corresponding matching, or the number of lamp beads in the current segment is less than or equal to two.
3. The lamp bead position detection method according to claim 2, characterized in that: Before dividing the lamp beads of the target segment in the lamp chain into multiple segments according to the serial number, including: According to the preset interval rule, the serial numbers of the lamp beads in the lamp chain are grouped to obtain a set of serial numbers corresponding to each group; Start a corresponding thread for each group, input the set of lamp bead serial numbers and spacing rules in each group into the thread, and the thread will use the corresponding group as the target segment and perform recursive segmentation on the target segment.
4. The lamp bead position detection method according to claim 1, characterized in that: Identifying the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determining the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs, including: Using a camera unit to collect real-shot images of the light chain at different segmentation stages, the light beads of each segment in the real-shot images display the corresponding apparent color of the segment; Identifying the spatial position of each light-emitting lamp bead in the real-shot image and the apparent color displayed by each light-emitting lamp bead from the real-shot image; According to the apparent color of the light-emitting lamp beads in the real-shot image, each light-emitting lamp bead is classified into a corresponding segment, and it is determined that the serial number of the light-emitting lamp bead belongs to the serial number range of the segment.
5. The lamp bead position detection method according to claim 1, characterized in that: According to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, a mapping relationship between the spatial position and the serial number of each lamp bead is determined to achieve a corresponding match between the spatial position and the serial number of the lamp bead, including: For each segment, when the number of lamp beads in the segment is less than or equal to two, the serial numbers of the two lamp beads and their spatial positions in the actual image are inferred and determined based on the serial number relationship and spatial position relationship between the lamp beads and the adjacent segments of the segment to achieve corresponding matching.
6. The lamp bead position detection method according to any one of claims 1 to 5, characterized in that: The spatial position of the missing lamp bead in the segment is inferred based on the average spacing of all adjacent lamp beads that have achieved corresponding matching, including: Calculate the average spacing between adjacent lamp beads according to the straight-line distance between the spatial positions of adjacent lamp beads with consecutive serial numbers that have achieved corresponding matching in the real-shot image; Perform linear fitting on the lamp beads with determined spatial positions in the corresponding segment to determine the linear distribution relationship of the lamp beads; According to the linear distribution relationship and the average spacing, the spatial position of the missing lamp beads in the segment in the real-shot image is determined.
7. The lamp bead position detection method according to any one of claims 1 to 5, characterized in that: Exclude redundant LEDs in the segment in the real-shot image based on the common features of the segment, including: According to the straight-line distance between the consecutive pairs of lamp beads with corresponding matching serial numbers, the average spacing and standard deviation are calculated; The average spacing plus at least one standard deviation is used as the deviation threshold as the common feature of the same segment, and the straight-line distance between any pair of lamp beads in the segment is traversed to detect whether it exceeds the deviation threshold. If it does not exceed, the corresponding pair of lamp beads is marked as a reliable pair of points; After the traversal is completed, all the redundant lamp beads that are not included in the credible point pairs in the segment of the real-shot image are deleted, and the lamp beads that belong to the credible point pairs are retained.
8. The lamp bead position detection method according to any one of claims 1 to 5, characterized in that: Exclude redundant LEDs in the segment in the real-shot image based on the common features of the segment, including: Determine the average color value of the regional image of each lamp bead with a determined spatial position in the segment in the real shot image; Based on the average color value of each lamp bead, the average value is averaged to obtain the average value, and the absolute error between each average color value and the average value is determined as the common feature of the same segment; According to the number of lamp beads defined by the serial number range of the segment, the lamp beads with the smallest absolute error are screened and retained as valid lamp beads, and the remaining lamp beads in the actual image are deleted.
9. A lamp bead position detection device, characterized in that: include: A serial number setting module is configured to sort the lamp beads according to the total number of lamp beads in the lamp chain and determine the serial number of each lamp bead; A recursive segmentation module, configured to recursively segment the light chain according to the serial number to obtain a serial number range of lamp beads covered by a plurality of segments, and after each segmentation, control each segment obtained by the current segmentation to present different apparent colors with other segments through lamp beads; An image analysis module is configured to identify the spatial position and apparent color of the light-emitting lamp beads in the real-shot image of the light chain collected in each segment, and determine the serial number range to which the light-emitting lamp beads in the image belong according to the segment to which the apparent color belongs; The matching execution module is configured to determine the mapping relationship between the spatial position and the serial number of each lamp bead according to the spatial position relationship between adjacent lamp beads in the real-shot image and the serial number relationship in the serial number range to which they belong, so as to achieve the corresponding matching between the spatial position and the serial number of the lamp bead, including: For each segment, the number of identified lamp beads whose spatial positions are determined in the real-shot image of the segment is compared with the number of lamp beads to be identified obtained by dividing the segment to obtain a comparison result; When the comparison result shows that the identified number is the same as the number to be identified, the spatial position of each lamp bead belonging to the segment in the real shot image is matched with each serial number within the serial number range of the segment; When the comparison result shows that the difference between the number of identified lamps and the number to be identified does not exceed the preset threshold, the spatial position of the missing lamp beads in the segment is inferred based on the average spacing of all adjacent lamp beads that have achieved corresponding matching, and the spatial position of each lamp bead belonging to the segment in the real-shot image is matched one by one with each serial number within the serial number range of the segment; When the comparison result shows that the number of identified lamps exceeds the number to be identified, the redundant lamp beads of the segment in the real-shot image are excluded based on the common features of the same segment, and the spatial positions of each lamp bead belonging to the segment in the real-shot image are matched one by one with each serial number within the serial number range of the segment.
10. A computer device comprising a central processing unit and a memory, characterized in that: The central processing unit is used to call and run the computer program stored in the memory to execute the steps of the method according to any one of claims 1 to 8.
11. A computer program product comprising a computer program or computer instructions, characterized in that When the computer program or computer instruction is called and executed by a central processing unit, the steps of the method according to any one of claims 1 to 8 are executed.
Citation Information
Patent Citations
Signal lamp time domain state detection method, model training method and related device
CN114677657A
Processing track making method, processing system, processor and storage medium
CN116475025A