Generation method of lamp strip modeling graph, electronic equipment and storage medium
By extracting the equivalent outer contour from the target picture, eliminating feature points that do not meet the concave conditions, generating the target contour and rendering the light strip layout information, the problem of unclear outline in the image is solved, and a personalized light strip modeling diagram is provided, which improves the user experience.
Patent Information
- Application Number
- CN202510162179.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2045-02-14
AI Technical Summary
In the prior art, the outline of the target object in the image or picture is not clear enough, making it difficult for users to create an accurate target object shape, unable to meet users' fun activities, and poor user experience.
By obtaining the target picture, the equivalent outer contour corresponding to the target object is determined, the key feature points that do not meet the preset concave conditions are eliminated according to the smoothing parameters entered by the user, the target outline is generated, and the light strip layout information is generated based on the preset interval distance, and the target outline is rendered to obtain the light strip modeling diagram.
It provides clearly visible and personalized light strip shape drawings, allowing users to accurately and beautifully shape the shape, enhance the fun and user experience.
Smart Images

Figure CN119741399A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of image processing technology, and in particular to a method for generating a light strip shape diagram, an electronic device, and a storage medium. Background Art
[0002] With the continuous popularization and development of terminals, users are increasingly dependent on terminals, and a variety of applications can be installed on the terminals, such as video applications, through which users watch pictures or videos for entertainment. In some cases, users are very interested in the shapes of animals or people in video applications and want to shape the shapes of animals or people.
[0003] At present, most users capture images from videos or save pictures, and directly shape them according to the shape of animals or people. However, since the images or pictures contain other interfering objects that are not related to animals or people (for example, various electrical appliances, furniture, etc.), and the influence of light causes the outlines of animals or people to be not clear and obvious, and users cannot distinguish them with the naked eye, which makes it difficult for users to use light strips to shape accurate animal or human shapes, and cannot satisfy users' fun activities, resulting in poor user experience. Summary of the invention
[0004] In view of this, one of the purposes of an embodiment of the present invention is to provide a method for generating a light strip shape diagram, an electronic device and a storage medium, aiming to solve the technical problem in the prior art that the outline of the target object in the image or picture is not clear and obvious enough, making it difficult for the user to shape the accurate target object shape.
[0005] To solve the above technical problems, the embodiments of the present invention provide the following technical solutions: In a first aspect, an embodiment of the present invention provides a method for generating a light strip shape diagram, comprising: Acquire a target image, wherein the target image includes a target image area occupied by a target object; Determine an equivalent outer contour corresponding to the target object based on the target image, wherein the equivalent outer contour includes a plurality of key feature points; In response to a user inputting a smoothing parameter about the equivalent outer contour, key feature points that do not meet a preset concave condition are eliminated from the equivalent outer contour to obtain a plurality of candidate feature points; generating a target contour based on a plurality of the candidate feature points; Generate light strip arrangement information based on a preset interval distance, wherein the light strip arrangement information is used to indicate positions where light strip segments of different colors are arranged on the target outline; The target outline is rendered based on the light strip arrangement information to obtain a light strip shape diagram.
[0006] In some embodiments, determining the equivalent outer contour corresponding to the target object based on the target image includes: Extracting an outer contour of the target object from the target image, wherein the outer contour includes a plurality of contour feature points; In response to a user inputting a precision parameter about the outer contour, screening out a plurality of key feature points from the plurality of contour feature points; The equivalent outer contour is generated based on a plurality of the key feature points.
[0007] In some embodiments, extracting the outer contour of the target object from the target image includes: Segmenting a target image region occupied by the target object from the target image to obtain a binary contour image, wherein a pixel value of the target image region is a first pixel value, and a pixel value of an image region in the target image excluding the target image region is a second pixel value; The outer contour of the target object is extracted from the binary contour image based on a preset edge detection algorithm.
[0008] In some embodiments, segmenting the target image region occupied by the target object from the target image to obtain a binary contour map includes: In response to a user's frame selection operation on the target image area, segmenting the target image area occupied by the target object from the target image to obtain a binary contour map; or In response to the text content about segmenting the target image area input by the user, segmenting the target image area occupied by the target object from the target picture to obtain a binary contour map; or, In response to the default segmentation command, a target image area occupied by the target object is segmented from the target image to obtain a binary contour map, wherein the target object is an object that is focused and photographed in the target image.
[0009] In some embodiments, the smoothing parameter includes a preset angle threshold, and in response to the user inputting the smoothing parameter about the equivalent outer contour, key feature points that do not meet the preset concave condition are removed from the equivalent outer contour to obtain a plurality of candidate feature points, including: Obtaining a preset angle threshold value input by a user regarding the equivalent outer contour; Calculate the angle value corresponding to each of the key feature points; Key feature points whose angle values are smaller than the preset angle threshold are eliminated from the equivalent outer contour to obtain a plurality of candidate feature points.
[0010] In some embodiments, calculating the angle value corresponding to each of the key feature points includes: For any key feature point, determine a previous key feature point and a next key feature point corresponding to the key feature point; Determine that the angle formed by the first line segment and the second line segment is the angle value corresponding to the key feature point, the first line segment is the line segment obtained by connecting the previous key feature point and the key feature point, and the second line segment is the line segment obtained by connecting the key feature point and the next key feature point.
[0011] In some embodiments, generating a target contour based on the plurality of candidate feature points comprises: Generating a plurality of reference feature points based on the plurality of candidate feature points, wherein the distances between any two adjacent reference feature points are the same; Performing a curve fitting operation on all the reference feature points to obtain a reference contour; determining a perimeter of the reference contour; Based on the preset light strip length, the reference contour is scaled so that the perimeter of the scaled reference contour is consistent with the preset light strip length.
[0012] In some embodiments, generating the light strip arrangement information based on the preset spacing distance includes: Based on a preset interval distance, a plurality of reference feature points are equally spaced in the target contour, and a line segment between any two adjacent reference feature points is a sub-contour line segment; Based on the multiple sub-contour line segments, the light strip arrangement information corresponding to the multiple sub-contour line segments is generated, and one sub-contour line segment corresponds to one piece of light strip arrangement information.
[0013] In some embodiments, the light strip arrangement information includes the color of the light strip segment and the position of the light strip segment on the target outline, and rendering the target outline based on the light strip arrangement information to obtain the light strip shape diagram includes: For any light strip segment, according to the position of the light strip segment on the target contour, determining the sub-contour line segment corresponding to the light strip segment as the target sub-contour line segment; The color of the target sub-contour line segment is rendered as the color of the light strip segment to obtain a light strip modeling diagram, wherein the colors of any two adjacent sub-contour line segments are different.
[0014] In a second aspect, an embodiment of the present invention provides an electronic device, including: A processor and a memory communicatively connected to the processor; The memory stores computer program instructions executable by the processor, and when the computer program instructions are called by the processor, the processor executes any one of the methods for generating a light strip shape diagram proposed in the first aspect.
[0015] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium, on which computer program instructions executable by a processor are stored, and when the computer program instructions are called by the processor, the processor executes any one of the methods for generating a light strip shape diagram proposed in the first aspect.
[0016] The embodiments of the present invention have the following beneficial effects: Different from the prior art, the method for generating a light strip shape diagram provided by the embodiments of the present invention includes: obtaining a target image, the target image includes a target image area occupied by a target object, determining an equivalent outer contour corresponding to the target object based on the target image, the equivalent outer contour includes multiple key feature points, in response to a user input of a smoothing parameter for the equivalent outer contour, eliminating key feature points that do not meet a preset concave condition from the equivalent outer contour to obtain multiple candidate feature points, generating a target contour based on the multiple candidate feature points, generating light strip layout information based on a preset interval distance, the light strip layout information is used to indicate the positions of light strip segments of different colors arranged on the target contour, rendering the target contour based on the light strip layout information to obtain a light strip shape diagram.
[0017] The embodiment of the present invention extracts the equivalent outer contour corresponding to the target object from the target image, generates the target contour corresponding to the target object according to the smoothing parameters input by the user, and personalizes the rendering of the target contour based on the light strip arrangement information to obtain the light strip shape diagram. In this way, a clear, visible and personalized light strip shape diagram can be provided to the user, and the user can shape an accurate and beautiful shape according to the light strip shape diagram, thereby enhancing the fun and usage experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following is a brief introduction to the drawings required for the description of the prior art or the embodiments. Obviously, the drawings described below only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection. For those of ordinary skill in the art, other related drawings can also be obtained based on these drawings without creative work.
[0019] Figure 1 is a schematic diagram of an application scenario for generating a light strip shape diagram in some embodiments of the present invention; Figure 2 is a schematic diagram of the structure of an electronic device provided by some embodiments of the present invention; Figure 3 is a schematic flow chart of a method for generating a light strip shape diagram provided by some embodiments of the present invention; Figure 4 is a target image provided by some embodiments of the present invention; Figure 5is a binary contour map of a target object provided by some embodiments of the present invention; Figure 6 yes Figure 5 A schematic diagram of a contour obtained by extracting the outer contour of a target object shown in the embodiment; Figure 7 is a schematic diagram of a contour for screening a plurality of key feature points provided by some embodiments of the present invention; Figure 8 is another schematic diagram of screening multiple key feature points provided by some embodiments of the present invention; Fig. 9 is another schematic diagram of screening multiple key feature points provided by some embodiments of the present invention; Fig.10 This is a diagram of light strip shapes provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose and advantages of the embodiments of the present invention easier to understand, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The detailed description of the embodiments of the present invention in the drawings below does not limit the scope of protection claimed by the present invention, but only represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0021] It should be noted that, if no conflict is constituted, the various technical features involved in the embodiments of the present invention described below can be combined with each other, and are all within the scope of protection of the present invention. In addition, although the functional modules are divided in the device or structural schematic diagram, and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order than the module division in the device, or in a different order than in the flow chart. In addition, the "first", "second", "third" and other similar expressions used herein do not limit the data and execution order, but are only for the purpose of convenience of explanation and to distinguish between the same or similar items with basically the same functions and effects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features.
[0022] Unless otherwise defined, the technical terms and scientific terms used in this specification have the same meanings as those generally understood by those of ordinary skill in the art of the present invention. The terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. It should be understood that the term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0023] With the continuous popularization and development of terminals, users are increasingly dependent on terminals, and a variety of applications can be installed on the terminals, such as video applications, through which users watch pictures or videos for entertainment. In some cases, users are very interested in the shapes of plants, animals or people in video applications and want to shape the shapes of plants, animals or people.
[0024] At present, most users capture images from videos or save pictures, and directly shape them according to the shapes of plants, animals or people. However, the inventors found that because the images or pictures contain other interfering objects that are not related to plants, animals or people (for example, various electrical appliances, furniture, etc.), and the influence of light causes the outlines of plants, animals or people to be unclear and obvious, users cannot distinguish the outlines of plants, animals or people with the naked eye, and it is difficult for users to use light strips to shape accurate and beautiful plants, animals or people. The activities are less interesting and the user experience is poor.
[0025] In view of this, an embodiment of the present invention provides a method for generating a light strip modeling diagram, by extracting the target image area occupied by the target object (such as an animal, plant or person) in the image or picture, obtaining the equivalent outer contour corresponding to the target object, removing the feature points that do not meet the preset concave condition from the equivalent outer contour according to the smoothing parameter input by the user, and generating the target contour corresponding to the target object, and rendering the target contour in a personalized way based on the light strip layout information to obtain the light strip modeling diagram, and the light strip layout information is used to indicate the positions of light strip segments of different colors arranged on the target contour. In this way, a clear, visible and personalized light strip modeling diagram can be provided to the user, so that the user can shape an accurate and beautiful shape according to the light strip modeling diagram, thereby improving the fun and use experience.
[0026] See also Figure 1 , Figure 1 A schematic diagram of an application scenario for generating a light strip shape diagram provided by some embodiments of the present invention is shown.
[0027] Specifically, Figure 1 As shown, the application scenario includes an electronic device 100, which is used to process the acquired target image 101 to obtain a light strip shape image 102, and output the light strip shape image 102. In some embodiments, the electronic device 100 can be any suitable type of terminal device such as a laptop computer, a desktop computer, a tablet computer, and a smart phone. In other embodiments, the electronic device 100 can also be any suitable type of component such as a single-chip microcomputer, a microcontroller, an FPGA chip, etc.
[0028] In some embodiments, the user can input the target image 101 to the electronic device 100 through a smart terminal such as a smart phone or a tablet computer. For example, the user connects the smart phone or tablet computer to the electronic device 100 and sends the target image 101 to the electronic device 100, so that the electronic device 100 obtains the target image 101.
[0029] In some embodiments, the user can also access an APP, a web page, etc. on the electronic device 100 to obtain the target image 101. For example, the user can access the web link of "Visual China" and filter and obtain the required target image 101.
[0030] The target image 101 includes a target object, for example, Figure 1 The trees enclosed by the rectangular frame in the target image 101 shown in the figure occupy the corresponding image area in the target image 101. After acquiring the target image 101, the electronic device 100 processes the target image 101 and extracts the equivalent outer contour corresponding to the target object, which includes a plurality of key feature points.
[0031] The user inputs the smoothing parameters of the equivalent outer contour to the electronic device 100, and the electronic device 100 removes the key feature points that do not meet the preset concave conditions from the equivalent outer contour according to the smoothing parameters, and retains multiple key feature points that meet the concave conditions, thereby obtaining multiple candidate feature points, and generates a target contour corresponding to the target object according to the multiple candidate feature points, and generates light strip layout information according to the preset interval distance, wherein the light strip layout information is used to indicate the positions of light strip segments of different colors arranged on the target contour.
[0032] According to the light strip arrangement information, the electronic device 100 uses image processing technology to render corresponding colors at various positions in the target outline to obtain an accurate, beautiful, and personalized light strip shape diagram 102, and outputs and displays the light strip shape diagram 102, so that users can create accurate and beautiful shapes based on the light strip shape diagram 102, thereby enhancing fun and usage experience.
[0033] It should be understood that Figure 1 It is only a schematic diagram showing a situation in which the electronic device 100 extracts the equivalent outer contour corresponding to the target object in the target image 101 and generates a light strip shape image 102 corresponding to the target object. Figure 1 In the application scenario shown, the electronic device 100 is a laptop computer, but it does not impose any restrictions on the structure, type, quantity, etc. of the electronic devices in other application scenarios or embodiments. For example, in some other application scenarios or embodiments, the electronic device may also be a desktop computer, a tablet computer, or other suitable types of devices. Figure 1 The notebook computers shown may include more or fewer components or may have Figure 1 Laptops shown in different configurations.
[0034] In order to facilitate understanding of the method for generating a light strip shape diagram provided by an embodiment of the present invention, firstly, the electronic device provided by an embodiment of the present invention is introduced in detail.
[0035] See also Figure 2 , Figure 2 A schematic diagram of the structure of an electronic device provided by some embodiments of the present invention is shown.
[0036] like Figure 2 As shown, the electronic device 100 includes at least one processor 110 and a memory 120 that are communicatively connected. Figure 2 In the figure, the bus system 130 is used to connect a processor. The components in the electronic device 100 are coupled together through the bus system 130, and the bus system 130 is used to realize the connection and communication between the components. It is easy to understand that the bus system 130 includes not only a data bus, but also a power bus, a control bus, and a status signal bus. However, for the sake of clarity and brevity, Figure 2 In the figure, various buses are labeled as bus system 130. It can be understood that Figure 2 The structure shown in the embodiment is only for illustration and does not impose any limitation on the structure of the electronic device. Figure 2 The structures shown may have more or fewer components, or may have the same Figure 2 Different configurations of the structure shown.
[0037] Specifically, the processor 110 is used to provide computing and control capabilities to control the electronic device 100 to perform corresponding tasks, such as controlling the above electronic device 100 to perform any method for generating a light strip shape diagram provided in an embodiment of the present invention, or to perform any step in any possible implementation method of any method for generating a light strip shape diagram provided in an embodiment of the present invention. Those skilled in the art can understand that the processor 110 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0038] The memory 120, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, instructions and modules, for example, programs, instructions and modules corresponding to the method for generating the light strip shape diagram in the embodiment of the present invention. In some embodiments, the memory 120 may include a program storage area and a data storage area, the program storage area may store an operating system, an application required for at least one function, and the data storage area may store data created according to the use of the processor 110, etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the non-transitory software programs, instructions and modules stored in the memory 120, so as to implement any method for generating a light strip shape diagram provided in the embodiment of the present invention, or execute any step in any possible implementation method of any method for generating a light strip shape diagram provided in the embodiment of the present invention. In some embodiments, the memory 120 may include a high-speed random access memory, and may also include a non-transitory memory. For example, at least one disk storage device, a flash memory device or other non-transitory solid-state storage device. In some embodiments, the memory 120 may also include a memory remotely arranged relative to the processor 110, and these remotely arranged memories may be connected to the processor 110 through a communication network. It can be understood that examples of the above-mentioned communication network include but are not limited to the Internet, corporate intranet, local area network, mobile communication network and combinations thereof.
[0039] It can be understood from the above that the implementation subject of any method for generating a light strip shape diagram provided in the embodiment of the present invention can be any suitable type of electronic device with certain computing and control capabilities, for example, it can be implemented by the above electronic device 100. In some feasible implementations, the method for generating any light strip shape diagram provided in the embodiment of the present invention can be implemented by a processor calling a computer program instruction stored in a memory.
[0040] The method for generating a light strip shape diagram provided by an embodiment of the present invention will be described in detail below in conjunction with exemplary applications and implementations of the electronic device provided by an embodiment of the present invention.
[0041] See also Figure 3 , Figure 3 The flowchart of the method for generating the light strip shape diagram provided by some embodiments of the present invention is schematically shown.
[0042] Those skilled in the art can understand that the method for generating a light strip shape diagram provided in the embodiment of the present invention can be applied to the above electronic device (eg, electronic device 100). Specifically, the execution subject of the method for generating a light strip shape diagram is one or at least two processors of the electronic device.
[0043] like Figure 3As shown, the method for generating the light strip shape diagram includes but is not limited to the following steps S100-S600: S100: Acquire a target image, where the target image includes a target image area occupied by a target object.
[0044] In this step, the target image includes a target image area occupied by a target object. The target object refers to an object that the user needs to imitate and shape. The target object can be a plant, an animal, or a person, etc. The plant can be a tree, a flower, etc., the animal can be a cat, a dog, a tiger, etc., and the person can be a human target in the image, such as a child, a woman, a middle-aged man, etc. The target object occupies a corresponding image area in the target image. The image areas occupied by different target objects may overlap or not overlap. For example, see Figure 4 , Figure 4 The target objects in the video include a cat and a girl’s torso. The cat is in the girl’s arms, and the image area occupied by the cat overlaps with the image area occupied by the girl’s torso.
[0045] In some embodiments, the user can upload the target image to the electronic device through a smart terminal such as a smart phone or a tablet computer. For example, the user connects the smart phone or tablet computer to the electronic device through communication methods such as Wi-Fi and Bluetooth, uploads the target image to the electronic device, and the electronic device obtains the target image.
[0046] In some embodiments, the user can also operate an electronic device to access an APP, web page, etc. on the electronic device to obtain the target image. For example, the user can access the web link of "Visual China" and filter and obtain the required target image.
[0047] In some embodiments, the user can also input keywords into the electronic device through voice or text. After receiving the keywords, the electronic device extracts the target object information and generates a corresponding target image, so that the electronic device obtains the target image, and the keywords include the target object information.
[0048] Of course, the electronic device may also obtain the target image in other ways, and those skilled in the art may select any appropriate way according to actual needs, and the embodiments of the present invention do not impose any limitation on this.
[0049] S200: Determine an equivalent outer contour corresponding to a target object based on a target image, where the equivalent outer contour includes a plurality of key feature points.
[0050] In this step, the target image is converted into a grayscale image using image processing technology, and the noise in the image is removed using methods such as Gaussian filtering or median filtering. The target object is highlighted by methods such as histogram equalization or adaptive contrast enhancement. The edge of the target object is identified by edge algorithms (such as Canny, Sobel, and Prewitt, etc.) or threshold segmentation algorithms (such as Otsu algorithm) to obtain the outer contour of the target object. The equivalent outer contour is generated by polygonal approximation methods (such as Ramer-Douglas-Peucker algorithm), B-spline curves, Bezier curves, etc., and important feature points on the outer contour of the target object, such as inflection points, concave and convex points, and extreme points, are detected. The key feature points are retained, small and discontinuous boundaries are eliminated, and the main contour line of the target object is smoothed to obtain the equivalent outer contour corresponding to the target object.
[0051] In some embodiments, the target object has obvious color features, and the target object can be converted to a color space such as HSV or Lab to identify the edge of the target object and obtain the outer contour of the target object. In other embodiments, a contour tracking algorithm (such as findContours of the OpenCV library) can be used to obtain the closed boundary of the target object, identify the edge of the target object, and obtain the outer contour of the target object.
[0052] In some embodiments, if there are interruptions in the equivalent outer contour, the breakpoints are connected by an interpolation method (such as linear interpolation or Lagrange interpolation, etc.) to form a complete equivalent outer contour.
[0053] S300: In response to a user inputting a smoothing parameter about an equivalent outer contour, key feature points that do not satisfy a preset concave condition are eliminated from the equivalent outer contour to obtain a plurality of candidate feature points.
[0054] In this step, the smoothing parameter is used to control the smoothness of the equivalent outer contour. The embodiment of the present invention presets multiple smoothing parameters, and the user can select and input any smoothing parameter of any one of the gears according to actual needs. In some embodiments, the smoothing parameter includes any one or more of a curvature threshold, an angle threshold, and a distance threshold.
[0055] The electronic device receives the smoothing parameters input by the user, and eliminates key feature points that do not meet the preset concave conditions (for example, the concave depth or angle does not meet the requirements) according to the smoothing parameters, retains multiple key feature points that meet the preset concave conditions, and obtains multiple candidate feature points (that is, multiple key feature points that meet the preset concave conditions).
[0056] For example, the smoothing parameters include a curvature threshold. The electronic device calculates the curvature corresponding to each key feature point on the contour, compares the curvature of each key feature point with the curvature threshold, and screens out key feature points that do not meet the curvature threshold requirements. For example, key feature points whose curvature is greater than the curvature threshold are screened out, and multiple key feature points that meet the curvature threshold requirements (i.e., the curvature is less than or equal to the curvature threshold) are obtained, that is, multiple candidate feature points.
[0057] It is understandable that there are many methods for calculating the curvature of key feature points, and any suitable method in the prior art can be used for calculation, which will not be described in detail here. For example, in some embodiments, NumPy or other mathematical libraries can be used to calculate the curvature of key feature points.
[0058] S400: Generate a target contour based on a plurality of candidate feature points.
[0059] In this step, multiple candidate feature points are arranged in order on the equivalent outer contour, and a smooth continuous curve is generated between the multiple candidate feature points using a suitable curve fitting or interpolation method to obtain a smooth and continuous target contour corresponding to the target object.
[0060] In some embodiments, a polygon fitting method can be used to connect each candidate feature point to generate a broken line contour to obtain a target contour. The polygon fitting method is suitable for situations with low precision requirements. The target contour obtained is relatively stiff and lacks smoothness. Therefore, a suitable algorithm can be used to smooth the target contour to obtain a smoother target contour.
[0061] In some embodiments, methods such as B-spline curves and Bezier curves can also be used to fit and generate smooth continuous curves to obtain a smooth and continuous target contour. The smoothing parameters can be adjusted efficiently and easily to generate a natural and smooth target contour.
[0062] In some embodiments, Lagrange interpolation or piecewise interpolation method may be used to perform piecewise interpolation on multiple candidate feature points, smoothly transition each point, generate a smooth continuous curve, and obtain a smooth and continuous target contour.
[0063] Of course, any other suitable method may be used to generate the target contour. Those skilled in the art may use any suitable method according to actual needs, and the embodiment of the present invention does not impose any limitation on this.
[0064] S500: generating light strip arrangement information based on a preset spacing distance, where the light strip arrangement information is used to indicate positions where light strip segments of different colors are arranged on a target outline.
[0065] In this step, the preset interval distance refers to the distance between two adjacent lighting points, indicating the length of each light strip segment. The light strip arrangement information is used to indicate the position of the light strip segment on the target contour, wherein the light strip segment includes multiple colors, and the lighting points are arranged on the target contour according to the positions of the light strip segments of different colors on the target contour. Those skilled in the art can set the value of the preset interval distance according to actual needs, and the embodiments of the present invention do not impose any limitation on this.
[0066] Specifically, get the length of the target contour , according to the preset interval , calculate the number of lighting points ,in, It means the value is not greater than The maximum integer of the target contour. The preset interval distance is set every time along the target contour. A lighting point is set, and multiple lighting points are arranged, wherein two adjacent lighting points correspond to a light strip segment. A color is assigned to each light strip segment, and light strip arrangement information corresponding to each light strip segment is generated according to the color of each light strip segment and the position of the light strip segment on the target contour.
[0067] In some embodiments, the target contour is represented in the form of a point sequence or a parameterized curve, where the point sequence is represented as: , ), , ),……,( , ), then the length of the target contour The parameterized curve is expressed as: ,in As a parameter, the length of the target contour is calculated by numerical integration .
[0068] It is understandable that the assigned colors include at least two, and each light strip segment can be assigned a corresponding color according to a preset rule, for example, in the order of color arrangement, in a counterclockwise or clockwise order along the target contour to each light strip segment.
[0069] For example, the assigned colors include three, namely green, red and yellow, and the colors are arranged in order of red, green and yellow. The target outline corresponds to ten light strip segments. Then, the colors assigned to the ten light strip segments along the target outline in a counterclockwise order are: red, green, yellow, red, green, yellow, red, green, yellow, red, red.
[0070] Of course, other methods may also be used to assign a color to each light strip segment, and the embodiment of the present invention does not impose any limitation on this.
[0071] S600: Rendering a target outline based on the light strip arrangement information to obtain a light strip shape diagram.
[0072] In this step, the light strip arrangement information includes the color of the light strip segment and the position of the light strip segment arranged on the target outline.
[0073] Specifically, according to the position of the light strip segment on the target contour, the sub-contour corresponding to each light strip segment is traversed on the target contour, and the color of the sub-contour corresponding to each light strip segment is rendered as the color of each light strip segment to obtain a light strip shape diagram with aesthetic effect and practical value, and the generated light strip shape diagram is exported as a vector image or a pixel image for subsequent use. Among them, the light strip shape diagram includes the color and position information of each light strip segment.
[0074] The embodiment of the present invention extracts the equivalent outer contour corresponding to the target object from the target image, generates the target contour corresponding to the target object according to the smoothing parameters input by the user, and personalizes the rendering of the target contour based on the light strip arrangement information to obtain a light strip shape diagram with aesthetic effect and practical value. In this way, a clear, visible and personalized light strip shape diagram can be provided to the user, so that the user can create an accurate and beautiful shape according to the light strip shape diagram, thereby enhancing the fun and usage experience.
[0075] In some embodiments, determining the equivalent outer contour corresponding to the target object based on the target image specifically includes but is not limited to the following steps S210-S230: S210: extracting an outer contour of a target object from a target image, where the outer contour includes a plurality of contour feature points.
[0076] Specifically, the target image is converted into a grayscale image, a filter (such as Gaussian filtering) is used to remove image noise, an edge detection algorithm (such as Canny, Sobel) is used to extract edges in the image, the edges of the target object are identified, and a contour detection algorithm (such as findContours of the OpenCV library) is used to extract the outer contour of the target object. The outer contour includes multiple contour feature points, and the multiple contour feature points are discrete representations of the edge of the target object.
[0077] In some embodiments, extracting the outer contour of the target object from the target image specifically includes but is not limited to the following steps S2110-S2120: S2110: Segment a target image area occupied by a target object from a target image to obtain a binary contour image, wherein a pixel value of the target image area is a first pixel value, and a pixel value of an image area in the target image excluding the target image area is a second pixel value.
[0078] In this step, the target image is converted into a grayscale image. Grayscaling refers to converting each pixel of the RGB image into a grayscale value (usually a value between 0 and 255). Gaussian filtering or median filtering is used to remove image noise to prevent noise from interfering with edge extraction.
[0079] According to the color or brightness information of the target image area, the target image area and other image areas (i.e., image areas other than the target image area in the target image) occupied by the target object are segmented by setting a threshold. The pixel value of the target image area is the first pixel value, and the pixel value of other image areas (image areas other than the target image area in the target image) is the second pixel value.
[0080] In some embodiments, the target object has an obvious color difference from other objects in the target image, and a fixed threshold may be used to segment the target image area occupied by the target object from the target image.
[0081] In some embodiments, if the brightness value of the target image area is significantly different from that of other image areas, a threshold segmentation technique (such as Otsu's binarization method) can be used to select the optimal segmentation threshold. When the brightness or color difference of the target image is not obvious, an adaptive threshold segmentation method can be used to dynamically calculate the segmentation threshold based on the pixel value of the local area. For example, the cv2.adaptiveThreshold function in OpenCV can be used to implement adaptive threshold segmentation.
[0082] After segmenting the target image area, a binary contour map is generated. In the binary contour map, the pixel value of the target image area is the first pixel value (assigned to 255, white), and the pixel value of other image areas is the second pixel value (assigned to 0, black). The binary contour map clearly shows the location and contour of the target object. For example, see Figure 5 , Figure 5 The figure shows a binary contour map of a target object generated in some embodiments of the present invention.
[0083] In some embodiments, segmenting the target image region occupied by the target object from the target image to obtain a binary contour map specifically includes but is not limited to the following steps S2111: S2111: In response to the user's frame selection operation on the target image area, the target image area occupied by the target object is segmented from the target image to obtain a binary contour map.
[0084] In this step, the interactive selection function provided by the image processing library (such as OpenCV) is used to allow the user to select the target object in the target image by mouse or touch screen. The cv2.selectROI function is used to allow the user to select the target object in the target image, and the target object occupies the corresponding image area (i.e., the target image area) in the target image.
[0085] Specifically, the electronic device monitors through an event listener that the user has performed a frame selection operation on the target image area occupied by the target object in the target image, responds to the performed frame selection operation, and segments the framed target image area in the target image through a threshold segmentation technique (for example, a global threshold method or an adaptive threshold method), thereby segmenting the target image area, and then binarizing the target image area and other image areas in the target image (i.e., image areas other than the target image area in the target image), assigning pixel values of the target image area to first pixel values, and assigning pixel values of other image areas to second pixel values, to obtain a binary contour map.
[0086] In some embodiments, segmenting the target image region occupied by the target object from the target image to obtain a binary contour map specifically includes but is not limited to the following steps S2112: S2112: In response to the text content regarding segmenting the target image area input by the user, segment the target image area occupied by the target object from the target image to obtain a binary contour map.
[0087] In this step, the user can also input text content about segmenting the target image area through text or voice. For example, in some embodiments, after acquiring the target image, the user uses a microphone to input the text content of "intercept the cat in the picture", and after receiving the text content, the electronic device parses the text content, determines that the target object is a cat, and segments the target image area occupied by the target object (i.e., the cat) in the target image through a threshold segmentation technique (e.g., a global threshold method or an adaptive threshold method, etc.), and obtains the target image area through segmentation, and then performs binarization processing on the target image area and other image areas in the target image (i.e., the image areas in the target image other than the target image area), assigns the pixel value of the target image area to the first pixel value, and assigns the pixel value of other image areas to the second pixel value, and obtains a binary contour map.
[0088] In some embodiments, the text content may specifically describe the position and size of the target object (for example, the target object is located in the center of the picture, or the boundary coordinates of the target object, etc.). For example, the text content is "The target image area is the middle part of the picture, with a width of 500px and a height of 400px." The electronic device parses the text content, extracts the position information and size of the target image area, and segments the target image area from the target picture based on the position information and size of the target image area.
[0089] In some embodiments, segmenting the target image region occupied by the target object from the target image to obtain a binary contour map specifically includes but is not limited to the following steps S2113: S2113: In response to the default segmentation command, a target image area occupied by a target object is segmented from the target image to obtain a binary contour map, where the target object is an object that is focused and photographed in the target image.
[0090] In this step, by default, the object in the target image that is focused on is the target object. When the user does not input text content for segmenting the target image area and does not perform a frame selection operation on the target image area, in response to the monitored default segmentation command, the objects included in the target image are traversed one by one, and the object in the target image that is focused on is determined to be the target object, and the target object occupies the corresponding image area (i.e., the target image area) in the target image.
[0091] The target image area occupied by the target object in the target image is segmented by a threshold segmentation technique (for example, a global threshold method or an adaptive threshold method, etc.) to obtain a target image area. Then, the target image area and other image areas in the target image (i.e., image areas other than the target image area in the target image) are binarized, and the pixel values of the target image area are assigned to a first pixel value, and the pixel values of other image areas are assigned to a second pixel value to obtain a binary contour map.
[0092] S2120: Extracting the outer contour of the target object from the binary contour image based on a preset edge detection algorithm.
[0093] In this step, the preset edge detection algorithm can be any suitable edge detection algorithm, for example, it can be a Canny algorithm, a Sobel algorithm, etc. Of course, any other suitable preset edge detection algorithm can also be used. The Canny algorithm is a commonly used edge detection method, which identifies edges by detecting changes in image gradients.
[0094] In some embodiments, the Canny algorithm is used to identify the edge of the target object. The gradient of the image is first calculated (using the Sobel operator or other operators), non-maximum suppression is applied, the edge is refined, and dual threshold detection is used to determine the edge of the target object, thereby identifying the outer contour of the target object.
[0095] After identifying the outer contour of the target object, use OpenCV's findContours function to detect the contour in the image, extract the contour based on the edge detection results in the image, and obtain the outer contour of the target object. The findContours function returns a list of contours, each of which is a collection of points representing the boundary of the contour. Use the cv2.drawContours function to draw the extracted contours onto the original image or a blank image to visualize the outer contour of the target object. For example, see Figure 6 , Figure 6 shows the outer contour of the target object extracted in some embodiments of the present invention, Figure 6 and Figure 5 corresponding to the target object.
[0096] S220: In response to the user inputting the precision parameter about the outer contour, a plurality of key feature points are screened out from the plurality of contour feature points.
[0097] In this step, the precision parameter represents the screening criteria of the contour feature points, and is used to control the degree of simplification of the outer contour. The embodiment of the present invention presets the precision parameters of multiple gears, and the user can choose to input the precision parameter of any gear according to actual needs. In some embodiments, the precision parameter includes any one or more of a curvature threshold, an angle threshold, and a distance threshold.
[0098] The electronic device receives the accuracy parameters input by the user, and selects multiple contour feature points that meet the screening criteria from multiple contour feature points according to the accuracy parameters, and eliminates contour feature points that do not meet the screening criteria (for example, the depth or angle of the depression, or the curvature does not meet the criteria), thereby obtaining multiple key feature points (i.e., multiple key feature points that meet the screening criteria).
[0099] For example, the accuracy parameters include an angle threshold. The electronic device calculates the angle corresponding to each contour feature point on the outer contour, compares the angle of each contour feature point with the angle threshold, and screens out multiple contour feature points that meet the angle threshold requirements. For example, contour feature points whose angles are greater than or equal to the angle threshold are screened out, and multiple contour feature points that meet the angle threshold requirements (i.e., the angles are greater than or equal to the angle threshold) are obtained, that is, multiple key feature points are obtained.
[0100] For example, see Figures 7 to 9 , Figures 7 to 9The schematic diagrams respectively show the multiple key feature points selected after inputting the accuracy parameters of three different gears. Figures 7 to 9 The red contour point 10 shown is the key feature point. Figure 7 The corresponding input precision parameter value is large, the number of key feature points screened out is small, the subsequent equivalent outer contour is highly simplified, and there is a large difference between the equivalent outer contour and the original contour of the target object. Figure 8 The corresponding input precision parameter value is moderate, the number of key feature points screened out is moderate, the degree of simplification of the equivalent outer contour obtained subsequently is average, and the difference between the equivalent outer contour and the original contour of the target object is moderate. Fig. 9 The corresponding input precision parameter value is small, the number of key feature points screened out is large, the degree of simplification of the equivalent outer contour obtained subsequently is low, and the equivalent outer contour is almost consistent with the original contour of the target object.
[0101] It is understandable that there are many methods for calculating the angle of contour feature points, and any suitable method in the prior art can be used for calculation, which will not be described in detail here. For example, in some embodiments, NumPy or other mathematical libraries can be used to calculate the angle of contour feature points.
[0102] S230: Generate an equivalent outer contour based on multiple key feature points.
[0103] In this step, polygonal approximation methods (such as the Ramer-Douglas-Peucker algorithm), Bezier curves, B-spline curves and other fitting methods are used to generate a smooth and continuous equivalent outer contour through multiple key feature points to obtain the equivalent outer contour corresponding to the target object.
[0104] In some embodiments, the fitted equivalent outer contour is segmented, and a smoothing algorithm (such as Gaussian smoothing, B-spline smoothing) can be used to smooth the equivalent outer contour to obtain a smooth, continuous and natural equivalent outer contour.
[0105] In some embodiments, in response to a user inputting a smoothing parameter about an equivalent outer contour, key feature points that do not meet a preset concave condition are removed from the equivalent outer contour to obtain a plurality of candidate feature points, specifically including but not limited to the following steps S310-S330: S310: Obtaining a preset angle threshold value input by a user regarding an equivalent outer contour.
[0106] In this step, the smoothing parameter includes a preset angle threshold. The embodiment of the present invention presets preset angle thresholds for multiple gears. The user can choose to input the preset angle threshold for any gear according to actual needs.
[0107] In some embodiments, the user inputs a preset angle threshold, which represents the minimum value of the angle formed between two adjacent feature points. Key feature points with angle values less than the preset angle threshold do not meet the preset concave condition and need to be eliminated.
[0108] Specifically, the user can select and input a preset angle threshold of any one gear from among preset angle thresholds of multiple gears about the equivalent outer contour through the interactive interface of the electronic device, so that the electronic device obtains the preset angle threshold.
[0109] S320: Calculate the angle value corresponding to each key feature point.
[0110] It can be understood that the calculation of the angle value of the feature point is based on three adjacent feature points on the contour. By calculating the angle between the three adjacent feature points, the angle value corresponding to each key feature point is determined.
[0111] In this step, the vector method is used to calculate the angle value corresponding to each key feature point. For any three consecutive key feature points on the contour , , , calculated by arrive and by arrive The angle value formed, that is, the line segment and line segments The angle value formed.
[0112] For each key feature point, the angle value of the key feature point is calculated using the vector angle formula. The vector angle formula is as follows:
[0113] In the above formula, , , , Then use the arccosine function (arccos) to calculate the angle value of each key feature point .
[0114] In some embodiments, calculating the angle value corresponding to each key feature point includes but is not limited to the following steps S321-S322: S321: For any key feature point, determine a previous key feature point and a next key feature point corresponding to the key feature point.
[0115] S322: Determine the angle formed by the first line segment and the second line segment as the angle value corresponding to the key feature point, the first line segment is the line segment obtained by connecting the previous key feature point and the key feature point, and the second line segment is the line segment obtained by connecting the key feature point and the next key feature point.
[0116] Specifically, for any current key feature point , find the previous key feature point adjacent to it And the next key feature point . Connect the previous key feature point and the current key feature points Get the first line segment, the first line segment vector . Connect the current key feature points And the next key feature point Get the second line segment, the second line segment vector .
[0117] The vector angle (i.e. the angle formed by the first line segment and the second line segment) is calculated using the dot product formula. The dot product formula is as follows:
[0118] In the above formula, , , , the angle value of the current key feature point Through the above method, the angle value corresponding to each key feature point can be calculated.
[0119] S330: Eliminate key feature points whose angle values are less than a preset angle threshold from the equivalent outer contour to obtain multiple candidate feature points.
[0120] Specifically, the angle value corresponding to each key feature point is compared with a preset angle threshold, key feature points with angle values less than the preset angle threshold are removed from the equivalent outer contour, multiple key feature points with angle values greater than or equal to the preset angle threshold are retained, and key feature points with angle values greater than or equal to the preset angle threshold are taken as candidate feature points to obtain multiple candidate feature points.
[0121] In some embodiments, generating a target contour based on multiple candidate feature points specifically includes but is not limited to the following steps S410-S440: S410: Generate multiple reference feature points based on multiple candidate feature points, wherein the distance between any two adjacent reference feature points is the same.
[0122] S420: Perform a curve fitting operation on all reference feature points to obtain a reference contour.
[0123] Exemplarily, the number of reference feature points is set by those skilled in the art according to actual needs, and multiple reference feature points are generated in combination with the distances between the candidate feature points, wherein the distances between any two adjacent reference feature points are the same.
[0124] In some embodiments, the total distance between candidate feature points is calculated, and a target step length for uniformly generating reference feature points is determined, and a plurality of uniformly distributed reference feature points are generated with the target step length, and the distances between adjacent reference feature points are the same.
[0125] A curve fitting algorithm (such as spline interpolation or Bezier curve fitting) is used to perform curve fitting on all reference feature points to generate a smooth and continuous reference contour. It should be understood that any other suitable method (such as polynomial fitting) can also be used to fit and generate the reference contour, and the embodiment of the present invention does not impose any limitation on this.
[0126] S430: Determine the perimeter of the reference contour.
[0127] In this step, the fitted reference contour is sampled to obtain a plurality of sampled contour line segments, the length of each sampled contour line segment is calculated, and the lengths of all the sampled contour line segments are summed to obtain the perimeter of the reference contour.
[0128] S440: Based on the preset light strip length, scaling the reference contour so that the perimeter of the scaled reference contour is consistent with the preset light strip length.
[0129] In this step, the preset light strip length refers to the length of the light strip used by the user to imitate and shape the light strip shape diagram. The user can input the preset light strip length into the electronic device in any appropriate manner.
[0130] Specifically, a scaling factor is calculated based on the preset light strip length and the perimeter of the reference contour, that is, the ratio of the preset light strip length to the perimeter of the reference contour, and then the scaling factor is applied to each reference feature point on the reference contour, and the reference contour is translated and scaled to adjust the perimeter of the reference contour so that the perimeter of the scaled reference contour is consistent with the preset light strip length, thereby obtaining a target contour. The shape of the target contour is the same as that of the reference contour.
[0131] In some embodiments, generating light strip arrangement information based on a preset spacing distance specifically includes but is not limited to the following steps S510-S520: S510: sampling a plurality of reference feature points at equal intervals in the target contour based on a preset interval, and a line segment between any two adjacent reference feature points is a sub-contour line segment.
[0132] In this step, the preset interval distance refers to the distance used to sample multiple reference feature points, and those skilled in the art can set the value of the preset interval distance according to actual needs. Among them, the line segment between any two adjacent reference feature points is a sub-contour line segment, and the length of each sub-contour line segment is the same.
[0133] Exemplarily, an arc-length parameterization method is used to equally sample multiple reference feature points in the target contour according to a preset interval distance to obtain multiple reference feature points that are evenly distributed, and the distance between two adjacent sampling points (reference feature points) is the preset interval distance.
[0134] The line segment between every two adjacent reference feature points is a sub-contour line segment, each group of adjacent reference feature points corresponds to a sub-contour line segment, and each sub-contour line segment includes position information of two adjacent reference feature points.
[0135] S520: Generate light strip arrangement information corresponding to the plurality of sub-contour line segments based on the plurality of sub-contour line segments, wherein one sub-contour line segment corresponds to one light strip arrangement information.
[0136] In this step, for each sub-contour line segment, the light strip layout information is generated according to the coordinates of the starting reference feature point and the ending reference feature point, thereby obtaining multiple light strip layout information corresponding to multiple sub-contour line segments, and one sub-contour line segment corresponds to one light strip layout information. The light strip layout information includes the starting position, the ending position and the attribute information of the light strip segment (such as the length, color, brightness, etc. of the light strip segment).
[0137] In some embodiments, rendering the target outline based on the light strip arrangement information to obtain a light strip shape diagram specifically includes but is not limited to the following steps S610-S620: S610: For any light strip segment, according to the position of the light strip segment on the target contour, determine the sub-contour line segment corresponding to the light strip segment as the target sub-contour line segment.
[0138] S620: Rendering the color of the target sub-contour line segment as the color of the light strip segment to obtain a light strip shape diagram, wherein the colors of any two adjacent sub-contour line segments are different.
[0139] In this step, the light strip arrangement information includes the color of the light strip segment and the position of the light strip segment on the target outline.
[0140] Specifically, for any light strip segment, according to the position (starting point and ending point) of the light strip segment on the target contour, find the sub-contour line segment corresponding to the light strip segment on the target contour, the starting point and ending point of the sub-contour line segment are consistent with the starting point and ending point of the light strip segment, determine the sub-contour line segment corresponding to the light strip segment as the target sub-contour line segment, and render the color of the target sub-contour line segment as the color of the light strip segment, thereby obtaining the light strip shape diagram. That is, for each sub-contour line segment of the target contour, render its color as the color of the light strip segment corresponding to the sub-contour line segment, and any two adjacent sub-contour line segments have different colors.
[0141] In some embodiments, a rendering color can be switched in a loop to ensure that the colors of adjacent sub-contour segments are different. For example, a set of predefined color lists, red and green, are set and rendered to each sub-contour segment in turn to obtain a target contour in which the colors of adjacent sub-contour segments are different. For example, see Fig.10 , Fig.10 The figure shows the shape of the light strip after rendering the color in some embodiments of the present invention. Fig.10 In the light strip shape diagram shown, each sub-contour line segment is rendered alternately in red and green.
[0142] In summary, the method for generating a light strip shape diagram provided in an embodiment of the present invention includes: obtaining a target image, the target image includes a target image area occupied by a target object, determining an equivalent outer contour corresponding to the target object based on the target image, the equivalent outer contour includes multiple key feature points, in response to a user input of a smoothing parameter for the equivalent outer contour, eliminating key feature points that do not meet a preset concave condition from the equivalent outer contour to obtain multiple candidate feature points, generating a target contour based on the multiple candidate feature points, generating light strip layout information based on a preset interval distance, the light strip layout information is used to indicate the positions of light strip segments of different colors arranged on the target contour, rendering the target contour based on the light strip layout information to obtain a light strip shape diagram.
[0143] The embodiment of the present invention extracts the equivalent outer contour corresponding to the target object from the target image, generates the target contour corresponding to the target object according to the smoothing parameters input by the user, and personalizes the rendering of the target contour based on the light strip arrangement information to obtain the light strip shape diagram. In this way, a clear, visible and personalized light strip shape diagram can be provided to the user, and the user can shape an accurate and beautiful shape according to the light strip shape diagram, thereby enhancing the fun and usage experience.
[0144] An embodiment of the present invention provides a computer-readable storage medium, on which computer program instructions executable by a processor are stored. When the computer program instructions are called by the processor, the processor executes any method for generating a light strip shape diagram provided by the embodiment of the present invention, or executes the steps in any implementation method of any method for generating a light strip shape diagram provided by the embodiment of the present invention.
[0145] In some embodiments, the storage medium may be a flash memory, a hard disk, an optical disk, a register, a magnetic surface storage, a removable disk, a CD-ROM, a random access memory (RAM), a read-only memory (ROM), an electrically programmable ROM, and an electrically erasable programmable ROM, or any other form of storage medium known in the technical field, or may be various devices including one or any combination of the above storage media.
[0146] In some embodiments, computer program instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0147] As an example, computer program instructions may, but need not, correspond to a file in a file system, may be stored as part of a file storing other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0148] As an example, the computer program instructions may be deployed to be executed on a computing device (including devices such as smart terminals and servers), or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network. It is easy to understand that all or part of the steps of the method described in the embodiments provided by the present invention above can be directly implemented using electronic hardware or processor executable computer program instructions, or a combination of the two.
[0149] Those skilled in the art will appreciate that the embodiments provided by the present invention are only illustrative, and the order of writing the steps in the method of the embodiment does not mean a strict execution order and does not constitute any limitation on the implementation process. The order can be adjusted, merged and deleted according to actual needs, and the modules or sub-modules, units or sub-units in the device or system of the embodiment can be merged, divided and deleted according to actual needs. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.
[0150] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware. Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0151] It should be noted that the above embodiments are intended to illustrate the technical concept and features of the present invention, and their purpose is to enable people familiar with this technology to understand the content of the present invention and implement it accordingly, and cannot be used to limit the scope of protection of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments can be implemented according to the technical solutions recorded in the embodiments of the present invention, or some of the technical features can be equivalently replaced. It can be understood that these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and should be regarded as equal changes and modifications based on the embodiments of the present invention, and should all fall within the scope of the claims of the present invention.
Claims
1. A method for generating a light strip shape diagram, characterized in that: include: Acquire a target image, wherein the target image includes a target image area occupied by a target object; Determine an equivalent outer contour corresponding to the target object based on the target image, wherein the equivalent outer contour includes a plurality of key feature points; In response to a user inputting a smoothing parameter about the equivalent outer contour, key feature points that do not meet a preset concave condition are eliminated from the equivalent outer contour to obtain a plurality of candidate feature points; generating a target contour based on a plurality of the candidate feature points; Generate light strip arrangement information based on a preset interval distance, wherein the light strip arrangement information is used to indicate positions where light strip segments of different colors are arranged on the target outline; The target outline is rendered based on the light strip arrangement information to obtain a light strip shape diagram.
2. The method according to claim 1, characterized in that The determining, based on the target image, an equivalent outer contour corresponding to the target object comprises: Extracting an outer contour of the target object from the target image, wherein the outer contour includes a plurality of contour feature points; In response to a user inputting a precision parameter about the outer contour, screening out a plurality of key feature points from the plurality of contour feature points; The equivalent outer contour is generated based on a plurality of the key feature points.
3. The method according to claim 2, characterized in that The step of extracting the outer contour of the target object from the target image includes: Segmenting a target image region occupied by the target object from the target image to obtain a binary contour image, wherein a pixel value of the target image region is a first pixel value, and a pixel value of an image region in the target image excluding the target image region is a second pixel value; The outer contour of the target object is extracted from the binary contour image based on a preset edge detection algorithm.
4. The method according to claim 3, characterized in that The step of segmenting the target image region occupied by the target object from the target image to obtain a binary contour map includes: In response to a user's frame selection operation on the target image area, segmenting the target image area occupied by the target object from the target image to obtain a binary contour map; or In response to the text content about segmenting the target image area input by the user, segmenting the target image area occupied by the target object from the target picture to obtain a binary contour map; or, In response to the default segmentation command, a target image area occupied by the target object is segmented from the target image to obtain a binary contour map, wherein the target object is an object that is focused and photographed in the target image.
5. The method according to claim 1, characterized in that The smoothing parameter includes a preset angle threshold, and in response to the user inputting the smoothing parameter about the equivalent outer contour, key feature points that do not meet the preset concave condition are removed from the equivalent outer contour to obtain a plurality of candidate feature points, including: Obtaining a preset angle threshold value input by a user regarding the equivalent outer contour; Calculate the angle value corresponding to each of the key feature points; Key feature points whose angle values are smaller than the preset angle threshold are eliminated from the equivalent outer contour to obtain a plurality of candidate feature points.
6. The method according to claim 5, characterized in that The calculating the angle value corresponding to each of the key feature points includes: For any key feature point, determine a previous key feature point and a next key feature point corresponding to the key feature point; Determine that the angle formed by the first line segment and the second line segment is the angle value corresponding to the key feature point, the first line segment is the line segment obtained by connecting the previous key feature point and the key feature point, and the second line segment is the line segment obtained by connecting the key feature point and the next key feature point.
7. The method according to claim 1, characterized in that The generating of the target contour based on the plurality of candidate feature points comprises: Generating a plurality of reference feature points based on the plurality of candidate feature points, wherein the distances between any two adjacent reference feature points are the same; Performing a curve fitting operation on all the reference feature points to obtain a reference contour; determining a perimeter of the reference contour; Based on the preset light strip length, the reference contour is scaled so that the perimeter of the scaled reference contour is consistent with the preset light strip length.
8. The method according to claim 1, characterized in that The generating the light strip arrangement information based on the preset spacing distance includes: Based on a preset interval distance, a plurality of reference feature points are equally spaced in the target contour, and a line segment between any two adjacent reference feature points is a sub-contour line segment; Based on the multiple sub-contour line segments, the light strip arrangement information corresponding to the multiple sub-contour line segments is generated, and one sub-contour line segment corresponds to one piece of light strip arrangement information.
9. The method according to claim 8, characterized in that The light strip arrangement information includes the color of the light strip segment and the position of the light strip segment on the target outline, and the rendering of the target outline based on the light strip arrangement information to obtain the light strip shape diagram includes: For any light strip segment, according to the position of the light strip segment on the target contour, determining the sub-contour line segment corresponding to the light strip segment as the target sub-contour line segment; The color of the target sub-contour line segment is rendered as the color of the light strip segment to obtain a light strip modeling diagram, wherein the colors of any two adjacent sub-contour line segments are different.
10. An electronic device, characterized in that: include: A processor and a memory communicatively connected to the processor; The memory stores computer program instructions executable by the processor, and when the computer program instructions are called by the processor, the processor executes the method for generating a light strip shape diagram according to any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions executable by a processor, and when the computer program instructions are called by the processor, the processor executes the method for generating a light strip shape diagram according to any one of claims 1 to 9.
Citation Information
Patent Citations
Atmosphere lamp equipment, light-emitting partition layout construction method and device and computer equipment
CN117521179A
Light-emitting equipment, lamp effect light-emitting area editing method and device, medium and product
CN117794029A
Object contour adjustment method and device, equipment, storage medium and program product
CN118314158A
Image processing device, image processing method, image processing system, and image processing program
JP2012194919A
Cited By
Control method, controller and lighting equipment
CN121940931A