Shadow processing method, device and equipment
By using a line scan camera and HSV color space processing, shadows in laptop box inspection are calculated and removed, solving the shadow alignment error problem and improving inspection accuracy and quality.
Patent Information
- Application Number
- CN202510578497.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-09-12
AI Technical Summary
In the inspection of laptop computer packaging boxes, lighting shadows lead to alignment errors between the imaging target object and the template, causing systematic errors in the detection of printed content and size, and reducing the accuracy of the inspection equipment.
The original image is acquired by a line scan camera and converted to the HSV color space. The boundary of the target area is scanned using the line scan algorithm. The shadow width is calculated based on the target object and camera parameters, and the shadow is removed to determine the true boundary of the target object.
It solves the problem of shadow alignment deviation, improves the accuracy of packaging box detection, avoids errors in printing content and size detection, and improves the quality of detection equipment.
Smart Images

Figure CN120634907A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a shadow processing method, device and equipment. Background Art
[0002] When inspecting laptop computer packaging, it is necessary to check the various contents of the printed area and the dimensions of the box slots based on the template to eliminate defective products and prevent them from entering the factory, affecting production efficiency and even causing customer complaints. When inspecting laptop computer packaging, the target object area in the image must first be acquired, and then aligned with the template in the length direction. The accuracy of the alignment guarantees the accuracy of subsequent printed content and size inspections. However, because the light source used for imaging cannot be completely aligned with the camera to avoid part interference, and the target objects of the laptops all have a certain thickness, a shadow is generated on one side of the packaging box. This shadow causes an alignment error between the target object in the image and the template, which in turn causes systematic errors in subsequent printed content and size inspections. Summary of the Invention
[0003] The present application provides a shadow processing method, device and equipment to at least solve the above technical problems existing in the prior art.
[0004] According to a first aspect of the present application, a shadow processing method is provided, the method comprising:
[0005] Obtaining an original image of the target object;
[0006] Based on the tone value of the original image, a first image is obtained; the first image includes a target object and a shadow of the target object;
[0007] Scanning the first image to determine a boundary of a target area in the first image; the target area includes an area formed by a target object and a shadow of the target object;
[0008] Determining shape parameters of a shadow of a target object in a target area based on a first parameter, a second parameter, and a third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of a camera of an original image;
[0009] determining a boundary of the target object in the first image based on a boundary of the target area in the first image and shape parameters of a shadow of the target object in the target area;
[0010] The shadow of the target object is removed based on the boundary of the target object in the first image and the boundary of the target area in the first image.
[0011] In one possible implementation manner, obtaining the first image based on the tone value of the original image includes:
[0012] Converting the original image from a first color space to a second color space;
[0013] Obtaining the hue value of the original image converted to the second color space;
[0014] determining a background area in the original image based on a tone value of the original image;
[0015] Based on the background area, a foreground area in the original image is obtained; the foreground area includes a target object and a shadow of the target object;
[0016] The image of the foreground area is used as the first image.
[0017] In one possible implementation manner, converting the original image from the first color space to the second color space includes:
[0018] Normalizing the red, green, and blue (RGB) values of the original image in the first color space to obtain RGB maximum values;
[0019] Determine the hue, saturation, and brightness (HSV) value corresponding to the original image in a second color space based on the RGB maximum value;
[0020] Based on the HSV value, the original image is converted from a first color space to a second color space.
[0021] In one embodiment, scanning the first image to determine a boundary of a target area in the first image includes:
[0022] Scanning the target area in the first image based on a line scanning algorithm to obtain a scanning line for the target area;
[0023] Determining a boundary point of the target area based on the scan line;
[0024] Based on the points on the boundary of the target area, the boundary of the target area in the first image is obtained.
[0025] In one embodiment, determining the shape parameter of the shadow of the target object in the target area based on the first parameter, the second parameter, and the third parameter includes:
[0026] Obtaining a first parameter of the target object based on a design document of the target object, wherein the first parameter is used to characterize a thickness of the target object;
[0027] Based on the design parameters of the camera, a second parameter and a third parameter are obtained; the second parameter is used to represent a first distance between the camera and the light source, and the third parameter is used to represent a second distance between the camera and the target object placement platform;
[0028] A shape parameter of a shadow of a target object in a target area is determined according to the first parameter, the second parameter, and the third parameter; the shape parameter is used to characterize a width of the shadow of the target object.
[0029] In one embodiment, determining the boundary of the target object in the first image based on the boundary of the target area in the first image and the shape parameters of the shadow of the target object in the target area includes:
[0030] A third distance is moved along the boundary of the target area in the first image in a direction close to the target object to obtain the boundary of the target object in the first image; the value of the third distance is the same as the shape parameter of the shadow of the target object.
[0031] In one embodiment, removing the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image includes:
[0032] determining an area between a boundary of the target object in the first image and a boundary of the target area in the first image as a shadow of the target object;
[0033] Remove the shadow of the target object.
[0034] According to a second aspect of the present application, a shadow processing device is provided, the device comprising:
[0035] A first acquisition module is used to acquire an original image of a target object;
[0036] A second acquisition module is configured to obtain a first image based on the tone value of the original image; the first image includes a target object and a shadow of the target object;
[0037] a first determining module, configured to scan the first image and determine a boundary of a target area in the first image; the target area includes an area formed by a target object and a shadow of the target object;
[0038] a second determining module, configured to determine a shape parameter of a shadow of a target object in a target area based on a first parameter, a second parameter, and a third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of a camera of an original image;
[0039] a third determining module, configured to determine a boundary of the target object in the first image based on a boundary of the target area in the first image and a shape parameter of a shadow of the target object in the target area;
[0040] The shadow removal module is used to remove the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image.
[0041] According to a third aspect of the present application, an electronic device is provided, including:
[0042] at least one processor; and
[0043] a memory communicatively connected to the at least one processor; wherein,
[0044] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the method described in any one of the above embodiments.
[0045] According to a fourth aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the present application.
[0046] The shadow processing method, device and equipment of the present application solve the problem of template alignment error caused by lighting shadows in packaging box inspection, avoids systematic errors in printed content and size inspection, and improves the quality of packaging boxes.
[0047] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The above and other objects, features and advantages of the exemplary embodiments of the present application will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, in which:
[0049] In the drawings, the same or corresponding reference numerals denote the same or corresponding parts.
[0050] Figure 1 A schematic diagram of the implementation process of the shadow processing method according to an embodiment of the present application is shown;
[0051] Figure 2 A schematic diagram of the photographing process according to an embodiment of the present application is shown;
[0052] Figure 3A schematic diagram of the process of cutting the background color area according to an embodiment of the present application is shown;
[0053] Figure 4 A schematic diagram of shadow removal according to an embodiment of the present application is shown;
[0054] Figure 5 A schematic structural diagram of a shadow processing device according to an embodiment of the present application is shown;
[0055] Figure 6 A schematic diagram of the structure of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0056] In order to make the purpose, features, and advantages of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of this application.
[0057] Related technologies use background removal based on the HSV (Hue, Saturation, Value) color space. Specifically, images captured by a line scan camera are converted from RGB (Red, Green, Blue) to the HSV color space. The background is then filtered based on the threshold of the HSV hue for the specific green background to remove the background. However, due to the presence of lighting shadows, even after extracting the green color using the HSV color space to create a mask and then using the mask to cut out the background, some shadows remain that cannot be removed. This leads to deviations during subsequent alignment with the template, causing systematic errors in the final printed content and size detection, and reducing the accuracy of the detection equipment.
[0058] The present application provides a shadow processing method that can solve the problem of deviation in alignment with the template caused by the presence of lighting shadows in the inspection of laptop computer packaging boxes, which leads to systematic errors in the final printed content and size inspection, thereby improving the accuracy of the inspection equipment.
[0059] The following describes a shadow processing method provided by the present application in conjunction with the accompanying drawings, the method comprising:
[0060] S101, obtaining an original image of a target object;
[0061] In this application, a camera is used to take pictures of a target object, wherein the camera can be a line scan camera, which scans the moving object line by line through a linear sensor, and combines multiple lines of images into a complete two-dimensional image in conjunction with mechanical movement.
[0062] The target object in this application is a notebook box. During the inspection of the notebook box, it is necessary to check the contents of the printed area and the slot size of the box based on the template to remove defective products and prevent defective products from entering the factory, affecting production efficiency and even causing customer complaints. Figure 2 As shown in the figure, during actual operation, when using line scan camera 1 to photograph a notebook box 2, the thickness t of the cardboard 2 to be inspected causes light source 3 to illuminate the cardboard 2, creating a shadow width s to be removed. The distance between light source 3 and line scan camera 1 is d, and the distance between line scan camera 1 and the inspection platform is h.
[0063] In this application, a line scan camera 1 is used to scan and photograph a notebook packaging box 2 to obtain an image of the notebook packaging box 2. It is understood that the original image can be an image obtained by photographing the notebook packaging box 2 using the line scan camera 1, or an image obtained by processing the photographed image.
[0064] S102, obtaining a first image based on the tone value of the original image; the first image includes a target object and a shadow of the target object;
[0065] It's important to note that before capturing the laptop box, a specific color background is required, such as green. The resulting image captured by the line scan camera will only contain the green background, the laptop box, and its shadow. This prevents the problem of indistinguishable shadows from the background due to excessive background color, leading to inaccurate detection.
[0066] After obtaining the original image, the present application can determine the background color area in the original image according to the hue value of the original image. The foreground area can be obtained by removing the background area, and the foreground area includes the target object and the shadow of the target object.
[0067] S103, scanning the first image to determine the boundary of a target area in the first image; the target area includes an area formed by the target object and the shadow of the target object;
[0068] In this application, the first image can be scanned using a line scan algorithm, thereby obtaining the boundary of the laptop packaging box and its shadow based on the scan result. It is understandable that at this time, the laptop cannot be distinguished from the shadow part.
[0069] S104, determining shape parameters of the shadow of the target object in the target area based on the first parameter, the second parameter, and the third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of the camera of the original image;
[0070] It's understandable that the first parameter of the target object is the thickness of the laptop packaging box, the second parameter of the camera is the distance between the light source and the line scan camera, and the third parameter is the distance between the line scan camera and the detection platform. This application calculates the width of the shadow to be removed based on the box thickness, the distance between the light source and the line scan camera, and the distance between the line scan camera and the detection platform.
[0071] S105, determining a boundary of the target object in the first image based on a boundary of the target area in the first image and shape parameters of a shadow of the target object in the target area;
[0072] After obtaining the boundary of the notebook packaging box and its shadow and the shape parameters of the shadow of the target object, the actual boundary position of the notebook packaging box can be obtained.
[0073] S106 , removing the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image.
[0074] Finally, the shadow of the target object can be determined according to the boundary of the target object in the first image and the boundary of the target area in the first image, and the shadow is removed.
[0075] The shadow processing method provided in this application uses a line scan camera to obtain an original image of a packaging box, then removes the background color area in the original image to obtain a first image, uses a line scan algorithm to determine the boundaries of the packaging box and its shadow in the first image, and then determines the width of the shadow based on the first parameter of the target object, the second parameter of the camera, and the third parameter. The boundary of the target object in the first image is determined by the boundary of the target area in the first image and the shape parameters of the shadow of the target object in the target area. Finally, the shadow of the target object is removed based on the boundary of the target object in the first image and the boundary of the target area in the first image. This application solves the problem of template alignment deviation caused by the presence of lighting shadows in laptop packaging box inspection, avoids errors in the final printed content and size inspection of the laptop packaging box, and improves the quality of the packaging box.
[0076] In some embodiments, obtaining an original image of a target object includes:
[0077] Identify the target object within the camera's framing range and use the image of the framing area that meets the first size as the original image of the target object
[0078] It is understood that the camera in this application may be a line scan camera, and the framing range in this application may be an area of any shape with a base color or background color, such as a green background area. Specifically, in this application, an image of a first size captured by the camera in an area of any shape with a base color or background color is used as the original image. The first size may be the maximum size of the packaging box area, or may be an area within the framing range where the packaging box meets the first size to ensure that the packaging box is included. It may also be a user-defined size, such as 1m×1.5m, or other custom sizes, which are not limited in this application.
[0079] This application first identifies the target object and uses a line array camera to obtain an image containing a packaging box.
[0080] In some embodiments, obtaining the first image based on the hue value of the original image includes:
[0081] Converting the original image from a first color space to a second color space;
[0082] Obtaining the hue value of the original image converted to the second color space;
[0083] determining a background area in the original image based on a tone value of the original image;
[0084] Based on the background area, a foreground area in the original image is obtained; the foreground area includes the target object and the shadow of the target object;
[0085] The image of the foreground area is taken as the first image.
[0086] Specifically, when the background color is the determined target color, a rectangular frame area is cut out based on the captured image as the original image of the target object. The target object may be a packaging box for a laptop computer.
[0087] like Figure 3As shown, in the present application, after identifying the packaging box, obtaining the original image of the packaging box can also be done by identifying a rectangular frame area within an area of any shape using a camera. Specifically, by identifying the vertices of the background rectangular area, the rectangular frame area is determined, and then the rectangular frame area is converted to a color space to obtain the hue value or color saturation of the background color of the rectangular frame area, thereby determining the background color and color saturation of the rectangular frame area. After determining the background color and color saturation, a rectangular frame area with the target color and / or target color saturation can be cut out from the video stream or image captured by the camera. The rectangular frame area with the background color is the original image. It should be noted that the CV algorithm is used in the present application to identify the rectangular frame area because the hue H component of the HSV color space can well distinguish green from other colors. For example, the hue component of green is around 120, which distinguishes it from the hues of other colors. Therefore, the background green and other colors can be distinguished by the hue component, thereby obtaining the hue value of green. Therefore, the original image is first converted from the first color space to the second color space. The first color space is the RGB color space, and the second color space is the HSV color space.
[0088] Furthermore, the original image obtained after the color space conversion is divided into two parts by the threshold value of the hue component, namely the background color part and the packaging box part. The background color part and the packaging box part are both discontinuous areas, and the two types of colors need to be counted. The color of the background color and the packaging box are determined by the statistical results. It is generally believed that the area of the background color is larger than the area of the packaging box, and the colors of the background color and the packaging box are very different, such as a green background and a yellow-brown packaging box, a green background color and a white packaging box, a green background color and a red packaging box, etc. After determining the background color, the rectangular frame area with the background color can be used as the original image. Alternatively, the background color can be preset to white, black or dark green. If the background color determined is the preset white, black or dark green, etc., then this rectangle is the background.
[0089] In some embodiments, converting the original image from the first color space to the second color space includes:
[0090] Normalize the red, green, and blue (RGB) values of the original image in the first color space to obtain the RGB maximum value;
[0091] Determine the hue, saturation, and lightness (HSV) values corresponding to the original image in the second color space based on the RGB maximum value;
[0092] The original image is converted from a first color space to a second color space based on the HSV value.
[0093] Specifically, in this application, the RGB value of the original image is first obtained, and the RGB value is normalized to obtain
[0094]
[0095] Where R is the R value of the original image, G is the G value of the original image, and B is the B value of the original image. R' is the normalized R value, G' is the normalized G value, and B' is the normalized B value.
[0096] Determine the normalized RGB value
[0097] C max =max(R′,G′,B′)
[0098] C min =min(R′,G′,B′)
[0099] C max is the maximum value of RGB, C min The minimum value of RGB.
[0100] Then calculate the corresponding HSV value based on the RGB value.
[0101]
[0102] V=C max
[0103] H is the H value of the original image in the HSV color space, S is the S value of the original image in the HSV color space, and V is the V value of the original image in the HSV color space.
[0104] Thus, the color space conversion of the original image is completed.
[0105] The background color area is determined based on the hue value of the background color. In this application, the background color is green.
[0106]
[0107] Mask green The hue value of the green background color.
[0108] In some embodiments, scanning the first image to determine a boundary of a target area in the first image includes:
[0109] Scanning the target area in the first image based on a line scanning algorithm to obtain a scan line for the target area;
[0110] Based on the scan line, determine the boundary points of the target area;
[0111] Based on the points of the boundary of the target area, the boundary of the target area in the first image is obtained.
[0112] In this application, the first thing to determine is that the boundary is a straight line.
[0113] y=mx+b
[0114]
[0115] Among them, y is a straight line, m is the slope, b is the intercept, and the two parameters of the straight line are fitted by the least squares method, where (x i ,y i ) is the point on each scan line that meets the outer boundary of the shadow, and N is the number of points that meet the conditions. Calculate the parameter b and finally obtain the line of the outer boundary of the shadow.
[0116] Specifically, the present application scans the target area in the first image through a line scanning algorithm, the target area includes the target object and its shadow, obtains a scanning line for the target area, determines the point of the boundary of the target object's shadow in the scanning line, and thus obtains the boundary straight line of the target object's shadow based on the point of the outer boundary of the shadow.
[0117] In some embodiments, determining a shape parameter of a shadow of a target object in a target area based on the first parameter, the second parameter, and the third parameter includes:
[0118] Obtaining a first parameter of the target object based on a design document of the target object; the first parameter is used to characterize a thickness of the target object;
[0119] Based on the design parameters of the camera, a second parameter and a third parameter are obtained; the second parameter is used to represent a first distance between the camera and the light source, and the third parameter is used to represent a second distance between the camera and the platform where the target object is placed;
[0120] A shape parameter of the shadow of the target object in the target area is determined according to the first parameter, the second parameter, and the third parameter; the shape parameter is used to characterize the width of the shadow of the target object.
[0121] Specifically, in the present application, the width of the shadow of the target object is calculated according to the thickness of the target object, the first distance between the camera and the light source, and the second distance between the camera and the platform on which the target object is placed.
[0122] Specifically, such as Figure 2 As shown, in this application, the design document of the packaging box is first parsed to obtain the thickness t of the packaging box, and then the design parameters of the camera are obtained to obtain the first distance d between the light source and the line scan camera, and the second distance h between the line scan camera and the detection platform where the target object is located. Figure 2 Similar triangles in triangle OAB and triangle DOC, we get
[0123]
[0124] get
[0125] Then get
[0126] Where s is the width of the shadow to be removed, d is the first distance, t is the second distance, and t is the thickness of the box.
[0127] In some embodiments, determining the boundary of the target object in the first image based on the boundary of the target area in the first image and shape parameters of the shadow of the target object in the target area includes:
[0128] The boundary of the target object in the first image is obtained by moving a third distance along the boundary of the target area in the first image in a direction close to the target object; the value of the third distance is the same as the shape parameter of the shadow of the target object.
[0129] Finally, if Figure 4 As shown, the boundary of the target area in the first image is moved toward the target object by the width of the shadow to be removed, and the obtained straight line is translated inward by a distance s to obtain the actual packaging box boundary.
[0130] In some embodiments, removing the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image includes:
[0131] determining an area between a boundary of the target object in the first image and a boundary of the target area in the first image as a shadow of the target object;
[0132] Remove the shadow of the target object.
[0133] It can be understood that, in the present application, the area between the boundary of the target object in the first image and the boundary of the target area in the first image is determined as the shadow of the target object, and then the shadow portion is removed.
[0134] The shadow processing method provided by this application first removes the green background through the HSV color space; then, a line scan algorithm is used to find the boundary of the target area. Finally, based on the distance d between the light source and the line scan camera, the distance h between the line scan camera and the detection platform, and the thickness t of the cardboard, the width s of the shadow to be removed is calculated, and the straight line found by the line scan algorithm is translated inward to obtain the true boundary of the packaging box, thereby removing the edge lighting shadow. The distance d between the light source and the line scan camera and the distance h between the line scan camera and the detection platform are read from the basic parameters of the equipment, and the cardboard thickness t is obtained from the packaging box design document. This application solves the problem of deviation from the template alignment caused by the presence of lighting shadows in the inspection of laptop packaging boxes, which leads to systematic errors in the final printed content and size detection, improves the accuracy of the inspection equipment, and ultimately improves the quality of the packaging box.
[0135] like Figure 5As shown, the present application provides a shadow processing device, the device comprising:
[0136] A first acquisition module 501 is used to acquire an original image of a target object;
[0137] The second acquisition module 502 is configured to obtain a first image based on the tone value of the original image; the first image includes a target object and a shadow of the target object;
[0138] A first determining module 503 is configured to scan the first image and determine a boundary of a target area in the first image; the target area includes an area formed by a target object and a shadow of the target object;
[0139] A second determining module 504 is configured to determine shape parameters of the shadow of the target object in the target area based on the first parameter, the second parameter, and the third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of the camera of the original image;
[0140] A third determining module 505 is configured to determine a boundary of the target object in the first image based on a boundary of the target area in the first image and a shape parameter of a shadow of the target object in the target area;
[0141] The shadow removal module 506 is configured to remove the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image.
[0142] The present application provides a shadow removal device, wherein a first acquisition module 501 acquires an original image of a target object; a second acquisition module 502 is used to obtain a first image based on the tone value of the original image; the first image includes the target object and the shadow of the target object; a first determination module 503 scans the first image to determine the boundary of a target area in the first image; the target area includes an area composed of the target object and the shadow of the target object; the second determination module 504 determines the shape parameters of the shadow of the target object in the target area based on a first parameter, a second parameter and a third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of the camera of the original image; the third determination module 505 determines the boundary of the target object in the first image based on the boundary of the target area in the first image and the shape parameters of the shadow of the target object in the target area; the shadow removal module 506 removes the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image.
[0143] It should be noted that the shadow processing device in the embodiment of the present application solves the problem in a similar principle to the aforementioned shadow processing method. Therefore, the implementation process, implementation principle, and beneficial effects of the shadow processing device can all be referred to the description of the implementation process, implementation principle, and beneficial effects of the aforementioned method, and the repetitive parts will not be repeated.
[0144] An embodiment of the present application provides an electronic device, including:
[0145] at least one processor; and
[0146] a memory communicatively connected to the at least one processor; wherein,
[0147] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the method described in any one of the above embodiments.
[0148] An embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the method described in any of the above embodiments.
[0149] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0150] Figure 6 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or claimed herein.
[0151] like Figure 6 As shown, the device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the device 800 can also be stored in the RAM 803. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0152] Various components in device 800 are connected to I / O interface 805, including an input unit 806, such as a keyboard, mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, optical disk, etc.; and a communication unit 809, such as a network card, modem, wireless communication transceiver, etc. The communication unit 809 allows device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0153] The computing unit 801 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as the shadow processing method. For example, in some embodiments, the shadow processing method can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the shadow processing method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the shadow processing method by any other suitable means (e.g., via firmware).
[0154] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0155] The program code for implementing the methods of the present application can be written in any combination of one or more programming languages. Such program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow charts and / or block diagrams are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0156] In the context of the present application, a machine-readable medium can be a tangible medium that can contain or store a program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0157] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0158] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0159] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0160] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of this application can be achieved. This is not limited herein.
[0161] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.
[0162] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A shadow processing method, characterized in that: The method comprises: Obtaining an original image of the target object; Based on the tone value of the original image, a first image is obtained; the first image includes a target object and a shadow of the target object; Scanning the first image to determine a boundary of a target area in the first image; the target area includes an area formed by a target object and a shadow of the target object; Determining shape parameters of a shadow of a target object in a target area based on a first parameter, a second parameter, and a third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of a camera of an original image; determining a boundary of the target object in the first image based on a boundary of the target area in the first image and shape parameters of a shadow of the target object in the target area; The shadow of the target object is removed based on the boundary of the target object in the first image and the boundary of the target area in the first image.
2. The method according to claim 1, characterized in that The step of obtaining a first image based on the tone value of the original image includes: Converting the original image from a first color space to a second color space; Obtaining the hue value of the original image converted to the second color space; determining a background area in the original image based on a tone value of the original image; Based on the background area, a foreground area in the original image is obtained; the foreground area includes a target object and a shadow of the target object; The image of the foreground area is used as the first image.
3. The method according to claim 2, characterized in that The converting of the original image from the first color space to the second color space includes: Normalizing the red, green, and blue (RGB) values of the original image in the first color space to obtain RGB maximum values; Determine the hue, saturation, and value (HSV) values corresponding to the original image in a second color space based on the RGB maximum values; Based on the HSV value, the original image is converted from a first color space to a second color space.
4. The method according to claim 1, wherein Scanning the first image to determine a boundary of a target area in the first image includes: Scanning the target area in the first image based on a line scanning algorithm to obtain a scanning line for the target area; Determining a boundary point of the target area based on the scan line; Based on the points on the boundary of the target area, the boundary of the target area in the first image is obtained.
5. The method according to claim 1, wherein The determining of the shape parameter of the shadow of the target object in the target area based on the first parameter, the second parameter, and the third parameter includes: Obtaining a first parameter of the target object based on a design document of the target object, wherein the first parameter is used to characterize a thickness of the target object; Based on the design parameters of the camera, a second parameter and a third parameter are obtained; the second parameter is used to represent a first distance between the camera and the light source, and the third parameter is used to represent a second distance between the camera and the target object placement platform; A shape parameter of a shadow of a target object in a target area is determined according to the first parameter, the second parameter, and the third parameter; the shape parameter is used to characterize a width of the shadow of the target object.
6. The method according to claim 1, characterized in that The determining the boundary of the target object in the first image based on the boundary of the target area in the first image and the shape parameters of the shadow of the target object in the target area includes: A third distance is moved along the boundary of the target area in the first image in a direction close to the target object to obtain the boundary of the target object in the first image; the value of the third distance is the same as the shape parameter of the shadow of the target object.
7. The method according to claim 1, characterized in that The step of removing the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image includes: determining an area between a boundary of the target object in the first image and a boundary of the target area in the first image as a shadow of the target object; Remove the shadow of the target object.
8. A shadow processing device, characterized in that: The device comprises: A first acquisition module is used to acquire an original image of a target object; A second acquisition module is configured to obtain a first image based on the tone value of the original image; the first image includes a target object and a shadow of the target object; a first determining module, configured to scan the first image and determine a boundary of a target area in the first image; the target area includes an area formed by a target object and a shadow of the target object; a second determining module, configured to determine a shape parameter of a shadow of a target object in a target area based on a first parameter, a second parameter, and a third parameter; wherein the first parameter represents an attribute parameter of the target object, and the second parameter and the third parameter represent parameters of a camera of an original image; a third determining module, configured to determine a boundary of the target object in the first image based on a boundary of the target area in the first image and a shape parameter of a shadow of the target object in the target area; The shadow removal module is used to remove the shadow of the target object based on the boundary of the target object in the first image and the boundary of the target area in the first image.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for detecting and eliminating shadow
CN102622763A
Method and arrangement for detecting free fibre ends in paper
CN105229464A
Target detection method and device
CN109961455A
Shadow removal method for pothole image
CN113487502A
Shadow processing method and device based on depth map, equipment and storage medium
CN116823911A