Low-computing-power target positioning method based on background color recognition
By using low-resolution image processing and background color recognition technology, the nail position of the nail lamp is accurately located, solving the problem of prolonged ultraviolet radiation to the skin in existing technologies. This achieves low-cost, low-power, precise UVLED irradiation and adaptability to different users.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU NAHUA COSMETICS CO LTD
- Filing Date
- 2026-01-22
- Publication Date
- 2026-05-15
AI Technical Summary
Existing nail lamps cannot distinguish between the nail area and the finger skin area, resulting in prolonged exposure of the skin to ultraviolet rays, causing dryness, aging, or allergies. Furthermore, they rely on high-computing platforms and complex models and lack adaptive capabilities.
By using low-resolution image processing and background color recognition technology to quickly separate the target area, and using edge finding or peak and valley algorithms to accurately locate the fingernail position, combined with super-resolution convolutional neural network and simple threshold comparison, the precise illumination coordinates of the UVLED array are output.
It achieves precise differentiation between the nail and skin areas, avoids unnecessary ultraviolet radiation, reduces hardware costs and power consumption, adapts to different users' hand shapes and usage environments, and has good versatility and robustness.
Smart Images

Figure CN122049045A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electrical data processing technology, specifically to a low-computing-power target localization method based on background color recognition. Background Technology
[0002] In existing technologies, nail lamps typically use UV or LED light sources to cure nails coated with gel. Traditional lamps are mostly of the whole-area illumination type, where the user's hand is placed inside the lamp box and the light source illuminates the entire area evenly. While this method can achieve curing, it has the following obvious drawbacks: Existing technology cannot distinguish between nail areas and finger skin areas that may have similar colors and textures, resulting in prolonged exposure of the hand skin to ultraviolet radiation, which may cause dry skin, aging, or even allergic reactions. Existing products lack the ability to automatically identify and adapt to the user's nail position and cannot adaptively irradiate according to different users' hand shapes and nail lengths. Existing methods still generally rely on training complex models with massive amounts of pre-collected and labeled hand image data, and depend on complex models and high-computing platforms. They are especially suitable for lightweight solutions with relatively simple backgrounds and known target types. Therefore, there is an urgent need for a control scheme that has high recognition accuracy, low cost, rapid response, and is suitable for intelligent recognition and output of coordinate information that can directly drive UVLED arrays for selective and precise irradiation, in order to overcome the above-mentioned problems in the existing technology. Summary of the Invention
[0003] To address the security risks, operational inconveniences, and reliance on high-computing-power platforms present in the aforementioned background technologies, this application provides a low-computing-power target localization method based on background color recognition. This method rapidly separates the target region on a low-resolution image using background color features, achieving precise target localization with extremely low computational complexity.
[0004] The low-computing-power target localization method based on background color recognition described in this application includes: S1. When a hand is inserted into the device, a low-resolution camera is used to capture a target image, which includes the hand, nails, finger skin, and background. S2. Reduce the image size to a preset pixel size suitable for calculation. S3. Extract the color values of the four sides of the image and take the median value as the background color; S4. Set a color similarity threshold of 10% to exclude the background color and similar color areas. The remaining area is the target coordinate. S5. Use edge search or peak-valley algorithm to accurately locate the target fingernail position; S6. Map the target coordinates of the image in the preset pixels onto the real image and output the real target coordinates for precise control of UVLED irradiation.
[0005] Preferably, in step S1, after acquiring the original image output by the low-resolution camera, it is first denoised by median filtering, then contrast is enhanced by histogram equalization, its Sobel gradient is calculated and high gradient regions are extracted to generate candidate target masks. If the mask area is less than a threshold, it is considered invalid and re-acquired; otherwise, the background is suppressed using the mask to obtain a foreground image containing only the target. The foreground image is then processed by a super-resolution convolutional neural network to obtain a high-resolution target image.
[0006] Preferably, in step S2, the size of the acquired original image is detected. If its initial resolution does not meet the preset specifications, it is first scaled proportionally, then the redundant edge areas are cropped, and if necessary, a second scaling is performed. For images with stable size, smooth interpolation is used to supplement pixels to preserve details, and its format is converted to adapt to subsequent processing. If the storage format still does not meet the system requirements, the encoding is adjusted to obtain a suitable output image.
[0007] Preferably, in step S3, pixels are batch-collected from the four sides of the image to obtain a preliminary color distribution set. The median color of each side is calculated using statistical methods. If the difference between sides is significant, a second analysis and adjustment are performed to determine a unified color reference value. The unified color reference value is compared with the edge pixels to obtain a suitable background color reference and optimize the image processing flow to obtain color mapping data consistent with the background. Then, the entire image is color-calibrated using a preset mechanism to detect the consistency between the image edges and the internal colors, ensuring that the processed data has no significant distribution deviation.
[0008] Preferably, in step S4, the pixel color values of the four sides of the image are collected and their medians are calculated. By calculating the color distance between the edges, edges exceeding the similarity threshold are marked as different edges. For the different edges, the region is expanded into the image and the colors are collected and the medians are calculated again to update the medians of the corresponding edges. This process is repeated until the color distances of the four sides are all below the threshold. A unified background median color is determined. A similarity range is set based on the background median color. All pixels in the image are traversed and their distances from the background color are calculated. Pixels with distances within the threshold are marked as background, and the rest are foreground, thus obtaining a background pixel mask. Based on the background pixel mask, connected foreground pixel regions are filtered and clustered to obtain the coordinate set of the target.
[0009] Preferably, in step S5, after converting the original hand image into a grayscale image, the gradient magnitude is calculated using the Sobel operator, and the edge image is obtained after binarization. Then, the broken edges are connected by morphological closing operation, and a one-dimensional projection is performed on the continuous edge image in the vertical direction. The peak and valley position set is found using the peak and valley detection algorithm, and the peak and valley pairs that satisfy the nail width constraint are selected as the effective boundary. The left and right contour point sets are extracted through the effective boundary, and the center coordinates are determined by fitting the minimum bounding rectangle to obtain the precise position coordinates of the target nail.
[0010] Preferably, in step S6, the target pixel coordinates in the preset pixel image and the actual size of the corresponding original image are obtained, the horizontal and vertical mapping ratio parameters are calculated, and the target pixel coordinates are multiplied by the above parameters by bilinear scaling to obtain preliminary physical coordinates. Then, the preliminary coordinates are translated and corrected by combining the origin offset between the original image and the actual printing coordinate system to obtain aligned physical coordinates. If the corrected coordinates exceed the actual printing range, boundary truncation is performed, and the processed physical coordinates are converted into integer grid coordinates used by the UVLED dot matrix control system to obtain the final coordinates for precise illumination.
[0011] The low-computing-power target positioning method based on background color recognition described in this application has the advantage that, through background color recognition and region exclusion algorithms, it can accurately distinguish between the nail and the surrounding skin area, thereby achieving precise positioning and irradiation of UV LEDs. This fundamentally avoids unnecessary long-term exposure of the skin to ultraviolet rays, significantly reduces the risk of skin dryness, aging or allergies, and greatly improves the safety of product use. Employing low-resolution image processing, simple color median extraction, and threshold comparison, and performing the main calculations on a thumbnail of preset pixels without relying on complex deep learning models or high-performance computing platforms, the algorithm can be easily deployed in low-cost, low-power embedded systems such as microcontrollers, greatly reducing hardware costs and overall power consumption. Instead of relying on pre-trained hand or nail models, it dynamically recognizes the actual background color of the placement environment. Therefore, it can automatically adapt to different users' hand sizes, nail lengths, placement angles, and changing daily usage environments, possessing good versatility and robustness. The output real target coordinates can directly and accurately control the UVLED array or scanning module. Attached Figure Description
[0012] Figure 1 This is the flowchart of a low-computing-power target localization method based on background color recognition as described in this application. Figure 1 ; Figure 2 This is the flowchart of a low-computing-power target localization method based on background color recognition as described in this application. Figure 2 ; Figure 3 This is the flowchart of a low-computing-power target localization method based on background color recognition as described in this application. Figure 3 . Detailed Implementation
[0013] like Figures 1-3 As shown, the low-computing-power target localization method based on background color recognition described in this application includes: like Figures 1-3 As shown, S1, a low-resolution camera is used to capture the target image, which includes the hand, nails, finger skin, and background.
[0014] Further, in step S1, the raw image output by the low-resolution camera is acquired; The original image is denoised by using a median filter to obtain a denoised image. Histogram equalization is then used to enhance the contrast of the denoised image to obtain a contrast-enhanced image. The gradient image is obtained by calculating the Sobel gradient magnitude map based on the contrast-enhanced image. High gradient regions are extracted from the gradient image to form candidate target masks. If the area of the candidate target mask is smaller than the preset threshold, it is marked as an invalid region and the original image is re-acquired; otherwise, the mask is retained. Background suppression is performed on the contrast-enhanced image using a mask pair to obtain a foreground image containing only the target; A high-resolution target image is obtained by processing the foreground image using a super-resolution convolutional neural network.
[0015] Specifically, in step S1, a low-resolution USB camera with a resolution of 320×240 pixels is fixed in an indoor environment to capture images including hands, nails, and finger skin; The frames are read using OpenCV's cv2.VideoCapture(0) and the frame rate is set to 15fps to reduce the computational load. Each frame image is converted to the YUV color space and only the Y channel grayscale image is retained to reduce color noise interference. A background modeling method based on inter-frame difference is adopted, and the background model is initialized with the pixel-level median of the first 50 frames. The calculation formula is as follows:
[0016] Where B(x,y) is the pixel value of the background model at pixel position (x,y), and I t (x,y) represents the pixel value at pixel position (x,y) in the t-th frame image, and median is the median operation used to estimate the static background from a continuous frame sequence; The difference image is obtained by subtracting the background model from the current frame. The calculation formula is as follows:
[0017] Where D(t) is the difference image of the t-th frame, that is, the absolute difference image between the current frame and the background model, I(t) is the complete image of the t-th frame, and B(x,y) is the pixel value of the background model at the corresponding position. Set an adaptive threshold: Th is the adaptive binarization threshold, α is the adjustment coefficient used to control the sensitivity of the threshold to the average difference, and mean(D(t)) is the average value of all pixel values in the difference map D(t). α is set to 0.8 to adapt to changes in illumination. After binarization, the foreground mask is obtained:
[0018] Where M(t) is the binarized foreground mask of the t-th frame, where 1 represents the foreground (target) and 0 represents the background; Using morphological opening operations, a 3×3 square structuring element is eroded once and then expanded once to remove salt and pepper noise and fill small voids. The 8-connectivity rule is used to perform connected component analysis, and connected components with an area greater than 150 pixels and an aspect ratio between 0.3 and 2.5 are selected as candidate target regions to avoid false detection of fragments. For each candidate region, calculate the Hu invariant moment feature vector. Specifically, the threshold matching error of the first 3 Hu moments is <0.12. Compare the similarity with the pre-stored limb template. After confirming the real limb target, output its bounding rectangle coordinates and confidence score of 0.94. The system achieves fully automated target detection and localization in low-resolution environments. The entire process has an average processing latency of 68ms on an embedded device with a CPU clock speed of 0.4GHz, meeting real-time requirements.
[0019] like Figures 1-3 As shown, S2, reduce the image to a suitable calculation size preset pixels.
[0020] Furthermore, in step S2, the size of the acquired original image is detected to obtain its initial resolution information, and it is determined whether it meets the preset processing specifications. If the initial resolution does not meet the preset specifications, the original image is resized using a scaling method to obtain a first image that meets the specifications. Based on the pixel distribution of the first image, redundant edge areas are removed using a cropping tool to obtain the cropped second image; If the size of the second image still exceeds the preset range, it is scaled a second time to obtain a third image with a stable size. For the third image, a smooth interpolation method is used to supplement the pixels, resulting in a fourth image that preserves details; By converting the format of the fourth image, the final image data suitable for subsequent processing can be obtained; If the storage format of the final image data does not meet the system requirements, it will be encoded and adjusted to obtain a suitable output image.
[0021] Specifically, in step S2, in the field of low-resolution image processing, the process of scaling an image to a preset suitable computational size of 256×256 pixels is fully automated through the following methods; The preset input image is an indoor scene image captured by a camera with a resolution of 640×480 pixels. The cv2.resize function in the OpenCV library is used to scale the original image to 256×256 pixels using bilinear interpolation to reduce the amount of subsequent calculations. The scaling ratios are 0.533 and 0.4, corresponding to the width and height directions respectively, to ensure that the image details are still discernible after scaling. Image quality is optimized using Gaussian filtering for smoothing. The filter kernel size is set to 5×5, and the standard deviation σ is 1.2 to reduce jagged noise that may be introduced by scaling. Smoothing is achieved by calculating the weighted average of each pixel and its surrounding pixels, with the weights based on the Gaussian distribution formula:
[0022] Where G(x,y) is the weight value of the Gaussian filter at the relative center offset (x,y), σ is the standard deviation of the Gaussian distribution, which controls the smoothness, and x,y are the pixel offset coordinates relative to the center of the filter; Brightness equalization is performed using a histogram equalization algorithm to remap the image's grayscale value range from 0-255, enhancing contrast. Specifically, the new grayscale values are calculated using the cumulative distribution function.
[0023] Among them, s k The new gray level is mapped to the original gray level k after equalization, ranging from 0 to 255, n. i Let i be the number of pixels with gray level i, and N be the total number of pixels in the image; The above calculations are used to adapt image feature extraction under different lighting conditions; To address the potential edge blurring issue after scaling, the Canny edge detection algorithm was employed, with a low threshold of 50 and a high threshold of 150. By calculating the image gradient intensity and direction, significant edge points were selected, and edge refinement was achieved through non-maximum suppression and double threshold connection to obtain an edge map for subsequent analysis. The edge map is used as auxiliary information input into the target segmentation module. Combined with a pre-trained simple threshold segmentation method, the grayscale threshold is set to 120. The image is binarized to separate the foreground and background. The proportion of the foreground region is calculated. If the proportion is less than 0.1, it is determined that there is no significant target and the next frame processing is automatically triggered to form a closed loop logic. The processed 256×256 pixel image and edge information are stored as temporary data for use in deep learning models. The storage format is an 8-bit unsigned integer, occupying approximately 64KB of memory, and is used for full automation of the process from scaling to preprocessing.
[0024] like Figures 1-3 As shown, S3 extracts the color values of the four sides of the image and takes the median value as the background color.
[0025] Furthermore, in step S3, pixel data is obtained from the four-sided region by analyzing the image edges, and color information of each region is collected by batch reading to obtain a preliminary color distribution set; Based on the preliminary color distribution set, data calculations are performed for each quadrilateral region, and statistical methods are used to process the pixel data to determine the median color value of each side. If there are significant differences in the color median results across different sides, a secondary analysis of the color distribution is performed to obtain adjusted median data and determine a unified color benchmark value. For a unified color reference value, the edge pixels are compared to determine whether they meet the preset background reference conditions, and an adapted background color reference is obtained. Based on the adapted background color reference and combined with the logic of region division, the image processing flow is optimized to obtain color mapping data consistent with the background reference. Starting from color mapping data, a pre-established color adjustment mechanism is used to perform color calibration on the entire image to obtain the final background color application result; Based on the final background color application result, consistency detection is performed on the image edges and internal regions to determine whether there is a color distribution deviation and to determine the processed image data.
[0026] Specifically, in step S3, in the field of low-resolution image processing, the process of extracting the color values of the four sides of an image and taking the median value as the background color is fully automated through the following methods; The preset input image is an indoor monitoring screen with a resolution of 320×240 pixels. Through the image boundary extraction algorithm, the system automatically obtains a 10-pixel-wide area at each of the top, bottom, left, and right edges of the image. The system calculates the RGB color value of the pixels in each area. Specifically, the system sums the R, G, and B channel values of all pixels in each area and takes the average to obtain the average color value of the four boundary areas. For example, the top boundary has R=120, G=110, and B=100; the bottom boundary has R=125, G=115, and B=105; the left boundary has R=118, G=108, and B=98; and the right boundary has R=122, G=112, and B=102. The median of the color values in these four regions is calculated, and the median value is taken after sorting each channel separately to obtain the background color reference values R=121, G=111, B=101. The algorithm uses quicksort to sort the four values, and the time complexity is O(nlogn). This background color value is used as a global reference for subsequent image segmentation modules; The formula for calculating the Euclidean distance between each pixel and the background color is:
[0027] Where d is the Euclidean distance between the current pixel color and the reference background color, and R, G, B are the red, green, and blue channel values of the current pixel, respectively. ref G ref B ref The red, green, and blue channel values are used as a reference for the background color; Set a distance threshold of 30 to automatically distinguish between foreground and background regions. If the distance is greater than the threshold, it is marked as foreground; otherwise, it is marked as background, thus obtaining a preliminary segmentation result. The segmentation result is compared with the color distribution of the central region of the image, and the average color value of the central 100×100 pixel region is calculated, for example, R=130, G=120, B=110. If the deviation from the background color is less than the threshold of 15, the background color is automatically adjusted to a new average value of R=126, G=116, B=106 to adapt to complex scenes. The background color data is stored as a temporary variable in RGB format, occupying only 3 bytes of memory, and is used by the image processing module.
[0028] like Figures 1-3 As shown in step S4, set a color similarity threshold of 10% to exclude the background color and similar color areas, and the remaining area is the target coordinate.
[0029] Further, in step S4, the pixel color values of the top, bottom, left and right sides of the image are collected, and the median color value of each side is calculated to obtain a set of median colors of the four sides; Calculate the color distance for each pair of median colors within the set of median colors of the four sides. If there is a color distance that exceeds the preset similarity threshold, mark the corresponding two sides as different sides. For the marked difference edge, extend a fixed-width region into the interior of the image and collect the color values of all pixels in the extended region; The median color of the extended region is used to replace the original median color of the differing edge, and the set of median colors of the four edges is updated. Repeat the color distance calculation and difference edge marking until the distance of all colors in the median color set of the four sides is lower than the preset similarity threshold, and determine the median color of the unified background. A color similarity threshold range is set based on the median color of the uniform background. All pixels in the image are traversed, and the distance between each pixel and the median color of the uniform background is calculated. If the distance is less than or equal to the threshold range, the pixel is marked as a background pixel; otherwise, it is marked as a foreground pixel, thus obtaining the background pixel mask. Based on the background pixel mask, all foreground pixel position coordinates are filtered out, and the foreground pixel regions are clustered and connected to obtain the target coordinate set.
[0030] Specifically, in step S4, in the field of low-resolution image processing, a color similarity threshold of 10% is set to exclude background and similar color regions and determine the target coordinates. This process is implemented through a fully automated algorithm. The preset input image is an indoor scene with a resolution of 640×480 pixels. First, the image is converted from RGB format to HSV format through a color space conversion algorithm to more accurately analyze color similarity. Specifically, the hue (H), saturation (S), and lightness (V) of each pixel are calculated to obtain the color distribution data of the entire image. For example, 10,000 pixels are randomly sampled, and the average H value of 30, S value of 0.5, and V value of 0.7 are calculated as a reference. Based on preset background color values (H=32, S=0.48, V=0.68), the color difference between each pixel and the background color is calculated using the Euclidean distance formula:
[0031] Where, d HSV H is the Euclidean distance between the current pixel color and the reference background color in the HSV color space; H, S, and V are the hue, saturation, and lightness of the current pixel, respectively. ref ,S ref V ref Use the HSV value of the reference background color; Color similarity judgment criteria: , where d HSV d is the color distance of the current pixel. maxThe maximum possible value of the color distance is 0.1, which is the similarity threshold of 10%. If the value is less than or equal to this, it is determined to be a similar color to the background. The similarity threshold is set to 10%, meaning that pixels with a distance of less than 0.1 are marked as background similarity regions. For example, in the calculation, it was found that about 60% of the pixels had a distance value below 0.08 and were automatically classified as background. For the remaining non-background areas, a clustering algorithm, specifically K-means with K=3, is used to group the color distribution and analyze the center coordinates of the main target areas. For example, if the clustering results show that a group of pixels are concentrated in the upper left corner of the image with center coordinates (x=150, y=120) and an area of about 15%, it is identified as the target area. Further combining image gradient analysis, the gradient intensity of the target region edge was calculated, with an average value of 5.2, which is higher than the 3.8 of other non-background regions, confirming it as a significant target; The target coordinates and related color features (H=45, S=0.6, V=0.75) are stored as structured data, occupying approximately 10 bytes of memory, for use by the target tracking module.
[0032] In one embodiment, the Euclidean distance between the color of each pixel in the image and the uniform background color in the HSV color space is calculated; pixels whose distance is less than or equal to the similarity threshold are identified as background pixels to obtain a background pixel mask; the background pixel mask is inverted to obtain a preliminary foreground region mask, and the image coordinate range corresponding to the preliminary foreground region mask is used as the original coordinate range.
[0033] like Figures 1-3 As shown, S5 uses edge search or peak-valley algorithm to accurately locate the target fingernail position.
[0034] Further, in step S5, the original hand image is acquired and converted into a grayscale image to obtain a grayscale image; The gradient magnitude image is obtained by calculating the gray-level gradient in the horizontal and vertical directions of the gray-level image using the Sobel operator; Binarization of the gradient magnitude image yields a binary edge image; A continuous edge image is obtained by connecting broken edges in a binary edge image using morphological closing operations; A vertical projection curve is obtained by performing a one-dimensional projection of pixel intensity in the vertical direction on a continuous edge image. A peak and valley detection algorithm is used to find all peak and valley positions on the vertical projection curve to obtain a set of peak positions and a set of valley positions. If the distance between adjacent peaks and troughs satisfies the nail width constraint, then the peak-trough pair is retained to obtain a valid nail boundary pair. The left and right contours of the nail are obtained by extracting the corresponding left and right contour point sets based on the effective nail boundary. The nail region rectangle is obtained by fitting the left and right contours of the nail with the minimum bounding rectangle. The position coordinates of the target nail are determined by the center coordinates of the nail region rectangle.
[0035] Specifically, in step S5, in the technical implementation of accurately locating the target fingernail position using edge detection or peak-valley algorithms, the entire process of target detection and localization is completed through automated processing: The default input image is a color image of a hand with a resolution of 1920x1080. The system will first preprocess the image, convert it to a grayscale image, and apply a Gaussian blur filter. Specifically, the kernel size is 5x5 and the standard deviation is 1.5 to reduce noise interference. The Canny edge detection algorithm is used to extract edge features in the image. The low threshold is set to 50 and the high threshold is set to 150 to obtain the contour information of the hand and nail regions. By calculating the contour area, contours with an area greater than 500 pixels are filtered out to eliminate irrelevant noise. Based on the edge detection results, the system further analyzes the geometric characteristics of the contour, such as calculating the ellipse fitting degree of the contour. The nail is preset to be approximately elliptical in shape, and regions with a fitting degree greater than 0.8 are considered as candidate regions, which are used to initially locate the possible position of the nail. The peak-valley algorithm is used to analyze the gray value distribution of the candidate region. Specifically, the gray value sequence is extracted along the contour boundary, for example, every 2 pixels. The gray value peaks are found through one-dimensional signal processing. The peaks are greater than 1.2 times the average value and the valleys are less than 0.8 times the average value. These are used to determine the junction between the nail and the skin. If the peaks and valleys alternate more than 3 times, they are confirmed as nail edge features. Combining edge location and peak / valley features, the system uses the minimum bounding rectangle algorithm to calculate the center point coordinates of the nail region, for example, the center point is x=850, y=600, and outputs the positioning result. At the same time, the result is compared with the hand key point detection, which includes the fingertip position, with an error range of ±10 pixels, to ensure positioning accuracy.
[0036] like Figures 1-3 As shown, S6 maps the target coordinates on the preset 256×256 pixel image onto the real image and outputs the real target coordinates for precise control of UVLED irradiation.
[0037] Further, in step S6, the target pixel coordinates and the corresponding original image size in the 256×256 image are obtained; Calculate the horizontal and vertical mapping parameters based on the original image size and the actual print size; Using a bilinear scaling method, the target pixel coordinates are multiplied by the horizontal mapping parameter and the vertical mapping parameter respectively to obtain the preliminary physical coordinates; Obtain the offset between the origin of the original image coordinate system and the origin of the actual printed coordinate system; The aligned physical coordinates are obtained by translating and correcting the initial physical coordinates using offsets. Determine whether the aligned physical coordinates exceed the actual print size range. If they do, perform truncation to retain the portion within the boundary. The corrected physical coordinates are converted to integer grid coordinates of the UVLED dot matrix control system to obtain the final irradiation coordinates.
[0038] Specifically, in step S6, the preset original detection model outputs the target center coordinates as (cx, cy) = (142.3, 87.6) on a scaled image of 256×256. This 256×256 image is obtained by scaling down the original image of the true resolution of 4096×4096 by a factor of 16 through bilinear interpolation. Calculate the scaling factor: scale = 4096 / 256 = 16.0. Then, multiply the detected coordinates by the scaling factor to obtain the initial values of the real image coordinates. cx ,real cy =(142.3×16,87.6×16)=(2276.8,1401.6). Due to the sub-pixel alignment offset during bilinear scaling, it is necessary to compensate for the interpolation center deviation of 0.5 pixels. Therefore, after adding 0.5 in the 256×256 domain, it is rescaled. That is, (realcx, realcy) = ((142.3+0.5)×16-8,(87.6+0.5)×16-8)=(2284.8-8,1409.6-8) =(2276.8,1401.6) The verification results remain consistent, indicating that the images in this batch are well aligned. To match the actual projected coordinate system of the DMD device in the UVLED exposure machine, affine transformation correction is required. The transformation matrix from camera pixel coordinates to DMD coordinates, obtained through calibration, is known to be: ,
[0039] Where x, y are the original image coordinates, which have been normalized, x′, y′ are the transformed coordinates corresponding to the DMD coordinate domain of the UVLED exposure machine, and H is a 3×3 affine transformation matrix, which includes rotation, scaling, and translation transformation parameters. Inputting the normalized coordinates [x,y,1]=[2276.8 / 4096,1401.6 / 4096,1] into the matrix yields the DMD domain coordinates (x... dmd ,y dmd = (2292.2, 1392.0); Based on the field-of-view mapping relationship of the 2540×1080 resolution DMD of the UVLED exposure machine, the coordinates (2162, 1437) are further shifted (-130, +45) and rounded to obtain the final integer coordinates (2162, 1437) used to precisely control the UVLED to expose only in the target area. The error of the entire process is less than 0.8 pixels, which meets the industrial exposure accuracy requirement of ±2 pixels. The final integer coordinate transformation is as follows:
[0040] x′, y′ are the coordinates after the affine transformation, Δx, Δy are the coordinate system translation offsets, and round() is the rounding function. final ,y final These are the integer coordinates ultimately used to control UV LED irradiation.
[0041] In one embodiment, up to 20 most similar fingertip regions can be identified. The target of identification is the fingertip, that is, the region at the end of the finger with raised features, rather than being strictly limited to the nail itself. The output coordinate matrix is directly input into the UVLED dot matrix control system to control the precise irradiation of each nail area; The matrix serves as a unified coordinate output structure within the system, directly transmitting it to the UVLED dot matrix control system. Illumination control is applied only to valid coordinate rows, while invalid rows are automatically ignored.
[0042] In one embodiment, this embodiment provides another implementation of a low-computing-power target localization method based on background color recognition. The steps correspond to the aforementioned method, but different strategies are employed in the background color determination, initial point localization, contour extraction, and fingertip detection stages, as detailed below: S1. Use a low-resolution camera to capture target images containing hands, fingernails, and background; S2. Reduce the size of the acquired image to the preset calculation size; S3. The background color is determined using the four-corner sampling method, specifically including: The sampling block size is dynamically calculated, and 1 / 20 of the minimum value of the image width and height is taken as the side length of the sampling block. Pixel color values are collected in the four corners of the image, including the square areas at the top left, top right, bottom left, and bottom right. The average value of each channel in the RGB color space is calculated to obtain the background color reference value. S4. Perform foreground separation based on background color to obtain the preliminary foreground region, specifically including: Start by scanning horizontally from the bottom edge of the image to find color abrupt changes that are significantly different from the background color, which can be used as the initial search point for the hand to enter the image; Calculate the squared Euclidean distance between the color of each pixel in the image and the background color. If the distance is greater than the squared of a preset color threshold, the pixel is identified as a hand pixel, and a binarized mask is generated. Morphological closing operations are performed on the mask to eliminate noise and fill holes, resulting in the complete hand region; The Moore neighborhood tracking algorithm was used to extract the hand contour, and orientation correction and height threshold truncation were performed to exclude the forearm part and retain the contour point sequence of the palm and finger areas. S5. Locate the fingertip position from the outline, specifically including: The wrist center point is calculated based on the start and end points of the contour as a reference point; Calculate the squared Euclidean distance from each contour point to the center point of the wrist, forming a distance sequence; Use a three-state machine, including SEARCHING, RISING, and PEAK. FOUND Peak detection is performed to identify the peak positions in the distance sequence. Specifically, SEARCHING identifies the starting point of the increase, RISING represents the distance increase state, and peaks are continuously updated. FOUND A peak has been detected; the wave is waiting to decline. Insignificant local peaks are filtered out based on the minimum prominence threshold, preserving the true fingertip position; If no valid peak is detected, the global maximum distance point is used as the fallback output; S6. Map the fingertip coordinates back to the original image size, and output the real target coordinates for controlling the UVLED array illumination through coordinate transformation; In this embodiment, the core steps of background color extraction, hand contour tracking, and fingertip detection are implemented using algorithms different from those in the aforementioned specific implementation methods, including four-corner sampling, bottom scanning initial point, Moore contour tracking, and distance peak detection. It still falls within the scope of the low-computing-power target localization method based on background color recognition described in this invention, and is suitable for embedded low-computing-power platforms to achieve fast and robust detection and localization of fingertip (nail) positions.
[0043] For those skilled in the art, various other corresponding changes and modifications can be made based on the technical solutions and concepts described above, and all such changes and modifications should fall within the protection scope of the claims of this application.
Claims
1. A low-computing-power target localization method based on background color recognition, characterized in that, include: S1. When a hand is inserted into the device, a low-resolution camera is used to capture a target image, which includes the hand, nails, finger skin, and background. S2. Reduce the size of the acquired image to the preset calculation size; S3. Extract pixel color values from the four sides of the reduced-size image, calculate and determine a uniform background color; S4. Using the background color as a reference, according to the preset color similarity threshold, pixels in the image that are similar to the background color are marked as background areas and excluded, to obtain a preliminary foreground area including the finger skin area and the nail area, and to obtain the original coordinate range of the preliminary foreground area in the image. S5. From the preliminary foreground area, by analyzing the geometric shape of the finger contour, identify the protruding features on the fingertip contour line, and use edge finding or peak and valley algorithm to locate the boundary between the nail and the finger skin, in order to separate the nail area, and calculate the center position coordinates of the nail area. S6. The coordinates of the center position of the nail area calculated on the reduced-size image are mapped back to the original resolution image according to the image scaling ratio, and the real target coordinates for precise control of UVLED array irradiation are output.
2. The low-computing-power target localization method based on background color recognition according to claim 1, characterized in that, In S3, determining the uniform background color includes: Calculate the median color value for each of the four regions on the top, bottom, left, and right sides of the image; Compare the differences between the median colors of each side. If the difference exceeds a preset threshold, expand the sampling range of the corresponding edge region into the image, recalculate the median color, and iterate this process until a consistent median background color is obtained on all four sides and used as a unified background color.
3. The low-computing-power target localization method based on background color recognition according to claim 1, characterized in that, In S4, the preset color similarity threshold is 10%.
4. The low-computing-power target localization method based on background color recognition according to claim 3, characterized in that, S4 further includes: Calculate the Euclidean distance between the color of each pixel in the image and the uniform background color in the HSV color space; Pixels whose distance is less than or equal to the similarity threshold are identified as background pixels, and a background pixel mask is obtained; Invert the background pixel mask to obtain a preliminary foreground region mask, and use the image coordinate range corresponding to the preliminary foreground region mask as the original coordinate range.
5. The low-computing-power target localization method based on background color recognition according to claim 1, characterized in that, In S5, the step of analyzing the geometric shape of the finger contour, identifying the raised features on the fingertip contour line, and locating the nail area using a peak-valley algorithm includes: The image containing the initial foreground region is converted into a grayscale image and edge detection is performed to obtain a binary edge image of the hand contour; A morphological closing operation is performed on the binary edge image to connect the broken edges and obtain a continuous hand contour; Pixel intensity projection is performed on the continuous hand contour along the vertical direction to obtain a one-dimensional projection curve; A peak and valley detection algorithm is used on the one-dimensional projection curve to identify the peak position and adjacent valley position that represent the protrusion feature of the fingertip. Based on the preset nail width constraints, valid peak-valley pairs are selected to determine the upper and lower boundaries of the nail. Based on the valid boundary pairs, the left and right contour points of the nail are extracted. The nail region is obtained by fitting the minimum bounding rectangle, and the center coordinates of the rectangle are used as the center position coordinates of the nail region.
6. The low-computing-power target localization method based on background color recognition according to claim 1, characterized in that, In S6, obtain the image scaling factor from S2; Multiply the coordinates of the center position of the nail region calculated in S5 by the scaling factor to obtain the preliminary mapped coordinates on the original resolution image. Based on the calibration transformation relationship between the camera coordinate system and the UVLED dot matrix control system coordinate system, the preliminary mapping coordinates are subjected to affine transformation and translation correction. The corrected coordinates are converted into integer grid coordinates that can be recognized by the UVLED dot matrix control system, which are then used as the actual target coordinates for controlling the irradiation.