Pointer type instrument training picture synthesis method and device, equipment and storage medium
By separating and randomly rotating the pointer instrument pictures, diversified training pictures are generated, which solves the problem of lack of diversity in training data in the prior art, and improves the generalization ability and recognition accuracy of the model.
Patent Information
- Application Number
- CN202411827768.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-03-21
AI Technical Summary
The lack of diversity in training data used in the recognition process of existing pointer instruments, resulting in a decrease in generalization ability and recognition accuracy of training models.
By separating the original image of the pointer instrument picture, obtaining the pointer picture and dial picture, and using image processing technology to randomly rotate the pointer to generate training pictures of different pointer positions.
The content of the training data set has been greatly enriched, the generalization ability of deep learning models has been improved, the human and material resources required to collect actual pictures have been significantly reduced, and the accuracy and robustness of the identification system have been improved.
Smart Images

Figure CN119671867A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method, device, equipment and storage medium for synthesizing pointer instrument training images. Background Art
[0002] During the intelligent inspection of the power distribution room, the inspection robot needs to automatically identify the pointer instrument to grasp the working status of the equipment in time. At present, the recognition method based on deep learning is widely used due to its robustness and high accuracy. However, this method is highly dependent on a large number of diverse training pictures. In actual operation, collecting and taking these pictures faces many limitations and is time-consuming and laborious. In addition, since the equipment parameters are usually in a stable state, the pictures taken often show the same readings, resulting in a lack of diversity in the training data. When using such homogeneous data sets to train models, overfitting is prone to occur, causing the model's recognition ability to drop sharply when encountering changes in the pointer position, affecting the overall adaptability. Therefore, the lack of diversity in the training data used in the existing pointer instrument recognition process has led to a decrease in the generalization ability and recognition accuracy of the training model, which is an urgent problem to be solved. Summary of the invention
[0003] The main purpose of this application is to provide a method, device, equipment and storage medium for synthesizing pointer instrument training images, aiming to solve the technical problem that the training data used in the pointer instrument recognition process lacks diversity, resulting in reduced generalization ability and recognition accuracy of the training model.
[0004] In order to achieve the above-mentioned invention object, the present application proposes a method for synthesizing a pointer instrument training picture, characterized in that the method comprises:
[0005] Separate the pointer of the original image of the pointer instrument to obtain the pointer image and the dial image;
[0006] Defining key points of the original image, wherein the key points include the center point of the dial, the end point of the pointer, the minimum scale point and the maximum scale point;
[0007] Determine the coordinate vectors of the remaining key points starting from the center point of the dial;
[0008] Calculate the rotatable angle range of the current pointer based on the coordinate vector;
[0009] Based on the rotation center of the pointer, a rotation angle is randomly generated within the rotatable angle range to rotate the pointer in the pointer image to obtain a second pointer image;
[0010] The second pointer image is superimposed on the dial image to obtain a training image.
[0011] Furthermore, the step of separating the pointer of the original image of the pointer-type instrument to obtain the pointer image and the dial image includes:
[0012] Preprocessing the original image;
[0013] Get the pointer area;
[0014] A mask is used to extract the pointer area from the original image to generate a pointer image, wherein the area outside the pointer area in the pointer image is a transparent background;
[0015] Use the reverse mask to extract the dial area from the original image and generate the dial image.
[0016] Furthermore, the step of determining the coordinate vectors of the remaining key points starting from the center point of the dial includes:
[0017] Identify the coordinate values of the center point of the dial, the end point of the pointer, the minimum scale point, and the maximum scale point;
[0018] Taking the center point of the dial as the starting point, the coordinate value of the starting point to the coordinate value of the pointer end point, the coordinate value of the minimum scale point and the coordinate vector formed between the coordinate value of the minimum scale point are calculated.
[0019] Furthermore, the step of calculating the rotatable angle range of the current pointer based on the coordinate vector includes:
[0020] Calculate the angle A between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the minimum scale point, and the angle B between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the maximum scale point by using the vector angle formula;
[0021] Taking the coordinate vector of the current pointer end point as the rotation starting point, based on the preset positive direction, determine the current pointer's rotatable angle range; where, if the clockwise direction is specified as the positive direction, the pointer's rotatable angle range is between [-A, B]; if the counterclockwise direction is specified as the positive direction, the pointer's rotatable angle range is between [A, -B].
[0022] Furthermore, before the step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain the second pointer picture, the step includes:
[0023] Obtain the coordinate value of the center point of the dial in the original image;
[0024] Find the corresponding coordinate position on the pointer image based on the coordinate value of the center point of the dial;
[0025] The rotation center is determined based on the coordinate position.
[0026] Furthermore, the step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain a second pointer picture includes:
[0027] Identifying a boundary value of the rotatable angle range;
[0028] Randomly generate a corresponding angle value within the numerical interval of the boundary value;
[0029] determining a rotation angle based on the angle value;
[0030] The rotation angle of the current pointer around the rotation center is adjusted based on the pointer image to generate a second pointer image.
[0031] Furthermore, the step of superimposing the second pointer image with the dial image to obtain a training image includes:
[0032] Traversing the color channels of the second pointer picture;
[0033] The pixel values of the non-transparent part in the second pointer image are copied to the corresponding positions of the corresponding color channels in the dial image to obtain the training image.
[0034] The second aspect of the present application provides a synthesis device for pointer-type instrument training pictures, comprising:
[0035] A separation module is used to separate the pointer of the original image of the pointer instrument to obtain the pointer image and the dial image;
[0036] A definition module, used for defining key points of the original image, wherein the key points include a dial center point, a pointer end point, a minimum scale point, and a maximum scale point;
[0037] A determination module, used to determine the coordinate vectors of the remaining key points starting from the center point of the dial;
[0038] A calculation module, used for calculating the rotatable angle range of the current pointer based on the coordinate vector;
[0039] A generating module, configured to randomly generate a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer image, so as to obtain a second pointer image;
[0040] The superposition module is used to superimpose the second pointer image with the dial image to obtain a training image.
[0041] A third aspect of the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
[0042] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0043] Beneficial effects:
[0044] This application can generate a large number of training images with different pointer positions by separating a single original image into two parts: the pointer and the dial, and using image processing technology to randomly rotate the pointer. This method not only greatly enriches the content of the training data set and improves the generalization ability of the deep learning model, but also significantly reduces the human and material resources required to collect actual images. In addition, the solution is easy to implement and has a high degree of automation, which can quickly generate high-quality and diversified training samples, thereby improving the accuracy and robustness of the pointer instrument recognition system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A schematic diagram of a flow chart of a method for synthesizing a pointer instrument training picture according to an embodiment of the present application;
[0046] Figure 2 It is a schematic block diagram of the structure of a synthesis device for pointer-type instrument training pictures according to an embodiment of the present application;
[0047] Figure 3 A schematic block diagram of the structure of a computer device according to an embodiment of the present application;
[0048] Figure 4 This is a schematic diagram of key points and angle division of a pointer-type instrument according to an embodiment of the present application;
[0049] Figure 5 A schematic diagram of an original drawing of a pointer-type instrument according to an embodiment of the present application;
[0050] Figure 6 A schematic diagram of a pointer image according to an embodiment of the present application;
[0051] Figure 7 This is a schematic diagram of a dial image of an embodiment of the present application;
[0052] Figure 8 A schematic diagram of a second pointer image according to an embodiment of the present application;
[0053] Fig. 9 This is a schematic diagram of a training image obtained by superimposing the second pointer image and the dial image according to an embodiment of the present application.
[0054] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "a", "an", "above", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of features, integers, steps, operations, elements, modules, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, modules, components, and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any module and all combinations of one or more associated listed items.
[0057] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined as herein.
[0058] Reference Figure 1 The embodiment of the present invention provides a method for synthesizing a pointer instrument training picture, characterized in that the method comprises:
[0059] S1, separating the pointer of the original image of the pointer instrument to obtain a pointer image and a dial image;
[0060] S2, defining key points of the original image, wherein the key points include the center point of the dial, the end point of the pointer, the minimum scale point and the maximum scale point;
[0061] S3, determining the coordinate vectors of the remaining key points starting from the center point of the dial;
[0062] S4, calculating the rotatable angle range of the current pointer based on the coordinate vector;
[0063] S5, randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain a second pointer picture;
[0064] S6. Superimpose the second pointer image and the dial image to obtain a training image.
[0065] Reference Figure 5-Figure 7 In step S1, first, the pointer area and the dial area are separated from an original image of a pointer instrument. By using image processing software or algorithms (such as contour detection and edge detection in OpenCV), the pointer and the dial can be accurately segmented to ensure that each part retains the detailed features of the original image. The pointer area is saved as a separate pointer image with a transparent background; and the dial area is saved as a separate dial image. The size and resolution of the pointer image and the dial image are the same as the original image. Figure 1 This step is the basis of the entire synthesis process. It allows the pointer to be operated independently in subsequent steps without affecting the dial part, ensuring the authenticity and accuracy of the synthesized image.
[0066] In steps S2-S3, the center point of the dial, the end point of the pointer, the minimum scale point, and the maximum scale point are marked on the original image, wherein reference Figure 4 As shown in the figure, let the center point of the dial be O, the end point of the pointer be P, the minimum scale point be S, and the maximum scale point be E; and obtain the coordinate values of these key points. Then calculate the vector relationship between the points based on these coordinate values. Specifically, set the center point of the dial as the origin (x0, y0), and then calculate the distance and direction of the other three key points, the end point of the pointer, the minimum scale point, and the maximum scale point to the center point of the dial, and obtain their corresponding coordinate vectors OP, OS, and OE. By converting the problem into a vector operation in a two-dimensional plane, the calculation process is simplified, and the position of the pointer and its angular relationship relative to the range can be more intuitively represented. This step is a bridge between the position of the key points and the angle calculation, ensuring the accuracy of the reading recognition. Defining key points and calculating the vectors between them helps to determine the maximum range in which the pointer can rotate, which is the key to generating diverse training pictures. Using mathematical formulas to directly extract the required information from the image reduces the need for human intervention and improves the degree of automation.
[0067] In step S4, the coordinate vector obtained in the previous step is used to perform angle calculation. First, determine the rotation angle A between the vector OS and the vector OP, and the rotation angle B between the vector OS and the vector OE. These two angles can be obtained by the inner product and outer product between the vectors. Once A and B are obtained, the range in which the pointer in the original image can be rotated to both sides at the current position can be determined, and the rationality and accuracy of the instrument image finally generated can be determined. The specific rotation range is determined based on the rotation direction. If the clockwise rotation is the positive direction, the left side of the current pointer is a negative rotation when it is counterclockwise rotated, and the corresponding rotation angle is a negative number. The same is true when the counterclockwise rotation is the positive direction. This method based on geometric principles is not only simple and efficient in calculation, but also avoids the error accumulation problem caused by directly processing complex image data, further improving the recognition accuracy. At the same time, because mathematical formulas are used instead of complex image processing algorithms, the system is less sensitive to environmental changes and has better stability and generalization capabilities.
[0068] In step S5, the center point of the dial is used as the rotation center, an angle value c is randomly selected within the known rotation angle range, and then the pointer image is rotated c degrees around the center to generate a new pointer image, that is, Figure 8 The second pointer image is shown. By randomly selecting different rotation angles, each new image generated is different, which increases the diversity of the image collection. The random number generator is used to select the rotation angle, which not only maintains the uncertainty of the generation process, but also ensures that all possible situations are covered to a certain extent.
[0069] In step S6, the rotated pointer image is superimposed on the previously separated dial image. Since the pointer image has a transparent background, the synthesis can be completed by simply traversing the pixels and copying the non-transparent part to the corresponding position, and finally forming a complete instrument image including the new pointer position, as shown in Fig. 9 The training images shown in the figure are transformed from a single original image to multiple instrument images in different states. High-quality image synthesis can be achieved through simple pixel operations, which is efficient and natural.
[0070] Through steps S1-S6, a single original image is separated into two parts, the pointer and the dial, and the pointer is randomly rotated using image processing technology, so that a large number of training images with different pointer positions can be generated. This method not only greatly enriches the content of the training data set and improves the generalization ability of the deep learning model, but also significantly reduces the human and material resources required to collect actual images. In addition, the scheme is easy to implement and has a high degree of automation, which can quickly generate high-quality and diversified training samples, thereby improving the accuracy and robustness of the pointer instrument recognition system.
[0071] In one embodiment, the step of separating the pointer of the original image of the pointer-type instrument to obtain the pointer image and the dial image includes:
[0072] S10, preprocessing the original image;
[0073] S11, obtaining a pointer area;
[0074] S12, using a mask to extract the pointer area from the original image to generate a pointer image, wherein the area outside the pointer area in the pointer image is a transparent background;
[0075] S13. Use the reverse mask to extract the dial area from the original image and generate a dial image.
[0076] In this embodiment, first, the original image is preprocessed, which may include grayscale, noise reduction and other operations to enhance the effect of subsequent edge detection. Then, the pointer area is identified and obtained. The identification of the pointer area may include using an edge detection algorithm (such as Canny edge detection) to identify the pointer area, and using the contrast difference between the pointer and the background to clearly outline the pointer outline. It may also include obtaining the outline of the pointer that is identified and segmented using manual annotation to form the pointer area. A mask is created based on the identified pointer outline, which retains the pointer part and sets other areas to be transparent; the mask is used to extract the pointer part from the original image to form a new pointer image, in which the part other than the pointer is a transparent background. At the same time, a reverse mask is created, that is, only the non-pointer part is retained, and the position of the pointer is set to be transparent; the reverse mask is used to extract the dial area other than the pointer from the original image to generate a dial image.
[0077] This method can generate a large number of synthetic images with only one original image, greatly reducing the workload of actually shooting and collecting training images. By randomly rotating the pointer and superimposing it on the dial, a variety of images with different pointer positions can be generated, which increases the variability and diversity of the training set and helps avoid overfitting problems in the deep learning model training process. The entire process is highly automated, which reduces labor costs while speeding up development and improving efficiency. In addition, the synthetic images cover different pointer positions, enhancing the generalization ability of the trained model for various pointer readings and improving its practical application value.
[0078] In one embodiment, the step of determining the coordinate vectors of the remaining key points starting from the center point of the dial includes:
[0079] S20, identifying the coordinate values of the center point of the dial, the end point of the pointer, the minimum scale point, and the maximum scale point;
[0080] S21, taking the center point of the dial as the starting point, calculating the coordinate value of the starting point to the coordinate value of the pointer end point, the coordinate value of the minimum scale point, and the coordinate vector formed between the coordinate value of the minimum scale point.
[0081] In this embodiment, the process of determining the coordinate vectors of the remaining key points starting from the center point of the dial includes two main steps. First, by identifying the precise coordinate values of the center point of the dial (i.e., the center point of the dial), the end point of the pointer, the minimum scale point, and the maximum scale point, then, with the center point of the dial as the starting point, the coordinate vectors from this point to the end point of the pointer, the minimum scale point, and the maximum scale point are calculated respectively. By obtaining the specific coordinates of each key point, vector subtraction can be used to calculate the relative displacement between different points. For example, the coordinates of the center point of the dial are (x0, y0), the coordinates of the end point of the pointer are (x1, y1), the coordinates of the minimum scale point are (x2, y2), and the coordinates of the maximum scale point are (x3, y3). The coordinates of the end point of the pointer are (x1, y1), then the coordinates from the center point of the dial to the end point of the pointer, that is, the vector 0P is (x1 - x0, y1-y0); the coordinate vector from the center of the dial to the minimum scale point, that is, vector 0S is (x2-x0, y2-y0); the coordinate vector corresponding to the maximum scale point, that is, vector 0E is (x3-x0, y3-y0). For the specific correspondence between the vectors, refer to Figure 4 As shown. By accurately identifying and locating the key points on the dial, the accuracy of the basic data for all subsequent calculations is ensured. Based on these coordinate vectors, the angular range within which the pointer can rotate on the dial can be determined. This ensures that when the pointer is randomly rotated in subsequent steps, it is always within a reasonable range and will not exceed the maximum or minimum scale of the actual instrument, thereby maintaining the authenticity and effectiveness of the synthetic image.
[0082] In one embodiment, the step of calculating the rotatable angle range of the current pointer based on the coordinate vector includes:
[0083] S30, calculating the angle A between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the minimum scale point, and the angle B between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the maximum scale point by using the vector angle formula;
[0084] S31. Taking the coordinate vector of the current pointer end point as the rotation starting point, based on the preset positive direction, determine the rotatable angle range of the current pointer; wherein, if the clockwise direction is specified as the positive direction, the rotatable angle range of the pointer is between [-A, B]; if the counterclockwise direction is specified as the positive direction, the rotatable angle range of the pointer is between [A, -B].
[0085] In this embodiment, first, the angle A between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the minimum scale point, and the angle B between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the maximum scale point are calculated using the vector angle formula. These angles reflect the maximum limit of the pointer's rotation on the dial. Specifically, if the center point of the dial is O, the end point of the pointer is P, the minimum scale point is S, and the maximum scale point is E, then the vectors OP, OS, and OE represent the positions of the end point of the pointer, the minimum scale point, and the maximum scale point relative to the center point of the dial, respectively. By calculating the angle A between the vectors OP and OS, and the angle B between the vectors OP and OE, the angles that the pointer can rotate from the current position to the minimum scale point and the maximum scale point, respectively, can be determined. By accurately calculating the angles A and B, the effective rotation range of the pointer on the dial can be clearly defined, ensuring that the pointer position in the generated composite picture is always within a reasonable physical range, thereby enhancing the authenticity and effectiveness of the composite picture.
[0086] Next, the rotatable angle range of the pointer is determined according to the preset positive direction. If the clockwise direction is specified as the positive direction, the rotatable angle range of the pointer will be between [-A, B], where -A represents the maximum angle of the pointer rotating counterclockwise to the minimum scale point, and B represents the maximum angle of the pointer rotating clockwise to the maximum scale point. On the contrary, if the counterclockwise direction is specified as the positive direction, the rotatable angle range of the pointer will be between [A, -B], where A represents the maximum angle of the pointer rotating clockwise to the minimum scale point, and -B represents the maximum angle of the pointer rotating counterclockwise to the maximum scale point.
[0087] For example, if A is 45 degrees and B is 135 degrees, if the clockwise direction is defined as the positive direction, the pointer can rotate in the range of [-45 degrees, 135 degrees]; if the counterclockwise direction is defined as the positive direction, the pointer can rotate in the range of [45 degrees, -135 degrees]. By limiting the rotation angle range, it is possible to prevent the generation of images that do not conform to the actual law of instrument reading changes, thereby reducing invalid or unreasonable training data and further improving the effectiveness of model training.
[0088] In one embodiment, before the step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain the second pointer picture, the step includes:
[0089] S40, obtaining the coordinate value of the center point of the dial in the original image;
[0090] S41, finding the corresponding coordinate position on the pointer image based on the coordinate value of the center point of the dial;
[0091] S42. Determine the rotation center based on the coordinate position.
[0092] In this embodiment, the rotation center on the pointer image is determined based on the known coordinate value of the center point of the dial in the original image, wherein the coordinate value of the center point of the dial includes a coordinate value based on manual annotation or obtained by using edge detection, center detection algorithm or template matching. Once the coordinates of the center point of the dial in the original image are obtained, it is necessary to map this information to the separated pointer image. Since the original image and the pointer image are of the same size, the coordinates of the center point of the dial in the original image can be directly used as the rotation center of the pointer image. Since the pointer image is cropped from the original image and the resolution and size are consistent, the same coordinate system can be directly used, that is, (x0, y0) is directly used as the coordinates of the center point of the dial on the pointer image. This not only simplifies the operation process, but also ensures that no matter how the pointer rotates, it always rotates around the same fixed point, enhancing the realism and consistency of the synthesized image. That is, (x0, y0) is used as the center point of the pointer rotation on the pointer image. This means that all rotation operations on the pointer will be performed around this point, thereby ensuring that the spatial relationship between the pointer and the dial will not be offset or deformed during the synthesis process.
[0093] In one embodiment, the step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer image to obtain the second pointer image includes:
[0094] S50, identifying a boundary value of the rotatable angle range;
[0095] S51, randomly generating a corresponding angle value within the numerical range of the boundary value;
[0096] S52, determining a rotation angle based on the angle value;
[0097] S53. Adjust the rotation angle of the current pointer around the rotation center based on the pointer image to generate a second pointer image.
[0098] In this embodiment, after determining the rotatable angle range of the center point of the dial and the pointer, it is first necessary to clarify the specific boundary values of the range. For example, if the clockwise direction is specified as the positive direction, and the angle A between the end point of the pointer and the minimum scale point and the angle B between the end point of the pointer and the maximum scale point are obtained through the previous calculation, then the rotatable angle range is [-A, B][-A, B]. Assuming A = 45° and B = 135°, the pointer can rotate counterclockwise up to 45 degrees and clockwise up to 135 degrees. Next, a specific rotation angle value is randomly generated within the determined rotatable angle range. That is, this angle value will be randomly generated between [-45°, 135°]. This can be achieved through the random number generation function in the programming language. For example, in Python, "random.uniform(-45,135)" can be used to generate a random floating point number between -45 degrees and 135 degrees. The generated random angle value is the specific angle that the pointer will rotate. This step ensures that the pointer position in each generated synthetic image is different, thereby increasing the variability and richness of the training data set. Furthermore, the rotation function in the image processing library (such as OpenCV) can be used to rotate the pointer image around the previously determined rotation center point (i.e., the center point of the dial) according to the rotation angle value determined in the previous step. The rotated pointer image is called the "second pointer image", which has a new pointer position but still maintains the same resolution and background transparency as the original image.
[0099] This embodiment randomly generates rotation angles within the rotatable angle range, and the pointer position in each generated synthetic picture is different, thereby greatly increasing the diversity and variability of the training data set. Since the generated pictures cover the situations of various possible positions of the pointer, this reduces the risk of overfitting of the model due to over-reliance on specific patterns. Diversified training data enables the model to better adapt to various situations in practical applications. Only one original picture is needed to generate a large number of training pictures that meet the requirements, which significantly reduces the workload of field shooting and collecting training pictures, and reduces manpower and material costs. Only one original picture is needed to generate a large number of training pictures that meet the requirements, which significantly reduces the workload of field shooting and collecting training pictures, and reduces manpower and material costs.
[0100] In one embodiment, the step of superimposing the second pointer image with the dial image to obtain a training image includes:
[0101] S60, traversing the color channels of the second pointer picture;
[0102] S61. Copy the pixel values of the non-transparent part in the second pointer image to the corresponding positions of the corresponding color channels in the dial image to obtain the training image.
[0103] In this embodiment, usually, a digital image is composed of multiple color channels, for example, an RGB (red, green, blue) image contains three independent color channels. In this step, the program will process each color channel in the second pointer image in turn. This channel-by-channel processing method ensures that the synthesized image can accurately reflect the color information of the original image. After determining the color channel to be processed, the pixel values of the non-transparent area in the second pointer image are identified and extracted. This step relies on the transparency attribute of each pixel point, which is usually represented by the Alpha channel. For those pixels that are not completely transparent (i.e., the Alpha value is greater than zero), they represent the actual pointer content. Then, the pixel values of these non-transparent areas are accurately copied to the color channel at the same position on the dial image. This process requires that the two images are consistent in size and alignment to ensure that the pointer is correctly placed at the expected position on the dial. Furthermore, the exact offset of the rotated pointer relative to the center of the dial can be calculated first, so as to ensure that the pointer is perfectly integrated with the dial background.
[0104] By processing each color channel separately and only copying the pixel values of non-transparent areas, this method can combine the hands with the dial background very accurately, ensuring that the final composite image looks natural and has no obvious stitching marks. The training images generated by the above technical means have a high sense of reality and can provide more abundant and diverse training samples for the deep learning model, which helps to improve the recognition accuracy and generalization ability of the model. The generated diverse training images cover a wide range of pointer positions, helping the trained model to have better adaptability and anti-interference ability, and can perform stably even in the face of different lighting conditions or changes in viewing angles.
[0105] Reference Figure 2 , is a needle meter reading automatic recognition device in one embodiment of the present application, the device comprises:
[0106] The separation module 100 is used to separate the pointer of the original image of the pointer instrument to obtain the pointer image and the dial image;
[0107] A definition module 200, for defining key points of the original image, wherein the key points include a dial center point, a pointer end point, a minimum scale point, and a maximum scale point;
[0108] A determination module 300 is used to determine the coordinate vectors of the remaining key points starting from the center point of the dial;
[0109] A calculation module 400, configured to calculate a rotatable angle range of the current pointer based on the coordinate vector;
[0110] A generating module 500, configured to randomly generate a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer image, thereby obtaining a second pointer image;
[0111] The superposition module 600 is used to superimpose the second pointer image with the dial image to obtain a training image.
[0112] In one embodiment, the separation module 100 includes:
[0113] A preprocessing unit, used for preprocessing the original image;
[0114] A region recognition unit obtains a pointer region;
[0115] A first extraction unit, configured to extract a pointer region from an original image using a mask to generate a pointer image, wherein an area outside the pointer region in the pointer image is a transparent background;
[0116] The second extraction unit is used to extract the dial area from the original image using a reverse mask to generate a dial image.
[0117] In one embodiment, the determination module 300 includes:
[0118] A first coordinate value recognition unit, used to recognize the coordinate values of the center point of the dial, the end point of the pointer, the minimum scale point, and the maximum scale point;
[0119] The vector calculation unit is used to calculate the coordinate value of the starting point to the coordinate value of the pointer end point, the coordinate value of the minimum scale point and the coordinate vector formed between the coordinate value of the minimum scale point.
[0120] In one embodiment, the calculation module 400 includes:
[0121] An angle calculation unit, used to calculate the angle A between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the minimum scale point, and the angle B between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the maximum scale point through a vector angle formula;
[0122] The range determination unit is used to determine the rotatable angle range of the current pointer based on a preset positive direction, taking the coordinate vector of the current pointer end point as the rotation starting point; wherein, if the clockwise direction is specified as the positive direction, the rotatable angle range of the pointer is between [-A, B]; if the counterclockwise direction is specified as the positive direction, the rotatable angle range of the pointer is between [A, -B].
[0123] In one embodiment, the above device further includes a rotation center identification module, including:
[0124] A second coordinate value recognition unit, used to obtain the coordinate value of the center point of the dial in the original image;
[0125] A position calculation unit, used for finding a corresponding coordinate position on the pointer image based on the coordinate value of the center point of the dial;
[0126] A center determination unit is used to determine the rotation center based on the coordinate position.
[0127] In one embodiment, the generation module 500 includes:
[0128] A boundary identification unit, used to identify the boundary value of the rotatable angle range;
[0129] A random generation unit, used to randomly generate a corresponding angle value within a numerical interval of the boundary value;
[0130] an angle determination unit, configured to determine a rotation angle based on the angle value;
[0131] The second image generating unit is used to adjust the rotation angle of the current pointer around the rotation center based on the pointer image to generate a second pointer image.
[0132] In one embodiment, the superposition module 600 includes:
[0133] A traversal unit, used for traversing the color channels of the second pointer picture;
[0134] The copying unit is used to copy the pixel values of the non-transparent part in the second pointer image to the corresponding position of the corresponding color channel in the dial image to obtain the training image.
[0135] Reference Figure 3 In an embodiment of the present application, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 3As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the usage data in the process of the synthesis method of the pointer instrument training picture. The network interface of the computer device is used to communicate with an external terminal through a network connection. Furthermore, the above-mentioned computer device can also be provided with an input device and a display screen. When the above-mentioned computer program is executed by a processor, a method for synthesizing a pointer instrument training picture is implemented, including the following steps: separating the pointer of the original picture of the pointer instrument picture to obtain a pointer picture and a dial picture; defining key points of the original picture, wherein the key points include the center point of the dial, the end point of the pointer, the minimum scale point and the maximum scale point; determining the coordinate vectors of the remaining key points starting from the center point of the dial; calculating the rotatable angle range of the current pointer based on the coordinate vector; randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain a second pointer picture; superimposing the second pointer picture with the dial picture to obtain a training picture.
[0136] Those skilled in the art will understand that Figure 3 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.
[0137] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, a method for synthesizing a pointer instrument training picture is implemented, including the following steps: separating the pointer of the original picture of the pointer instrument picture to obtain a pointer picture and a dial picture; defining key points of the original picture, wherein the key points include the center point of the dial, the end point of the pointer, the minimum scale point and the maximum scale point; determining the coordinate vectors of the remaining key points starting from the center point of the dial; calculating the rotatable angle range of the current pointer based on the coordinate vector; randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain a second pointer picture; superimposing the second pointer picture with the dial picture to obtain a training picture. It can be understood that the computer-readable storage medium in this embodiment can be a volatile readable storage medium or a non-volatile readable storage medium.
[0138] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SyTchl iTk) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0139] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.
[0140] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for synthesizing a pointer instrument training picture, characterized in that: The method comprises: Separate the pointer of the original image of the pointer instrument to obtain the pointer image and the dial image; Defining key points of the original image, wherein the key points include the center point of the dial, the end point of the pointer, the minimum scale point and the maximum scale point; Determine the coordinate vectors of the remaining key points starting from the center point of the dial; Calculate the rotatable angle range of the current pointer based on the coordinate vector; Based on the rotation center of the pointer, a rotation angle is randomly generated within the rotatable angle range to rotate the pointer in the pointer image to obtain a second pointer image; The second pointer image is superimposed on the dial image to obtain a training image.
2. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: The step of separating the pointer of the original image of the pointer-type instrument to obtain the pointer image and the dial image includes: Preprocessing the original image; Get the pointer area; A mask is used to extract the pointer area from the original image to generate a pointer image, wherein the area outside the pointer area in the pointer image is a transparent background; Use the reverse mask to extract the dial area from the original image and generate the dial image.
3. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: The step of determining the coordinate vectors of the remaining key points starting from the center point of the dial includes: Identify the coordinate values of the center point of the dial, the end point of the pointer, the minimum scale point, and the maximum scale point; Taking the center point of the dial as the starting point, the coordinate value of the starting point to the coordinate value of the pointer end point, the coordinate value of the minimum scale point and the coordinate vector formed between the coordinate value of the minimum scale point are calculated.
4. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: The step of calculating the rotatable angle range of the current pointer based on the coordinate vector comprises: Calculate the angle A between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the minimum scale point, and the angle B between the coordinate vector corresponding to the end point of the pointer and the coordinate vector corresponding to the maximum scale point by using the vector angle formula; Taking the coordinate vector of the current pointer end point as the rotation starting point, based on the preset positive direction, determine the current pointer's rotatable angle range; where, if the clockwise direction is specified as the positive direction, the pointer's rotatable angle range is between [-A, B]; if the counterclockwise direction is specified as the positive direction, the pointer's rotatable angle range is between [A, -B].
5. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: Before the step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain the second pointer picture, the step includes: Obtain the coordinate value of the center point of the dial in the original image; Find the corresponding coordinate position on the pointer image based on the coordinate value of the center point of the dial; The rotation center is determined based on the coordinate position.
6. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: The step of randomly generating a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer picture to obtain a second pointer picture includes: Identifying a boundary value of the rotatable angle range; Randomly generate a corresponding angle value within the numerical interval of the boundary value; determining a rotation angle based on the angle value; The rotation angle of the current pointer around the rotation center is adjusted based on the pointer image to generate a second pointer image.
7. The method for synthesizing pointer instrument training pictures according to claim 1, characterized in that: The step of superimposing the second pointer image with the dial image to obtain a training image includes: Traversing the color channels of the second pointer picture; The pixel values of the non-transparent part in the second pointer image are copied to the corresponding positions of the corresponding color channels in the dial image to obtain the training image.
8. A device for synthesizing pointer instrument training pictures, characterized in that: include: A separation module is used to separate the pointer of the original image of the pointer instrument to obtain the pointer image and the dial image; A definition module, used for defining key points of the original image, wherein the key points include a dial center point, a pointer end point, a minimum scale point, and a maximum scale point; A determination module, used to determine the coordinate vectors of the remaining key points starting from the center point of the dial; A calculation module, used for calculating the rotatable angle range of the current pointer based on the coordinate vector; A generating module, configured to randomly generate a rotation angle within the rotatable angle range based on the rotation center of the pointer to rotate the pointer in the pointer image, so as to obtain a second pointer image; The superposition module is used to superimpose the second pointer image with the dial image to obtain a training image.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
State recognition method, electronic equipment and computer readable storage medium
CN120726612A