Image data annotation method, device and electronic device
By providing an image data annotation method and device, the existing annotation software has been solved, and the problem of insufficient automatic annotation capability and difficulty in converting data set formats is realized, efficient and accurate annotation of image data, and the conversion of multiple data set formats is supported, which improves the execution efficiency of industrial vision detection tasks.
Patent Information
- Application Number
- CN202411658938.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-04-08
AI Technical Summary
In the existing deep learning visual detection tasks, mainstream network open source or free labeling software has problems such as insufficient automatic labeling capabilities, difficulty in converting data set formats, limited labeling format support, limited rotating rectangle labeling methods, and poor user experience, resulting in high labor and time costs, poor accuracy and consistency of labeling results.
A method and device for labeling image data is provided, by receiving the first input data and labeling method input by a user, identifying data and labeling according to the labeling method, and generating labeling data. The method includes an interactive unit, a generation unit and annotation unit, which can automatically identify and label image data, support rotating rectangular labels and horizontal rectangular labels, and can export the label data into a variety of data set formats.
It improves the efficiency and accuracy of image data annotation, reduces labor and time costs, enhances the execution efficiency of industrial vision detection tasks and the accuracy of target area recognition, and supports the conversion of multiple data set formats, improving the universality of data.
Smart Images

Figure CN119784893A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of deep learning visual detection, and in particular, to an image data labeling method, device, and electronic device. Background Art
[0002] In the current deep learning visual inspection tasks, especially in the field of industrial visual inspection, the application of deep learning has become quite popular. However, the progress of deep learning technology depends on the training of AI models, and model training is inseparable from data sets in various formats, most of which come from a large number of image annotation work. Unfortunately, the current mainstream open source or free annotation software on the Internet has many shortcomings, which seriously affect the execution efficiency of industrial visual inspection tasks based on deep learning. First, although these annotation software can realize image annotation, they often find it difficult to cope with the huge workload when facing massive images, and cannot realize automatic annotation of the software. This not only leads to a waste of manpower and time costs, but also may affect the accuracy and consistency of the annotation results. Secondly, the data after annotation is often not directly used for model training, and users are required to perform additional data set format adjustment and preprocessing. This process is not only cumbersome and time-consuming, but may also cause data loss or damage due to improper operation. Furthermore, existing annotation software generally lacks support for different annotation formats. For example, it is difficult for existing annotation software to realize automatic conversion between horizontal rectangle annotation and rotated rectangle annotation, which limits the applicability of annotation software in different application scenarios, forcing users to frequently switch annotation tools between different tasks, reducing work efficiency. In addition, there are difficulties in converting dataset formats. For example, the YOLO dataset and the COCO dataset cannot be directly converted to each other, which brings inconvenience to the cross-framework training of the model and increases the complexity of data processing. Finally, existing annotation tools perform poorly when processing complex images, and are prone to mislabeling and missing labels, which affects the training quality and performance of the model.
[0003] In summary, the current mainstream annotation software has many shortcomings when dealing with large-scale image annotation tasks, including insufficient automatic annotation capabilities, difficulty in data set format conversion, limited annotation format support, limited rotation rectangle annotation methods, and poor user experience. The above problems not only increase manpower and time costs, but also restrict the execution efficiency of industrial visual inspection tasks based on deep learning and the accuracy of target area recognition. Summary of the invention
[0004] In view of this, embodiments of the present invention provide an image data annotation method, device, and electronic device for reducing manpower and time costs, improving the execution efficiency of industrial visual inspection tasks, and improving the accuracy of target area recognition.
[0005] A first aspect provides a method for labeling image data, the method comprising: receiving first input data and a marking method input by a user; generating at least one identification data according to the first input data; The at least one identification data is annotated according to the annotation method to generate at least one annotated data.
[0006] A second aspect provides an image data annotation device, comprising: An interaction unit, used for receiving first input data and a marking method input by a user; A first generating unit, configured to generate at least one identification data according to the first input data; The labeling unit is used to label the at least one identification data according to the labeling method to generate at least one labeling data.
[0007] The third aspect provides an electronic device, comprising: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the electronic device, enable the device to perform the image data labeling method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0008] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the electronic device where the computer-readable storage medium is located is controlled to execute the image data annotation method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0009] In the technical solution of the embodiment of the present invention, the electronic device receives first input data and a marking method input by a user; generates at least one identification data according to the first input data; and marks the at least one identification data according to the marking method to generate at least one marking data. The electronic device marks the identified data according to the marking method selected by the user, and by using the improved marking method to mark the identification data, the marking efficiency and marking accuracy are improved, thereby further reducing the manpower and time costs, improving the execution efficiency of industrial visual inspection tasks, and improving the target area recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 A flowchart of a method for labeling image data provided by an embodiment of the present invention; Figure 2 A schematic diagram of a software interface provided by an embodiment of the present invention; Figure 3 A flowchart of a method for generating identification data provided by an embodiment of the present invention; Figure 4 A flowchart of a method for screening target data provided by an embodiment of the present invention; Figure 5 A flowchart of another method for generating identification data provided by an embodiment of the present invention; Figure 6 A flowchart of a method for correcting identification data provided by an embodiment of the present invention; Fig. 7A A flowchart of a method for generating annotation data provided by an embodiment of the present invention; Figure 7B A flowchart of another method for generating annotation data provided by an embodiment of the present invention; Figure 7C Schematic diagram of another method for generating annotation data provided in an embodiment of the present application Figure 8 A flowchart of another method for generating annotation data provided by an embodiment of the present invention; Fig. 9 A flowchart of a method for correcting diagonal coordinates provided by an embodiment of the present invention; Fig.10 A flowchart of a method for correcting labeled data provided by an embodiment of the present invention; Fig.11 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention; Fig.12 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention; Fig.13 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention; Fig.14 A flowchart of a method for generating newly added annotation data provided by an embodiment of the present invention; Fig.15A flowchart of another method for generating newly added annotation data provided by an embodiment of the present invention; Fig.16 A flowchart of another method for correcting diagonal coordinates provided by an embodiment of the present invention; Fig.17 A schematic diagram of the structure of an image data annotation device provided by an embodiment of the present invention; Fig.18 A schematic diagram of the structure of a first generation unit provided in an embodiment of the present invention; Fig.19 A schematic diagram of the structure of a screening module provided by an embodiment of the present invention; Fig. 20 A schematic diagram of the structure of another first generating unit provided in an embodiment of the present invention; Fig.21 A structural schematic diagram of a marking unit provided in an embodiment of the present invention; Fig. 22 A schematic diagram of the structure of another marking unit provided in an embodiment of the present invention; Fig.23 A structural schematic diagram of a correction unit provided by an embodiment of the present invention; Fig.24 A schematic diagram of the structure of a sixth generation module provided by an embodiment of the present invention; Fig.25 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0012] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0013] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0015] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0016] Figure 1 A flowchart of a method for labeling image data provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes: Step 102: The electronic device receives first input data and a marking method input by a user.
[0017] In the embodiment of the present invention, the first input data includes image selection data, model selection data, confidence threshold and recognition type. The marking method includes a horizontal rectangle marking method or a rotated rectangle marking method.
[0018] Figure 2 A schematic diagram of a software interface provided by an embodiment of the present invention, such as Figure 2As shown in the figure, the software interface is divided into the image area, image list area, text prompt area, tool area and menu area, among which the image area is the area for displaying images. The image area is divided into two layers, namely the inner layer and the surface layer. The inner layer is created using the QGraphicsScene class and is used to store the images to be annotated. The surface layer is created using the QGraphicsView class and is used to observe the current image. The image list area is the area for displaying the thumbnail list. The text prompt area is the area for displaying text in the status bar. The tool area includes the toolbar area, the annotation format area, the AI annotation mode area and the custom annotation area. Among them, the toolbar area includes the move window button, the save button, the spin box button, the previous button, the horizontal box button, the next button, the clear button and the refresh button. The annotation format area includes the import coco button, the import yolo button, the import dota button and the export button. The AI annotation area includes the model selection menu, the category selection menu, the AI recognition button, the horizontal to spin button and the confidence value setting. The custom annotation area includes the model selection menu and the category selection menu. The menu area includes the menu button, the import button and the setting button. The image selection data may include the name of the thumbnail of any thumbnail selected by the user in the thumbnail list; the model selection data may include the name of any AI model selected by the user in the model selection menu; the confidence threshold may include the confidence entered by the user or the confidence adjusted by the user; the recognition type may include the recognition type selected by the user in the category selection menu; the annotation method may include a rotated rectangle annotation method or a horizontal rectangle annotation method, wherein the rotated rectangle annotation method is a annotation method in which the user clicks the spin box button in the toolbar area, the horizontal rectangle annotation method is a annotation method in which the user clicks the spin box button in the horizontal box button area of the toolbar, the user clicks the spin box button in the toolbar area by clicking the spin box button with the mouse or the user clicks the spin box button with the keyboard shortcut, and the user clicks the horizontal box button in the toolbar area by clicking the horizontal box button with the mouse or the user clicks the horizontal box button with the keyboard shortcut.
[0019] Step 104: The electronic device generates at least one identification data according to the first input data.
[0020] In an embodiment of the present invention, the first input data includes image selection data, model selection data, a confidence threshold, and an identification type; the identification data may include a plurality of coordinate data, and each coordinate data includes an identification abscissa and an identification ordinate corresponding to the identification abscissa. When using the rotated rectangle annotation method, the coordinate data is annotation coordinates, and the identification data includes 4 annotation coordinates; when using the horizontal rectangle annotation method, the coordinate data is diagonal coordinates, and the identification data includes 2 diagonal coordinates. The generated identification data is related to the selected annotation method. Specifically, if the annotation method is the rotated rectangle annotation method, the electronic device will automatically identify 4 annotation coordinates; if the annotation method is the horizontal rectangle annotation method and the user inputs 4 coordinates, the electronic device will identify 2 diagonal coordinates from the 4 coordinates, and the other 2 coordinates are invalid coordinates.
[0021] Step 106: The electronic device annotates at least one piece of identification data according to the annotation method to generate at least one piece of annotation data.
[0022] In an embodiment of the present invention, the annotation data may include a horizontal rectangle instance or a rotated rectangle instance.
[0023] Specifically, the electronic device annotates two diagonal coordinates according to the horizontal rectangle annotation method to generate at least one horizontal rectangle instance, where the horizontal rectangle instance includes two annotated diagonal coordinates, the height of the rectangle, and the width of the rectangle. As an alternative solution, the electronic device may annotate two diagonal coordinates through the instantiation method of the QGraphicsRectItem class in PySide6 to generate at least one horizontal rectangle instance. For example, the two diagonal coordinates include a first annotated diagonal coordinate and a second annotated diagonal coordinate, where the first annotated diagonal coordinate A1 is (x1, y1), the second annotated diagonal coordinate A2 is (x2, y2), and x1 < x2, y1 < y2. Then the electronic device calculates the minimum value x_min of x1 and x2 and the maximum value x_max of x1 and x2, and calculates the minimum value y_min of y1 and y2 and the maximum value y_max of y1 and y2; the electronic device generates an updated first annotated diagonal coordinate (x_min, y_min) and an updated second annotated diagonal coordinate (y_max, y_max) according to x_min, x_max, y_min, and y_max; calculates the width w of the rectangle according to the formula w = x_max - x_min, and calculates the height h of the rectangle according to the formula h = y_max - y_min.
[0024] The electronic device annotates at least one piece of annotation coordinate according to the rotated rectangle annotation method to generate at least one rotated rectangle instance, and the rotated rectangle instance includes four annotation coordinates, where the annotation coordinates are the vertex coordinates of the rectangle.
[0025] As an option, the plan may also include: Step 108: The electronic device generates a data set according to the at least one annotation data and the image data.
[0026] As an optional solution, the electronic device stores the horizontal rectangle instance as a COCO (Common Objects in Context) dataset or a YOLO (You Only Look Once) dataset. For example, the electronic device and the two annotated diagonal coordinates in each annotated data are stored as a COCO dataset. For another example, the image data includes width and height, and the annotated data includes two annotated diagonal coordinates. The electronic device divides the horizontal coordinate of each annotated diagonal coordinate by the width to obtain a normalized value of the horizontal coordinate, and divides the vertical coordinate of each annotated diagonal coordinate by the height to obtain a normalized value of the vertical coordinate; the image data and the normalized values are stored as a YOLO dataset, wherein the normalized values include a normalized value of the horizontal coordinate and a normalized value of the vertical coordinate.
[0027] As another optional solution, the electronic device stores the rotated rectangle instance as a DOTA (Dataset for Object Detection in Aerial Images) dataset or a YOLO_OBB dataset. For example, if the annotation data includes four vertex coordinates, the electronic device stores the image data and the four vertex coordinates in each annotation data as a DOTA dataset. For another example, if the image data includes width and height, and the annotation data includes four vertex coordinates, the electronic device divides the horizontal coordinate of each vertex coordinate by the width to obtain a normalized horizontal coordinate value, and divides the vertical coordinate of each vertex coordinate by the height to obtain a normalized vertical coordinate value; the image data and the normalized values are stored as a YOLO dataset, wherein the normalized values include a normalized horizontal coordinate value and a normalized vertical coordinate value. In an embodiment of the present invention, each of the above-mentioned data sets may also include an image name, an image address, a target category, and the like.
[0028] As an alternative, Figure 3 A flowchart of a method for generating identification data provided by an embodiment of the present invention, such as Figure 3 As shown, the first input data includes image selection data, model selection data, confidence threshold and recognition type, and step 104 specifically includes: Step 202: The electronic device acquires image data according to the image selection data, wherein the image data includes an image.
[0029] In an embodiment of the present invention, the image selection data may include the thumbnail name of any thumbnail selected by the user in the thumbnail list. Specifically, the electronic device reads out the image data of the thumbnail corresponding to the thumbnail name in the thumbnail list clicked by the user, wherein the image data may include the image, image width, and image height. The electronic device places the image origin of the image at the inner origin, wherein the image origin is the top left corner of the image. The inner origin is the origin of the coordinate system set in the image area, wherein in the coordinate system set in the image area, the horizontal direction is used as the horizontal axis, the vertical direction is used as the vertical axis, the horizontal right direction is set as the positive direction of the horizontal axis, and the vertical downward direction is set as the positive direction of the vertical axis.
[0030] As an optional solution, after step 202, the electronic device also includes: determining the horizontal drag distance and the vertical drag distance in response to the drag operation; and correcting the image origin according to the horizontal drag distance and the vertical drag distance to obtain a corrected image origin.
[0031] In an embodiment of the present invention, the dragging operation may include a user clicking on an image to select the image and dragging the image to change the position of the image. The horizontal axis dragging distance and the vertical axis dragging distance may include any positive number or any negative number. For example, the horizontal axis dragging distance is x_t, the vertical axis dragging distance is y_t, and the image origin coordinate B1 is (x3, y3), wherein the horizontal coordinate of the image origin is x3, and the vertical coordinate of the image origin is y3, and both x3 and y3 are equal to 0. The electronic device increases the horizontal coordinate of the image origin by the horizontal axis dragging distance and increases the vertical coordinate of the image origin by the vertical axis dragging distance to generate a corrected image origin, wherein the coordinates of the image origin are (x3+x_t, y3+y_t).
[0032] Step 204: The electronic device obtains the corresponding AI model according to the model selection data.
[0033] In an embodiment of the present invention, the model selection data may include the name of any AI model selected by the user in the model selection menu. Specifically, the electronic device reads the AI model corresponding to the selected AI model name according to the AI model name selected by the user in the model menu bar. For example, the AI model may include a convolutional neural network (CNN), a recurrent neural network (RNN), an object detection model, or an image generation model.
[0034] Step 206: The electronic device uses the AI model to recognize the image and generate at least one target data.
[0035] In an embodiment of the present invention, the target data includes the identified target, the confidence of the target, the type of the target, and at least two vertex coordinates of the identified target, wherein the confidence of the target may include the accuracy of the recognition result of the AI model for identifying the target, and the higher the confidence of the target, the more accurate the AI model is for the target recognition result; the type of the target may include teeth or bearings, etc., which is not limited in the embodiment of the present invention. For example, when the AI model is a convolutional neural network, the electronic device uses a convolutional neural network to identify the read image data and identify at least one target data in the image data.
[0036] For example, the AI model may include a new convolutional neural network obtained by training a data set of teeth marked with rotated rectangles and a convolutional neural network that performs a rotation recognition task. The electronic device then uses the above AI model to recognize the read image data and identify at least one target data in the image data, wherein each target data includes an identified target, and the type of each identified target is a tooth.
[0037] For another example, the AI model may include a new convolutional neural network obtained by training a data set of bearings marked with rotated rectangles and a convolutional neural network that performs a rotation recognition task. The electronic device then uses the above AI model to recognize the read image data and identify at least one target data in the image data, wherein each target data includes an identified target, and the type of each identified target is a bearing.
[0038] Step 208: The electronic device screens at least one target data according to the confidence threshold and the recognition type to generate at least one recognition data.
[0039] Figure 4 A flowchart of a method for screening target data provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the target data includes the target, the confidence of the target and the type of the target, and step 208 includes: Step 11: The electronic device takes the target whose confidence level is greater than the confidence level threshold as the first screening target.
[0040] The electronic device compares the confidence of each target with a confidence threshold, and takes the target whose confidence is greater than the confidence threshold as the first screening target.
[0041] Step 12: The electronic device uses the first screening target of the same type as the identification type as at least one identification data.
[0042] The electronic device matches the type of each first screening target with the identification type, and uses the first screening targets having the same type as the identification type as the identification data.
[0043] As another option, Figure 5 A flowchart of another method for generating identification data provided by an embodiment of the present invention, wherein the first input data includes image selection data, and the image data includes an image, such as Figure 5 As shown, step 104 specifically includes: Step 302: The electronic device acquires image data according to the image selection data.
[0044] In an embodiment of the present invention, the image selection data may include the thumbnail name of any thumbnail selected by the user in the thumbnail list. Specifically, the electronic device reads the image data of the selected thumbnail according to the thumbnail name selected in the thumbnail list clicked by the user, wherein the image data may include the image, image width, and image height. The electronic device places the upper left corner of the image at the inner origin, wherein the inner origin is the origin of the coordinate system set in the image area, and the coordinate system set in the image area uses the horizontal direction as the horizontal axis and the vertical direction as the vertical axis, and sets the horizontal right direction as the positive direction of the horizontal axis and the vertical downward direction as the positive direction of the vertical axis.
[0045] As an optional solution, after step 302, the electronic device also includes: determining the horizontal drag distance and the vertical drag distance in response to the drag operation; and correcting the image origin according to the horizontal drag distance and the vertical drag distance to obtain a corrected image origin.
[0046] In an embodiment of the present invention, the dragging operation may include a user clicking on an image to select the image and dragging the image to change the position of the image. The horizontal axis dragging distance and the vertical axis dragging distance may include any positive number or any negative number. For example, the horizontal axis dragging distance is x_t, the vertical axis dragging distance is y_t, and the image origin coordinate B1 is (x3, y3), wherein the horizontal coordinate of the image origin is x3, and the vertical coordinate of the image origin is y3, and both x3 and y3 are equal to 0. The electronic device increases the horizontal coordinate of the image origin by the horizontal axis dragging distance and increases the vertical coordinate of the image origin by the vertical axis dragging distance to generate a corrected image origin, wherein the coordinates of the image origin are (x3+x_t, y3+y_t).
[0047] Step 304: The electronic device receives at least one second input data input by the user according to the displayed image.
[0048] As an optional solution, the user clicks four coordinates in sequence on the image area according to the displayed image, and uses the four coordinates as the second input data, wherein the second input data includes four annotated coordinates. As another optional solution, the user clicks any position on the image area according to the displayed image, and drags the pointer from the clicked position to frame the target area, and uses the coordinates of the position clicked by the user as the first diagonal coordinates, and uses the coordinates of the position where the pointer stops when the user completes framing the target area as the second diagonal coordinates, and uses the first diagonal coordinates and the second diagonal coordinates as the second input data, wherein the second input data includes two diagonal coordinates.
[0049] Step 306: The electronic device uses at least one second input data as at least one identification data.
[0050] Figure 6 A flowchart of a method for correcting identification data provided by an embodiment of the present invention, such as Figure 6 As shown, the image data includes the image origin abscissa and the image origin ordinate, and the identification data includes a plurality of identification abscissas and an identification ordinate corresponding to each identification abscissa; before step 106, it also includes: Step 402: The electronic device determines the difference between the horizontal coordinate of the image origin and the horizontal coordinate of the set inner layer origin as the horizontal axis offset distance.
[0051] For example, the image origin coordinate B1 is (x3, y3), and the inner layer origin coordinate O is set to (x0, y0), where the image origin coordinate B1 includes the image origin horizontal coordinate x3, and the inner layer origin coordinate O includes the inner layer origin horizontal coordinate x0, x3 and x0 can be any numbers, and the embodiment of the present invention does not limit this. The electronic device calculates the image origin horizontal coordinate and the inner layer origin horizontal coordinate according to the formula: Δx_1=x3-x0, and generates a horizontal axis offset distance, where Δx_1 is the horizontal axis offset distance, x3 is the image origin horizontal coordinate, and x0 is the inner layer origin horizontal coordinate.
[0052] Step 404: The electronic device determines the difference between the ordinate of the image origin and the ordinate of the set inner layer origin as the ordinate offset distance.
[0053] For example, the coordinates of the image origin are B1 (x3, y3), and the coordinates of the inner origin are set to O (x0, y0), where the image origin coordinates B1 include the image origin ordinate y3, and the inner origin coordinates O include the inner origin ordinate y0, y3 and y0 can be any numbers, and the embodiment of the present invention does not limit this. The electronic device calculates the image origin ordinate and the inner origin ordinate according to the formula: Δy_1=y3-y0, and generates a longitudinal axis offset distance, where Δy_1 is the longitudinal axis offset distance, y3 is the image origin ordinate, and y0 is the inner origin ordinate.
[0054] Step 406: The electronic device adds each identified horizontal coordinate to the horizontal axis offset distance to generate a plurality of offset horizontal coordinates.
[0055] For example, the identified coordinate C1 is (x4, y4), where the identified coordinate C1 includes the identified horizontal coordinate x4. The electronic device calculates the identified horizontal coordinate and the horizontal axis offset distance according to the formula: x5=x4+Δx_1 to generate the offset horizontal coordinate, where x5 is the offset horizontal coordinate, x4 is the identified horizontal coordinate, and Δx_1 is the axis offset distance.
[0056] Step 408: The electronic device adds each identified vertical coordinate to the vertical axis offset distance to generate a plurality of offset vertical coordinates.
[0057] For example, the identification coordinate C1 is (x4, y4), where the identification coordinate C1 includes the identification ordinate y4. The electronic device calculates the identification ordinate and the ordinate offset distance according to the formula: y5=y4+Δy_1 to generate the offset ordinate, where y5 is the offset ordinate, y4 is the identification ordinate, and Δy_1 is the ordinate offset distance.
[0058] Step 410: The electronic device generates a plurality of corrected identification data according to a plurality of offset horizontal coordinates and a plurality of offset vertical coordinates.
[0059] In the embodiment of the present invention, each corrected identification data includes an offset horizontal coordinate and an offset vertical coordinate corresponding to the offset horizontal coordinate. For example, if the offset horizontal coordinate is x5 and the offset vertical coordinate is y5, the electronic device replaces the identification horizontal coordinate with the offset horizontal coordinate x5 and replaces the identification vertical coordinate with the offset vertical coordinate y5 to generate corrected identification data C2, wherein the coordinates of the identification data C2 are (x5, y5).
[0060] As an alternative, Fig. 7A A flowchart of a method for generating annotation data provided by an embodiment of the present invention, such as Fig. 7A As shown, the marking method is a rotated rectangular marking method, and the recognition data includes four marking coordinates. Step 106 specifically includes: Step 21: The electronic device calculates the four marked coordinates according to the bounding rectangle algorithm to generate a minimum bounding rectangle.
[0061] The bounding rectangle algorithm may include a rotating calipers algorithm, a Graham scan algorithm, or an OpenCV algorithm. The electronic device uses the cv2.minAreaRect() function in the OpenCV algorithm to calculate the four marked coordinates.
[0062] Step 22: The electronic device calculates the minimum bounding rectangle according to the image vertex algorithm to generate the coordinates of the four vertices of the minimum bounding rectangle.
[0063] The image vertex algorithm may include a rotating bounding box algorithm, a convex hull algorithm, or an OpenCV algorithm. The electronic device uses the cv2.boxPoints() function in the OpenCV algorithm to calculate the minimum enclosing rectangle.
[0064] Step 23: The electronic device generates annotation data according to the coordinates of the four vertices of the minimum circumscribed rectangle.
[0065] The electronic device uses the path method of the QGraphicsPathItem class in PySide6 to sequentially connect the four vertex coordinates of the minimum circumscribed rectangle to generate annotation data, wherein the annotation data is a rotated rectangle instance, and the rotated rectangle instance includes four vertex coordinates.
[0066] As another optional solution, the marking method is a rotating rectangular marking method, and the identification data includes the marking coordinates of four marking points, and the marking coordinates of the four marking points include the marking coordinates of the first marking point, the marking coordinates of the second marking point, the marking coordinates of the third marking point, and the marking coordinates of the fourth marking point. Then step 106 may include: according to the marking coordinates of the first marking point and the marking coordinates of the second marking point, the straight line passing through the first marking point and the second marking point is used as the top edge straight line; according to the first marking point, the second marking point, the third marking point, and the fourth marking point, the first boundary and the second boundary are determined; according to the marking coordinates of the third marking point and the marking coordinates of the fourth marking point, the bottom edge straight line parallel to the top edge straight line is determined; the top edge straight line, the first boundary, the bottom edge straight line, and the second boundary are intersected in sequence to obtain four vertices, and the coordinates of the four vertices are obtained; and the marking data is generated according to the coordinates of the four vertices.
[0067] Figure 7B A flowchart of another method for generating annotation data provided by an embodiment of the present invention, such as Figure 7B As shown, step 106 specifically includes: Step 81: The electronic device uses a straight line passing through the first marked point and the second marked point as a top edge straight line according to the marked coordinates of the first marked point and the marked coordinates of the second marked point.
[0068] Figure 7C A schematic diagram of another method for generating annotation data provided in an embodiment of the present application, such as Figure 7CAs shown, the labeled coordinates of the first labeled point A are (xa, ya), the labeled coordinates of the second labeled point B are (xb, yb), the labeled coordinates of the third labeled point C are (xc, yc), and the labeled coordinates of the fourth labeled point D are (xd, yd).
[0069] For example, the electronic device uses the straight line passing through the first marked point A and the second marked point B as the top edge straight line according to the marked coordinates (xa, ya) of the first marked point A and the marked coordinates (xb, yb) of the second marked point B.
[0070] Step 82: The electronic device calculates a first slope according to the marked coordinates of the first marked point and the marked coordinates of the second marked point.
[0071] As an optional solution, if the electronic device determines that the abscissa xa of the first marked point A and the abscissa xb of the second marked point B are not equal and the ordinate ya of the first marked point A and the ordinate yb of the second marked point B are not equal, the electronic device calculates the first slope by the formula M=(yb-ya) / (xb-xa), where M is the first slope. The first slope is the slope of the top straight line.
[0072] As another optional scheme, if the electronic device determines that the horizontal coordinate xa of the first marked point A and the horizontal coordinate xb of the second marked point B are equal, indicating that the top straight line is vertical and parallel to the y-axis, the horizontal coordinate xa can be added with n, and the first slope can be calculated by the formula M= (yb-ya) / (xb-xa-n), where n is a positive integer, for example n=1, and M is the first slope.
[0073] As another optional scheme, if the electronic device determines that the vertical coordinate ya of the first marking point A and the vertical coordinate yb of the second marking point B are equal, indicating that the top straight line is horizontal and parallel to the x-axis, the horizontal coordinate ya can be added with n, and the first slope can be calculated by the formula M= (yb-ya-n) / (xb-xa), where n is a positive integer, for example n=1, and M is the first slope.
[0074] Step 83: The electronic device generates, according to the first slope, a first perpendicular line passing through the first marked point, a second perpendicular line passing through the second marked point, a third perpendicular line passing through the third marked point, and a fourth perpendicular line passing through the fourth marked point.
[0075] like Figure 7C As shown, the straight line passing through the first marked point A is the first perpendicular line, the straight line passing through the second marked point B is the second perpendicular line, the straight line passing through the third marked point C is the third perpendicular line, and the straight line passing through the fourth marked point D is the fourth perpendicular line.
[0076] The electronic device can calculate the second slope according to the formula K=-1 / M, where K is the second slope; then, the electronic device generates the first vertical line, the second vertical line, the third vertical line and the fourth vertical line according to the second slope K, where the second slope K is the slope of the first vertical line, the second vertical line, the third vertical line and the fourth vertical line.
[0077] Step 84, the electronic device obtains the first intersection coordinates, the second intersection coordinates, the third intersection coordinates and the fourth intersection coordinates, the first intersection coordinates are the coordinates of the intersection of the first perpendicular line and the coordinate axis, the second intersection coordinates are the coordinates of the intersection of the second perpendicular line and the coordinate axis, the third intersection coordinates are the coordinates of the intersection of the third perpendicular line and the coordinate axis, and the fourth intersection coordinates are the coordinates of the intersection of the fourth perpendicular line and the coordinate axis.
[0078] like Figure 7C As shown, the coordinates of four intersection points on the Y-axis are obtained by cutting four perpendicular lines along the Y-axis, and the coordinates of the four intersection points include a first intersection point coordinate, a second intersection point coordinate, a third intersection point coordinate and a fourth intersection point coordinate. The first intersection point coordinate is the coordinate of the intersection point of the first perpendicular line and the Y-axis, the second intersection point coordinate is the coordinate of the intersection point of the second perpendicular line and the Y-axis, the third intersection point coordinate is the coordinate of the intersection point of the third perpendicular line and the Y-axis, and the fourth intersection point coordinate is the coordinate of the intersection point of the fourth perpendicular line and the Y-axis.
[0079] Among them, the first intersection coordinates have a corresponding relationship with the first marked point A, the second intersection coordinates have a corresponding relationship with the second marked point B, the third intersection coordinates have a corresponding relationship with the third marked point C, and the fourth intersection coordinates have a corresponding relationship with the fourth marked point D.
[0080] Step 85: The electronic device determines the maximum intersection coordinates and the minimum intersection coordinates from the first intersection coordinates, the second intersection coordinates, the third intersection coordinates and the fourth intersection coordinates.
[0081] like Figure 7C As shown, for example, the maximum intersection coordinate is the fourth intersection coordinate, and the minimum intersection coordinate is the first intersection coordinate.
[0082] Step 86, the electronic device generates a fifth perpendicular line and a sixth perpendicular line perpendicular to the top edge straight line, the fifth perpendicular line is a straight line passing through the marked point corresponding to the minimum intersection coordinate, and the sixth perpendicular line is a straight line passing through the marked point corresponding to the maximum intersection coordinate.
[0083] like Figure 7C As shown, the marked point corresponding to the minimum intersection coordinate is the first marked point A, and the marked point corresponding to the maximum intersection coordinate is the fourth marked point D. Then the fifth perpendicular line is the perpendicular line passing through the first marked point A, and the sixth perpendicular line is the perpendicular line passing through the fourth marked point D. In this case, the first perpendicular line is the same as the fifth perpendicular line, and the fourth perpendicular line is the same as the sixth perpendicular line.
[0084] Step 87: The electronic device determines the fifth vertical line as the first boundary, and determines the sixth vertical line as the second boundary.
[0085] exist Figure 7C In the figure, the first boundary is the left boundary of the rotated rectangle, and the second boundary is the right boundary of the rotated rectangle, so that the left and right boundaries of the rotated rectangle are determined by the fifth vertical line and the sixth vertical line.
[0086] Step 88, the electronic device calculates the distance from the third marking point to the top edge straight line according to the marking coordinates of the third marking point and calculates the distance from the fourth marking point to the top edge straight line according to the marking coordinates of the fourth marking point, and determines the marking point with the larger distance between the third marking point and the fourth marking point as the maximum marking point.
[0087] like Figure 7C As shown, for example, the electronic device calculates the distance from the third marking point C to the top edge straight line and the distance from the fourth marking point D to the top edge straight line through the point-to-straight line distance formula. Since the distance from the fourth marking point D to the top edge straight line is larger, the fourth marking point D with a larger distance is determined as the maximum marking point.
[0088] Step 89: The electronic device generates a parallel line to the top edge straight line, and determines the parallel line as the bottom edge straight line, and the parallel line passes through the maximum marked point.
[0089] like Figure 7C As shown, the electronic device determines the parallel line passing through the fourth marked point D as the bottom line of the rotated rectangle. Step 90: The electronic device intersects the top line, the first boundary, the bottom line and the second boundary in sequence to obtain four vertices, and obtains the coordinates of the four vertices.
[0090] like Figure 7C The electronic device intersects the top straight line, the first boundary, the bottom straight line and the second boundary in sequence to form a rotated rectangle, and obtains the coordinates of the four vertices of the rotated rectangle, wherein the four vertices include the first marked point A, the vertex E, the fourth marked point D and the vertex F, and the coordinates of the four vertices include the coordinates of the first marked point A, the coordinates of the vertex E, the coordinates of the fourth marked point D and the coordinates of the vertex F.
[0091] Step 91: The electronic device generates annotation data according to the coordinates of the four vertices.
[0092] The annotation data is a rotated rectangle instance, which includes four vertex coordinates.
[0093] In the embodiment of the present application, the above method is used to generate a rotated rectangle, so that the generated rotated rectangle is consistent with the expected rectangle, so that the generated rotated rectangle is an area that meets the requirements.
[0094] As another option, Figure 8The flowchart of another method for generating labeled data provided by the embodiments of the present invention is as follows. As Figure 8 shown, the labeling method is the horizontal rectangle labeling method. The recognition data includes two labeled diagonal coordinates, and the image data includes an image. After step 106, the following steps are further included: Step 31: The electronic device determines whether both of the two labeled diagonal coordinates exceed the range of the image. If so, step 32 is executed; if not, the process ends.
[0095] The two labeled diagonal coordinates include a first labeled diagonal coordinate and a second labeled diagonal coordinate. Among them, the first labeled diagonal coordinate A1 is (x1, y1), and the second labeled diagonal coordinate A2 is (x2, y2), and x1 < x2, y1 < y2. Among them, the first labeled diagonal coordinate A1 includes a first labeled diagonal abscissa x1 and a first labeled diagonal ordinate y1; the second labeled diagonal coordinate A2 includes a second labeled diagonal abscissa x2 and a second labeled diagonal ordinate y2.
[0096] The image data includes an image, an image width, and an image height. Among them, the image width is W, and the image height is H. The image includes an image origin coordinate B1 as (x3, y3). Among them, the image origin coordinate B1 includes an image origin abscissa x3 and an image origin ordinate y3. Since the image is a standard rectangle, the electronic device can determine the coordinates of the remaining vertices B2, B3, and B4 in the image according to the image width W and the image height H. Among them, B2 and B1 have the same ordinate, B3 and B4 have the same abscissa, B4 and B2 have the same abscissa and B4 and B3 have the same ordinate. Then the electronic device can determine the coordinate of B2 as (x3 + W, y3), the coordinate of B3 as (x3, y3 - H), and the coordinate of B4 as (x3 + W, y3 - H) according to B1(x3, y3), W, and H. The range of the image includes an image horizontal axis range and an image vertical axis range. The image horizontal axis range is from x3 to x3 + W, and the image vertical axis range is from y3 - H to y3.
[0097] The electronic device determines whether x1 satisfies x3≤x1≤x3+W, determines whether y1 satisfies y3-H≤y1≤y3, determines whether x2 satisfies x3≤x2≤x3+W, and determines whether y2 satisfies y3-H≤y2≤y3. If the electronic device determines that x1 satisfies x3≤x1≤x3+W, determines that y1 satisfies y3-H≤y1≤y3, determines that x2 satisfies x3≤x2≤x3+W, and determines that y2 satisfies y3-H≤y2≤y3, it indicates that it is determined that both of the marked diagonal coordinates are within the range of the image, and the process ends; if the electronic device determines that one of the following multiple judgment results is established, it indicates that at least one diagonal coordinate is beyond the range of the image, and step 32 is executed, wherein the multiple judgment results may include x1<x3, x1>x3+W, y1>y3, y1<y3-H, x2<x3, x2>x3+W, y2>y3 and y2<y3-H.
[0098] Step 32: The electronic device corrects the annotated diagonal coordinates that are beyond the range of the image to generate corrected annotated diagonal coordinates.
[0099] Specifically, the electronic device needs to correct all the annotated diagonal coordinates that are beyond the range of the image. If the electronic device determines that the horizontal coordinate of the annotated diagonal is less than the horizontal coordinate x3 of the image origin, the horizontal coordinate of the annotated diagonal is replaced with the horizontal coordinate x3 of the image origin; if the electronic device determines that the horizontal coordinate of the annotated diagonal is greater than the sum of the horizontal coordinate x3 of the image origin and the image width W, the horizontal coordinate of the annotated diagonal is replaced with the sum of the horizontal coordinate x3 of the image origin and the image width W; if the electronic device determines that the vertical coordinate of the annotated diagonal is greater than the vertical coordinate of the image origin, the vertical coordinate of the annotated diagonal is replaced with the vertical coordinate y3 of the image origin; if the electronic device determines that the vertical coordinate of the annotated diagonal is less than the difference between the vertical coordinate y3 of the image origin and the image height H, the vertical coordinate of the annotated diagonal is replaced with the difference between the vertical coordinate y3 of the image origin and the image height H. In the above four cases, the electronic device will execute at least one of the horizontal coordinate correction method and the vertical coordinate correction method or any combination thereof.
[0100] For example, if the electronic device determines that x1<x3, the first labeled diagonal horizontal coordinate x1 is replaced by the horizontal coordinate x3 of the image origin, and the first labeled diagonal coordinate is (x3, y1); if it is determined that x1>x3+W, the first labeled diagonal horizontal coordinate x1 is replaced by the sum of the horizontal coordinate x3 of the image origin and the image width W, and the first labeled diagonal coordinate is (x3+W, y1); if it is determined that y1>y3, the first labeled diagonal vertical coordinate y1 is replaced by the vertical coordinate y3 of the image origin, and the first labeled diagonal coordinate is (x3, y3); if it is determined that y1<y3-H, the first labeled diagonal vertical coordinate y1 is replaced by the difference between the vertical coordinate y3 of the image origin and the image height H, and the first labeled diagonal coordinate is (x1, y3-H).
[0101] For example, if the electronic device determines that x2<x3, the second labeled diagonal horizontal coordinate x2 is replaced by the horizontal coordinate x3 of the image origin, and the second labeled diagonal coordinate is (x3, y2); if it is determined that x2>x3+W, the second labeled diagonal horizontal coordinate x2 is replaced by the sum of the horizontal coordinate x3 of the image origin and the image width W, and the second labeled diagonal coordinate is (x3+W, y2); if it is determined that y2>y3, the second labeled diagonal vertical coordinate y2 is replaced by the vertical coordinate y3 of the image origin, and the second labeled diagonal coordinate is (x3, y3); if it is determined that y2<y3-H, the second labeled diagonal vertical coordinate y2 is replaced by the difference between the vertical coordinate y3 of the image origin and the image height H, and the second labeled diagonal coordinate is (x2, y3-H).
[0102] Step 33: The electronic device marks the corrected marking diagonal coordinates according to the horizontal rectangle marking method to generate corrected marking data.
[0103] As an optional solution, the annotation data includes a horizontal rectangle instance. The electronic device can annotate the corrected annotation diagonal coordinates through the instantiation method of the QGraphicsRectItem class in PySide6 to generate a horizontal rectangle instance, where the horizontal rectangle instance includes the corrected annotation diagonal coordinates, the height of the rectangle, and the width of the rectangle.
[0104] Fig. 9 A flowchart of a method for correcting diagonal coordinates provided by an embodiment of the present invention is shown in FIG. Fig. 9 As shown, the annotation method is a horizontal rectangular annotation method, the image data includes the coordinates of the image origin, the two diagonal coordinates include a first diagonal coordinate and a second diagonal coordinate, wherein the first diagonal coordinate includes a first diagonal horizontal coordinate and a first diagonal vertical coordinate, and the second diagonal coordinate includes a second diagonal horizontal coordinate and a second diagonal vertical coordinate, and before step 106, it also includes: Step 41: The electronic device compares the first diagonal horizontal coordinate and the second diagonal horizontal coordinate to determine the maximum horizontal coordinate and the minimum horizontal coordinate.
[0105] For example, the abscissa of the first diagonal line is x1', and the abscissa of the second diagonal line is x2', then the maximum abscissa x2' and the minimum abscissa x1' are determined.
[0106] Step 42: The electronic device compares the first diagonal ordinate and the second diagonal ordinate to determine the maximum ordinate and the minimum ordinate.
[0107] For example, the first diagonal ordinate y1' and the second diagonal ordinate y2', then the maximum ordinate y1' and the minimum ordinate y2' are determined.
[0108] Step 43: The electronic device generates an updated first diagonal coordinate according to the minimum horizontal coordinate and the minimum vertical coordinate.
[0109] For example, the updated coordinates of the first diagonal line are (x1', y2').
[0110] Step 44: The electronic device generates an updated second diagonal coordinate according to the maximum horizontal coordinate and the maximum vertical coordinate.
[0111] For example, the updated coordinates of the second diagonal line are (x2', y1').
[0112] Step 45: The electronic device generates updated identification data according to the updated first diagonal coordinates and the updated second diagonal coordinates.
[0113] The updated recognition data includes the first diagonal coordinate (x1′, y2′) and the second diagonal coordinate (x2′, y1′).
[0114] Fig.10 A flowchart of a method for correcting labeled data provided by an embodiment of the present invention is as follows: Fig.10 As shown, after step 31 or step 106, the following steps are further included: Step 502: The electronic device receives a correction operation input by the user based on the displayed multiple annotation data.
[0115] In the embodiment of the present invention, the correction operation includes at least one of a selection operation, a move operation, a delete operation, and an add operation, or any combination thereof. The selection operation may include a user clicking on the annotated data in the software interface; the move operation may include a user selecting the annotated data and then dragging it; the delete operation may include a user selecting the annotated data and then deleting the selected data; the add operation may include a user clicking on four coordinates in sequence on the image area, or clicking on any position on the image area, and dragging the pointer from the clicked position to frame the target area.
[0116] Step 504: The electronic device corrects the annotation data according to the correction operation to generate corrected annotation data.
[0117] As an alternative, Fig.11 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention, such as Fig.11 As shown, the correction operation includes a selection operation and a move operation, and step 404 specifically includes: Step 51 : In response to a selection operation, the electronic device uses the annotation data selected by the user as selection data, wherein the selection data includes a plurality of selection horizontal coordinates and a selection vertical coordinate corresponding to each selection horizontal coordinate.
[0118] The electronic device uses the annotation data clicked by the user as selection data, wherein the selection data may be a horizontal rectangle instance or a rotated rectangle instance. The selection data includes at least two selection coordinates, each of which includes a selection horizontal coordinate and a selection vertical coordinate corresponding to the selection horizontal coordinate.
[0119] Step 52: The electronic device obtains a horizontal axis movement distance and a vertical axis movement distance in response to the movement operation.
[0120] The electronic device obtains the horizontal axis movement distance and the vertical axis movement distance of the user's mouse on the horizontal axis according to the user's movement operation.
[0121] Step 53: The electronic device adds each selected horizontal coordinate to the horizontal axis movement distance to generate a plurality of movement horizontal coordinates.
[0122] For example, the annotated data includes coordinates D1 (x6, y6), where x6 is the annotated horizontal coordinate. The electronic device calculates the annotated horizontal coordinate and the horizontal axis moving distance according to the formula: x7=x6+Δx_2 to generate a moving horizontal coordinate, where the moving horizontal coordinate is x7, the annotated horizontal coordinate is x6, and the horizontal axis moving distance is Δx_2.
[0123] Step 54: The electronic device adds each selected vertical coordinate to the vertical axis movement distance to generate a plurality of moving vertical coordinates.
[0124] For example, the annotated data includes coordinates D1 (x6, y6), where y6 is the annotated ordinate. The electronic device calculates the annotated ordinate and the ordinate moving distance according to the formula: y7=y6+Δy_2 to generate a moving ordinate, where the moving ordinate is y7, the annotated ordinate is y6, and the ordinate moving distance is Δy_2.
[0125] Step 55: The electronic device generates a plurality of corrected annotation data according to the plurality of movement horizontal coordinates and the plurality of movement vertical coordinates.
[0126] In an embodiment of the present invention, each corrected annotation data includes a moving horizontal coordinate and a moving vertical coordinate corresponding to the moving horizontal coordinate. The electronic device replaces the marked horizontal coordinate with the moving horizontal coordinate, and replaces the marked vertical coordinate with the moving vertical coordinate. For example, the annotation data includes coordinate D1 as (x6, y6), the moving horizontal coordinate is x7, and the moving vertical coordinate is y7, wherein the marked horizontal coordinate is x6 and the marked vertical coordinate is y6. The electronic device replaces x6 with x7 and replaces y6 with y7, and the coordinates included in the generated corrected annotation data are (x7, y7).
[0127] As another option, Fig.12 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention, such as Fig.12As shown, the modification operation includes a selection operation and a deletion operation, and step 404 specifically includes: Step 61: In response to a selection operation, the electronic device uses the annotation data selected by the user as selected data.
[0128] The electronic device regards the marked data clicked by the user as selected data.
[0129] Step 62: The electronic device deletes the selected data in response to the deletion operation.
[0130] The electronic device deletes the selected data in response to the user clicking the delete button on the keyboard.
[0131] Step 63: The electronic device uses the undeleted annotation data as the corrected annotation data.
[0132] As another option, Fig.13 A flowchart of another method for correcting labeled data provided by an embodiment of the present invention, such as Fig.13 As shown, the correction operation includes an addition operation, and step 404 specifically includes: Step 71: The electronic device obtains third input data input by the user in response to the adding operation.
[0133] As an optional solution, the user clicks on four coordinates in sequence on the image area according to the displayed image, and uses the four coordinates as the third input data, wherein the third input data includes four newly annotated coordinates, and the newly annotated coordinates are the coordinates clicked by the user. As another optional solution, the user clicks on any position on the image area according to the displayed image, and drags the pointer from the clicked position to frame the target area, and uses the coordinates of the position clicked by the user as the third diagonal coordinates, and uses the coordinates of the position where the pointer stops when the user completes framing the target area as the fourth diagonal coordinates, and uses the third diagonal coordinates and the fourth diagonal coordinates as the third input data, wherein the third input data includes two newly added diagonal coordinates, and the two newly added diagonal coordinates are the third diagonal coordinates and the fourth diagonal coordinates.
[0134] In the embodiment of the present invention, the above-mentioned various user click operations may include the user click operation using a mouse, the user click operation using a laptop touch pad, the user click operation using a finger on a touch screen, or the user click operation using a stylus on a touch screen, etc., and the embodiment of the present invention does not limit this. The above-mentioned various pointers may include a mouse pointer, a touch screen pointer, or a stylus pointer, etc.
[0135] Step 72: The electronic device annotates the third input data according to the annotation method to generate newly added annotated data.
[0136] In an embodiment of the present invention, the newly added annotation data may include a horizontal rectangle instance or a rotated rectangle instance. The electronic device annotates the two diagonal coordinates according to the horizontal rectangle annotation method to generate a horizontal rectangle instance, wherein the horizontal rectangle instance includes two diagonal coordinates, the height of the rectangle and the width of the rectangle. As an optional solution, the electronic device may annotate the third input data through the instantiation method of the QGraphicsRectItem class in PySide6 to generate a horizontal rectangle instance. The electronic device annotates the four newly added annotation coordinates according to the rotated rectangle annotation method to generate a rotated rectangle instance, wherein the rotated rectangle instance includes four annotation coordinates, wherein the annotation coordinates are the vertex coordinates of the rectangle.
[0137] Step 73: The electronic device uses the newly added annotation data and the annotation data as the revised annotation data.
[0138] In the embodiment of the present invention, the revised annotation data includes newly added annotation data and annotation data.
[0139] As an alternative, Fig.14 A flowchart of a method for generating newly added annotation data provided by an embodiment of the present invention is shown in FIG. Fig.14 As shown, the marking method is a rotated rectangular marking method, the third input data includes four newly added marking coordinates, and step 72 specifically includes: Step 721: The electronic device calculates the four newly added annotation coordinates according to the bounding rectangle algorithm to generate a newly added minimum bounding rectangle.
[0140] The bounding rectangle algorithm may include a rotating calipers algorithm, a Graham scan algorithm or an OpenCV algorithm. In the embodiment of the present invention, the cv2.minAreaRect() function in the OpenCV algorithm is used to calculate the four newly added annotation coordinates.
[0141] Step 722: The electronic device calculates the newly added minimum bounding rectangle according to the image vertex algorithm to generate the coordinates of the four vertices of the newly added minimum bounding rectangle.
[0142] The image vertex algorithm may include a rotating bounding box algorithm, a convex hull algorithm or an OpenCV algorithm. In the embodiment of the present invention, the cv2.boxPoints() function in the OpenCV algorithm is used to calculate the newly added minimum enclosing rectangle.
[0143] Step 723: The electronic device generates new annotation data according to the coordinates of the four vertices of the new minimum circumscribed rectangle.
[0144] The electronic device uses the path method of the QGraphicsPathItem class in PySide6 to connect the four vertex coordinates of the newly added minimum enclosing rectangle in sequence to generate newly added annotation data, wherein the newly added annotation data is a rotated rectangle instance, and the rotated rectangle instance includes the four vertex coordinates of the newly added minimum enclosing rectangle.
[0145] As another option, Fig.15 A flowchart of another method for generating newly added annotation data provided by an embodiment of the present invention, such as Fig.15 As shown, the marking method is a horizontal rectangular marking method, the third input data includes two newly added diagonal coordinates, the image data includes an image, and after step 72, the following is further included: Step 724: The electronic device determines whether the coordinates of the two newly added diagonal lines are within the range of the image. If so, step 725 is executed; if not, the process ends.
[0146] Step 725: The electronic device corrects the newly added diagonal coordinates that exceed the range of the image to generate corrected newly added diagonal coordinates.
[0147] Step 726: The electronic device marks the corrected newly added diagonal coordinates according to the horizontal rectangle marking method to generate modified newly added diagonal coordinates.
[0148] In the embodiment of the present invention, the description of steps 724 to 726 can refer to steps 31 to 33, which will not be repeated here.
[0149] In an embodiment of the present invention, the two newly added diagonal coordinates include a first newly added diagonal coordinate and a second newly added diagonal coordinate, the first newly added diagonal coordinate includes a first newly added diagonal horizontal coordinate and a first newly added diagonal vertical coordinate, and the second newly added diagonal coordinate includes a second newly added diagonal horizontal coordinate and a second newly added diagonal vertical coordinate. Fig.16 A flowchart of another method for correcting diagonal coordinates provided by an embodiment of the present invention, such as Fig.16 As shown, before step 72, the following steps are also included: Step 727: The electronic device compares the first newly added diagonal horizontal coordinate with the second newly added diagonal horizontal coordinate to determine the maximum horizontal coordinate and the minimum horizontal coordinate.
[0150] Step 728: The electronic device compares the first newly added diagonal ordinate and the second newly added diagonal ordinate to determine the maximum ordinate and the minimum ordinate.
[0151] Step 729: The electronic device generates updated first additional diagonal coordinates based on the minimum abscissa and the minimum ordinate.
[0152] Step 730: The electronic device generates updated second additional diagonal coordinates based on the maximum abscissa and the maximum ordinate.
[0153] Step 731: The electronic device generates updated third input data based on the updated first additional diagonal coordinates and the updated second additional diagonal coordinates.
[0154] In the embodiments of the present invention, for the descriptions of steps 727 to 731, reference may be made to steps 41 to 45, which will not be elaborated herein.
[0155] In the embodiments of the present invention, if the annotation data includes horizontal rectangle instances, the correction operation further includes a conversion operation; the method includes: Step S1: In response to the conversion operation, the electronic device determines four conversion coordinates based on the horizontal rectangle instance.
[0156] Among them, the horizontal rectangle instance includes two diagonal coordinates, the height of the rectangle, and the width of the rectangle. The two diagonal coordinates include the fifth diagonal coordinate and the sixth diagonal coordinate. For example, the fifth diagonal coordinate A5 is (x11, y11), the sixth diagonal coordinate A6 is (x12, y12), and x11 < x12, the height of the rectangle is E_h, and the width of the rectangle is E_w. Then the four conversion coordinates are E1(x11, y11), E2(x12, y12), E3(x11 + E_w, y11), and E4(x11, y11 + E_h), where x11 + E_w ≤ x12 and y11 + E_h ≤ y12.
[0157] Step S2: The electronic device calculates the four conversion coordinates according to the circumscribed rectangle algorithm to generate a converted minimum circumscribed rectangle.
[0158] Among them, the circumscribed rectangle algorithm may include the Rotating Calipers Algorithm, the Graham Scan, or the OpenCV algorithm. The electronic device uses the cv2.minAreaRect() function in the OpenCV algorithm to calculate E1, E2, E3, and E4.
[0159] Step S3: The electronic device calculates the converted minimum circumscribed rectangle according to the image vertex algorithm to generate four vertex coordinates of the converted minimum circumscribed rectangle.
[0160] The image vertex algorithm may include a rotating bounding box algorithm, a convex hull algorithm or an OpenCV algorithm. The electronic device uses the cv2.boxPoints() function in the OpenCV algorithm to calculate the minimum enclosing rectangle of the conversion.
[0161] Step S4: The electronic device generates conversion data according to the coordinates of the four vertices of the minimum circumscribed rectangle.
[0162] Specifically, the electronic device uses the path method of the QGraphicsPathItem class in PySide6 to sequentially connect the four vertex coordinates of the converted minimum circumscribed rectangle to generate conversion data, wherein the conversion data is a rotated rectangle instance, and the rotated rectangle instance includes four vertex coordinates.
[0163] In an embodiment of the present invention, the method further includes: the electronic device receives an export operation input by the user according to the data set; in response to the export operation, the data set is stored in a local disk. As an optional solution, the data set is a COCO data set and a YOLO data set, and the electronic device stores the data set in a local disk specifically including: the electronic device directly stores the COCO data set and the YOLO data set in a local disk. As another optional solution, the data set is a DOTA data set, and the electronic device stores the data set in a local disk specifically including: the electronic device converts each data in the DOTA data set into a YOLO_OBB (YouOnly Look Once_Oriented Bounding Box) data set format, and uses all converted data in the YOLO_OBB data set format as a YOLO_OBB data set, and stores the YOLO_OBB data set and the DOTA data set in a local disk, wherein the YOLO_OBB data set includes all converted data in the YOLO_OBB data set format.
[0164] In an embodiment of the present invention, the method further includes: the electronic device performs an import operation according to a user input, where the import operation includes a target data set; and generates a rectangle instance according to the target data set.
[0165] For example, the target data set includes the COCO data set, the COCO data set includes two labeled diagonal coordinates, and the rectangular instance is a horizontal rectangular instance. The electronic device calculates the width and height of the horizontal matrix instance based on the two labeled diagonal coordinates, and generates the horizontal matrix instance based on the width and height of the horizontal matrix instance and the two labeled diagonal coordinates.
[0166] For another example, the target data set includes a YOLO data set, the YOYO data set includes image data and normalized values, the normalized values include a horizontal coordinate normalized value and a vertical coordinate normalized value, and the image data includes width and height. The electronic device multiplies each horizontal coordinate normalized value by the width to obtain a horizontal coordinate and multiplies each vertical coordinate normalized value by the height to obtain a vertical coordinate, so as to obtain two labeled diagonal coordinates, each labeled diagonal coordinate includes a horizontal coordinate and a vertical coordinate; calculates the width and height of the horizontal matrix instance according to the two labeled diagonal coordinates; and generates the horizontal matrix instance according to the width and height of the horizontal matrix instance and the two labeled diagonal coordinates.
[0167] For another example, the DOTA data set includes annotated data, and the annotated data includes four vertex coordinates. The electronic device sequentially connects the four vertex coordinates of the annotated data to generate a rotated rectangle instance.
[0168] For another example, the YOLO_OBB data set includes image data and normalized values of four vertex coordinates, the image data includes width and height, and each normalized value includes a normalized value of a horizontal coordinate and a normalized value of a vertical coordinate. The electronic device multiplies each normalized value of the horizontal coordinate by the width to obtain the horizontal coordinate and multiplies each normalized value of the horizontal coordinate and each normalized value of the vertical coordinate by the height to obtain the vertical coordinate, so as to obtain four vertex coordinates, each vertex coordinate includes a horizontal coordinate and a vertical coordinate; the four vertex coordinates are connected in sequence to generate a rotated rectangle instance.
[0169] In the technical solution of the embodiment of the present invention, the electronic device receives first input data and a marking method input by a user; generates at least one identification data according to the first input data; and marks the at least one identification data according to the marking method to generate at least one marking data. The electronic device marks the identified data according to the marking method selected by the user, and by using the improved marking method to mark the identification data, the marking efficiency and marking accuracy are improved, thereby further reducing the manpower and time costs, improving the execution efficiency of industrial visual inspection tasks, and improving the target area recognition accuracy.
[0170] In the embodiment of the present invention, the minimum circumscribed rectangle is used to determine the identification area required by the user according to the four marking points, and the identification area is accurate. In addition, the embodiment of the present invention uses a rotated rectangle marking method to directly mark, rather than determining a horizontal rectangle instance and then rotating the horizontal rectangle instance to generate a rotated rectangle instance, which leads to faster recognition efficiency.
[0171] In the embodiment of the present invention, a model pre-trained with a small sample size is used to identify accurate recognition data, and automatic annotation is performed according to the recognition data. After the image annotation is completed, the annotation data is allowed to be manually checked and corrected after the annotation data is generated. The advantages of machine learning and manual correction are combined to ensure both the annotation speed and the annotation quality.
[0172] In the embodiment of the present invention, the annotated data can be exported as COCO dataset, YOLO dataset, DOTA dataset and YOLO_OBB dataset at the same time, and the dataset can be directly used for model training without additional arrangement of the dataset format, thereby enhancing the versatility of the dataset. At the same time, the embodiment of the present invention also supports direct import of COCO dataset, YOLO dataset, DOTA dataset and YOLO_OBB dataset, and can realize format conversion between datasets, which helps users make full use of existing annotation resources, avoid duplication of work and waste, and further improve the efficiency of the use of annotated data.
[0173] In an embodiment of the present invention, a horizontal rectangular data set can also be converted into a rotated rectangular annotation data set, and a user can use the same annotation data to perform a variety of different types of model training and task applications, thereby increasing the scope of use of the annotation data and further improving the use efficiency and economic value of the annotation data.
[0174] Fig.17 A schematic diagram of the structure of an image data annotation device provided by an embodiment of the present invention is shown in FIG. Fig.17 As shown, the device includes: an interaction unit 11, a first generation unit 12 and a labeling unit 13. The interaction unit 11 is connected to the first generation unit 12, and the first generation unit 12 is connected to the labeling unit 13.
[0175] The interaction unit 11 is used to receive first input data and a marking method input by a user; the first generation unit 12 is used to generate at least one identification data according to the first input data; the marking unit 13 is used to mark the at least one identification data according to the marking method to generate at least one marking data.
[0176] In the embodiment of the present invention, Fig.17 As shown, the device further includes: a second generating unit 14. The second generating unit 14 is connected to the labeling unit 13. The second generating unit 14 is used to generate a data set according to the at least one labeling data.
[0177] As an alternative, Fig.18 A schematic diagram of the structure of a first generation unit provided in an embodiment of the present invention is shown in FIG. Fig.18As shown, the first input data includes image selection data, model selection data, confidence threshold and recognition type; the first generation unit 12 includes: a first acquisition module 21, a second acquisition module 22, an AI image recognition module 23 and a screening module 24. The first acquisition module 21 and the second acquisition module 22 are connected to the AI image recognition module 23, and the AI image recognition module 23 is connected to the screening module 24.
[0178] The first acquisition module 21 is used to acquire image data according to the image selection data, wherein the image data includes an image; the second acquisition module 22 is used to acquire the corresponding AI model according to the model selection data; the AI image recognition module 23 is used to use the AI model to recognize the image and generate at least one target data; the screening module 24 is used to screen the at least one target data according to the confidence threshold and the recognition type to generate at least one recognition data.
[0179] In the embodiment of the present invention, Fig.19 A structural diagram of a screening module provided by an embodiment of the present invention, such as Fig.19 As shown, the target data includes the target, the confidence of the target and the type of the target; the screening module 24 includes: a first screening submodule 241 and a second screening submodule 242. The first screening submodule 241 is connected to the second screening submodule 242.
[0180] The first screening submodule 241 is used to take the target whose confidence is greater than the confidence threshold as the first screening target; the second screening submodule 242 is used to take the first screening target of the same type as the recognition type as at least one of the recognition data.
[0181] As another option, Fig. 20 A schematic diagram of the structure of another first generation unit provided in an embodiment of the present invention, such as Fig. 20 As shown, the first input data includes image selection data, and the image data includes an image; the first generation unit 12 includes: a first acquisition module 31, a first interaction module 32 and a first generation module 33. The first acquisition module 31 and the first interaction module 32 are connected to the first generation module 33.
[0182] The first acquisition module 31 is used to acquire image data according to the image selection data; the first interaction module 32 is used to receive at least one second input data input by the user according to the displayed image; and the first generation module 33 is used to use the at least one second input data as the at least one identification data.
[0183] In the embodiment of the present invention, Fig.17As shown, the image data includes the horizontal coordinate of the image origin and the vertical coordinate of the image origin, and the recognition data includes multiple recognition horizontal coordinates and the recognition vertical coordinate corresponding to each of the recognition horizontal coordinates; the device also includes: a first determination unit 15, a second determination unit 16, a first calculation unit 17, a second calculation unit 18 and a third generation unit 19. The first determination unit 15 is connected to the generation unit 12 and the first calculation unit 17, the second determination unit 16 is connected to the generation unit 12 and the second calculation unit 18, the first calculation unit 17 and the second calculation unit 18 are connected to the third generation unit 19, and the third generation unit 19 is connected to the annotation unit 13.
[0184] The first determination unit 15 is used to determine the difference between the horizontal coordinate of the image origin and the horizontal coordinate of the set inner layer origin as the horizontal axis offset distance; the second determination unit 16 is used to determine the difference between the vertical coordinate of the image origin and the vertical coordinate of the set inner layer origin as the vertical axis offset distance; the first calculation unit 17 is used to add each of the identified horizontal coordinates to the horizontal axis offset distance to generate a plurality of offset horizontal coordinates; the second calculation unit 18 is used to add each of the identified vertical coordinates to the vertical axis offset distance to generate a plurality of offset vertical coordinates; the third generation unit 19 is used to generate a plurality of corrected identification data according to the plurality of offset horizontal coordinates and the plurality of offset vertical coordinates.
[0185] In one possible implementation, Fig.21 A structural diagram of a marking unit provided in an embodiment of the present invention is shown in FIG. Fig. 20 As shown, the marking method is a rotating rectangle marking method, and the recognition data includes four marking coordinates; the marking unit 13 includes: a rectangle calculation module 41, a vertex calculation module 42 and a second generation module 43. The rectangle calculation module 41 is connected to the vertex calculation module 42, and the vertex calculation module 42 is connected to the second generation module 43.
[0186] The rectangle calculation module 41 is used to calculate the four annotation coordinates according to the bounding rectangle algorithm to generate a minimum bounding rectangle; the vertex calculation module 42 is used to calculate the minimum bounding rectangle according to the image vertex algorithm to generate the four vertex coordinates of the minimum bounding rectangle; the second generation module 43 is used to generate the annotation data according to the four vertex coordinates of the minimum bounding rectangle.
[0187] In another possible implementation, Fig. 22 A schematic diagram of another marking unit provided in an embodiment of the present invention is shown in FIG. Fig. 22As shown, the marking method is a rotated rectangular marking method, and the identification data includes the marking coordinates of four marking points, and the marking coordinates of the four marking points include the marking coordinates of the first marking point, the marking coordinates of the second marking point, the marking coordinates of the third marking point and the marking coordinates of the fourth marking point; the marking unit 13 includes: a first determination module 511, a second determination module 512, a third determination module 513, a third acquisition module 514 and a third generation module 515.
[0188] The first determination module 511 is used to determine the straight line passing through the first marked point and the second marked point as the top edge straight line according to the marked coordinates of the first marked point and the marked coordinates of the second marked point; the second determination module 512 is used to determine the first boundary and the second boundary according to the first marked point, the second marked point, the third marked point and the fourth marked point; the third determination module 513 is used to determine the bottom edge straight line parallel to the top edge straight line according to the marked coordinates of the third marked point and the marked coordinates of the fourth marked point; the third acquisition module 514 is used to intersect the top edge straight line, the first boundary, the bottom edge straight line and the second boundary in sequence to obtain four vertices, and obtain the coordinates of the four vertices; the third generation module 515 is used to generate the annotation data according to the coordinates of the four vertices.
[0189] In the embodiment of the present application, the second determination module 512 is specifically used to calculate a first slope according to the marked coordinates of the first marked point and the marked coordinates of the second marked point; generate a first perpendicular line passing through the first marked point, a second perpendicular line passing through the second marked point, a third perpendicular line passing through the third marked point, and a fourth perpendicular line passing through the fourth marked point according to the first slope; obtain first intersection coordinates, second intersection coordinates, third intersection coordinates, and fourth intersection coordinates, the first intersection coordinates are the coordinates of the intersection of the first perpendicular line and the coordinate axis, the second intersection coordinates are the coordinates of the intersection of the second perpendicular line and the coordinate axis, and the third The intersection coordinates are the coordinates of the intersection of the third perpendicular line and the coordinate axis, and the fourth intersection coordinates are the coordinates of the intersection of the fourth perpendicular line and the coordinate axis; the maximum intersection coordinates and the minimum intersection coordinates are determined from the first intersection coordinates, the second intersection coordinates, the third intersection coordinates and the fourth intersection coordinates; the fifth perpendicular line and the sixth perpendicular line perpendicular to the top edge straight line are generated, the fifth perpendicular line is a straight line passing through the marked point corresponding to the minimum intersection coordinate, and the sixth perpendicular line is a straight line passing through the marked point corresponding to the maximum intersection coordinate; the fifth perpendicular line is determined as the first boundary, and the sixth perpendicular line is determined as the second boundary.
[0190] In an embodiment of the present application, the third determination module 513 is specifically used to calculate the distance from the third annotation point to the top edge straight line according to the annotation coordinates of the third annotation point, and to calculate the distance from the fourth annotation point to the top edge straight line according to the annotation coordinates of the fourth annotation point, and to determine the annotation point with a larger distance between the third annotation point and the fourth annotation point as the maximum annotation point; generate a parallel line to the top edge straight line, determine the parallel line as the bottom edge straight line, and the parallel line passes through the maximum annotation point.
[0191] In another possible implementation, Fig.17 As shown, the annotation method is a horizontal rectangular annotation method, the recognition data includes two annotation diagonal coordinates, and the image data includes an image; the device also includes: a first judgment unit 51, a first correction unit 52 and a fourth generation unit 53. The first judgment unit 51 is connected to the first correction unit 52, and the fourth generation unit 53 is connected to the first correction unit 52.
[0192] The first judgment unit 51 is used to judge whether the two labeled diagonal coordinates are within the range of the image; the first correction unit 52 is used to correct the labeled diagonal coordinates that exceed the range of the image if the first judgment unit 51 judges that at least one labeled diagonal coordinate exceeds the range of the image, and generate corrected labeled diagonal coordinates; the fourth generation unit 53 is used to annotate the corrected labeled diagonal coordinates according to the horizontal rectangular annotation method, and generate corrected annotation data.
[0193] In the embodiment of the present invention, Fig.17 As shown, the marking method is a horizontal rectangular marking method, and the identification data includes two diagonal coordinates, the two diagonal coordinates include a first diagonal coordinate and a second diagonal coordinate, wherein the first diagonal coordinate includes a first diagonal horizontal coordinate and a first diagonal vertical coordinate, and the second diagonal coordinate includes a second diagonal horizontal coordinate and a second diagonal vertical coordinate; the device also includes: a third determination unit 54, a fifth generation unit 55 and a sixth generation unit 56.
[0194] The third determination unit 54 is used to compare the first diagonal horizontal coordinate and the second diagonal horizontal coordinate to determine the maximum horizontal coordinate and the minimum horizontal coordinate; compare the first diagonal vertical coordinate and the second diagonal vertical coordinate to determine the maximum vertical coordinate and the minimum vertical coordinate. The fifth generation unit 55 is used to generate the updated first diagonal coordinate according to the minimum horizontal coordinate and the minimum vertical coordinate; generate the updated second diagonal coordinate according to the maximum horizontal coordinate and the maximum vertical coordinate. The sixth generation unit 56 is used to generate the updated identification data according to the updated first diagonal coordinate and the updated second diagonal coordinate.
[0195] In the embodiment of the present invention, Fig.17 As shown, the device further includes: a second correction unit 20. The second correction unit 20 is connected to the interaction unit 11 and the annotation unit 13. The interaction unit 11 is also used to receive a correction operation input by the user according to the displayed multiple annotation data; the second correction unit 20 is used to correct the annotation data according to the correction operation and generate the corrected annotation data.
[0196] As another option, Fig.23 A structural diagram of a correction unit provided by an embodiment of the present invention is shown in FIG. Fig.23 As shown, the correction operation includes an adding operation; the second correction unit 20 includes: an adding module 68, a sixth generating module 69 and a seventh generating module 70. The adding module 68 is connected to the sixth generating module 69, and the sixth generating module 69 is connected to the seventh generating module 70.
[0197] The adding module 68 is used to obtain the third input data input by the user in response to the adding operation; the sixth generating module 69 is used to annotate the third input data according to the annotation method to generate newly added annotation data; the seventh generating module 70 is used to use the newly added annotation data and the annotation data as the revised annotation data.
[0198] As an alternative, Fig.24 A schematic diagram of the structure of a sixth generation module provided in an embodiment of the present invention is shown in FIG. Fig.24 As shown, the annotation method is a rotated rectangle annotation method, and the third input data includes four newly added annotation coordinates; the sixth generation module 69 includes: a rectangle calculation submodule 691, a vertex calculation submodule 692 and a first generation submodule 693. The rectangle calculation submodule 691 is connected to the vertex calculation submodule 692, and the vertex calculation submodule 692 is connected to the second generation submodule 693.
[0199] The rectangle calculation submodule 691 is used to calculate the four newly added annotation coordinates according to the outer rectangle algorithm to generate a newly added minimum outer rectangle; the vertex calculation submodule 692 is used to calculate the newly added minimum outer rectangle according to the image vertex algorithm to generate the four vertex coordinates of the newly added minimum outer rectangle; the first generation submodule 693 is used to generate the newly added annotation data according to the four vertex coordinates of the newly added minimum outer rectangle.
[0200] In the technical solution of the embodiment of the present invention, the electronic device receives first input data and a marking method input by a user; generates at least one identification data according to the first input data; and marks the at least one identification data according to the marking method to generate at least one marking data. The electronic device marks the identified data according to the marking method selected by the user, and by using the improved marking method to mark the identification data, the marking efficiency and marking accuracy are improved, thereby further reducing the manpower and time costs, improving the execution efficiency of industrial visual inspection tasks, and improving the target area recognition accuracy.
[0201] Fig.25 Schematic diagram of an electronic device provided by an embodiment of the present invention. Fig.25 As shown, the electronic device 10 of this embodiment includes: a processor 11, a memory 12, and a computer program 13 stored in the memory 11 and executable on the processor 11. When the computer program 13 is executed by the processor 11, the method for generating passenger demand applied in the embodiment is implemented. To avoid repetition, they are not described one by one here.
[0202] The electronic device 10 includes, but is not limited to, a processor 11 and a memory 12. Those skilled in the art will appreciate that Fig.25 It is only an example of the electronic device 10 and does not constitute a limitation of the electronic device 10. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 10 may also include input and output devices, network access devices, buses, etc.
[0203] The processor 11 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0204] The memory 12 may be an internal storage unit of the electronic device 10, such as a hard disk or memory of the electronic device 10. The memory 12 may also be an external storage device of the electronic device 10, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 10. Further, the memory 12 may also include both an internal storage unit of the electronic device 10 and an external storage device. The memory 12 is used to store computer programs and other programs and data required by network devices. The memory 12 may also be used to temporarily store data that has been output or is to be output. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described system, device and unit can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided by the present invention, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interface, indirect coupling or communication connection of the device or unit, which may be electrical, mechanical or other forms.
[0205] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0206] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0207] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a computer-readable storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned computer-readable storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0208] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for labeling image data, characterized in that: The method comprises: receiving first input data and a marking method input by a user; generating at least one identification data according to the first input data; The at least one identification data is annotated according to the annotation method to generate at least one annotated data.
2. The method according to claim 1, characterized in that The first input data includes image selection data, model selection data, confidence threshold and recognition type; The step of generating at least one identification data according to the first input data comprises: Acquire image data according to the image selection data, wherein the image data includes an image; According to the model selection data, a corresponding AI model is obtained; Using the AI model to recognize the image and generate at least one target data; The at least one target data is screened according to the confidence threshold and the recognition type to generate at least one recognition data.
3. The method according to claim 2, characterized in that The target data includes a target, a confidence level of the target, and a type of the target; The step of screening the at least one target data according to the confidence threshold and the recognition type to generate at least one recognition data comprises: Taking the target whose confidence is greater than the confidence threshold as the first screening target; The first screening target of the same type as the identification type is used as at least one of the identification data.
4. The method according to claim 1, characterized in that: The first input data includes image selection data, and the image data includes an image; The step of generating at least one identification data according to the first input data comprises: acquiring image data according to the image selection data; receiving at least one second input data input by a user according to the displayed image; The at least one second input data is used as the at least one identification data.
5. The method according to claim 1, characterized in that The image data includes a horizontal coordinate of an image origin and a vertical coordinate of an image origin, and the identification data includes a plurality of identification horizontal coordinates and an identification vertical coordinate corresponding to each of the identification horizontal coordinates; Before the at least one identification data is annotated according to the annotation method to generate at least one annotated data, the method further includes: The difference between the horizontal coordinate of the image origin and the horizontal coordinate of the set inner layer origin is determined as the horizontal axis offset distance; The difference between the ordinate of the image origin and the ordinate of the inner layer origin is determined as the ordinate offset distance; Adding each of the identified horizontal coordinates to the horizontal axis offset distance to generate a plurality of offset horizontal coordinates; Adding each of the identified vertical coordinates to the vertical axis offset distance to generate a plurality of offset vertical coordinates; A plurality of corrected identification data are generated according to the plurality of offset horizontal coordinates and the plurality of offset vertical coordinates.
6. The method according to claim 1, characterized in that The marking method is a rotated rectangular marking method, and the identification data includes four marking coordinates; The step of labeling the at least one identification data according to the labeling method to generate at least one labeling data includes: Calculate the four marked coordinates according to the bounding rectangle algorithm to generate a minimum bounding rectangle; Calculate the minimum bounding rectangle according to the image vertex algorithm to generate the coordinates of four vertices of the minimum bounding rectangle; The annotation data is generated according to the coordinates of the four vertices of the minimum circumscribed rectangle.
7. The method according to claim 1, characterized in that The marking method is a rotated rectangular marking method, and the identification data includes the marking coordinates of four marking points, and the marking coordinates of the four marking points include the marking coordinates of a first marking point, the marking coordinates of a second marking point, the marking coordinates of a third marking point, and the marking coordinates of a fourth marking point; The step of labeling the at least one identification data according to the labeling method to generate at least one labeling data includes: According to the marked coordinates of the first marked point and the marked coordinates of the second marked point, a straight line passing through the first marked point and the second marked point is used as a top edge straight line; Determining a first boundary and a second boundary according to the first marked point, the second marked point, the third marked point, and the fourth marked point; Determine a bottom edge straight line parallel to the top edge straight line according to the marked coordinates of the third marked point and the marked coordinates of the fourth marked point; Intersecting the top edge straight line, the first boundary, the bottom edge straight line and the second boundary in sequence to obtain four vertices, and obtaining the coordinates of the four vertices; The annotation data is generated according to the coordinates of the four vertices.
8. The method according to claim 7, characterized in that The determining of the first boundary and the second boundary according to the first marking point, the second marking point, the third marking point and the fourth marking point includes: Calculating a first slope according to the marked coordinates of the first marked point and the marked coordinates of the second marked point; generating, according to the first slope, a first perpendicular line passing through the first marked point, a second perpendicular line passing through the second marked point, a third perpendicular line passing through the third marked point, and a fourth perpendicular line passing through the fourth marked point; Obtaining first intersection coordinates, second intersection coordinates, third intersection coordinates, and fourth intersection coordinates, wherein the first intersection coordinates are the coordinates of the intersection of the first perpendicular line and the coordinate axis, the second intersection coordinates are the coordinates of the intersection of the second perpendicular line and the coordinate axis, the third intersection coordinates are the coordinates of the intersection of the third perpendicular line and the coordinate axis, and the fourth intersection coordinates are the coordinates of the intersection of the fourth perpendicular line and the coordinate axis; Determining a maximum intersection point coordinate and a minimum intersection point coordinate from the first intersection point coordinate, the second intersection point coordinate, the third intersection point coordinate and the fourth intersection point coordinate; Generate a fifth perpendicular line and a sixth perpendicular line perpendicular to the top edge straight line, wherein the fifth perpendicular line is a straight line passing through the marked point corresponding to the minimum intersection coordinate, and the sixth perpendicular line is a straight line passing through the marked point corresponding to the maximum intersection coordinate; The fifth perpendicular line is determined as a first boundary, and the sixth perpendicular line is determined as a second boundary.
9. The method according to claim 7, characterized in that: The step of determining a bottom line parallel to the top line according to the marked coordinates of the third marked point and the marked coordinates of the fourth marked point includes: Calculate the distance from the third marked point to the top edge straight line according to the marked coordinates of the third marked point, and calculate the distance from the fourth marked point to the top edge straight line according to the marked coordinates of the fourth marked point, and determine the marked point with a larger distance between the third marked point and the fourth marked point as the maximum marked point; A parallel line of the top edge straight line is generated, and the parallel line is determined as the bottom edge straight line, and the parallel line passes through the maximum marking point.
10. The method according to claim 1, characterized in that The annotation method is a horizontal rectangular annotation method, the annotation data includes two annotation diagonal coordinates, and the image data includes an image; After the at least one identification data is annotated according to the annotation method to generate at least one annotated data, the method includes: Determining whether the two marked diagonal coordinates are within the range of the image; If it is determined that at least one of the labeled diagonal coordinates exceeds the range of the image, the labeled diagonal coordinates that exceed the range of the image are corrected to generate corrected labeled diagonal coordinates, and the corrected labeled diagonal coordinates are labeled according to the horizontal rectangular labeling method to generate corrected labeling data.
11. The method according to claim 1, characterized in that: The marking method is a horizontal rectangular marking method, and the identification data includes two diagonal coordinates, and the two diagonal coordinates include a first diagonal coordinate and a second diagonal coordinate, wherein the first diagonal coordinate includes a first diagonal horizontal coordinate and a first diagonal vertical coordinate, and the second diagonal coordinate includes a second diagonal horizontal coordinate and a second diagonal vertical coordinate; Before the at least one identification data is annotated according to the annotation method to generate at least one annotated data, the method further includes: Compare the first diagonal horizontal coordinate and the second diagonal horizontal coordinate to determine the maximum horizontal coordinate and the minimum horizontal coordinate; Compare the first diagonal ordinate and the second diagonal ordinate to determine the maximum ordinate and the minimum ordinate; Generate an updated first diagonal coordinate according to the minimum horizontal coordinate and the minimum vertical coordinate; Generate an updated second diagonal coordinate according to the maximum horizontal coordinate and the maximum vertical coordinate; Updated identification data is generated according to the updated first diagonal coordinates and the updated second diagonal coordinates.
12. The method according to claim 1, characterized in that After the at least one identification data is annotated according to the annotation method to generate at least one annotated data, the method further includes: receiving a correction operation input by a user according to the displayed plurality of annotated data; The labeled data is modified according to the modification operation to generate the modified labeled data.
13. The method according to claim 12, characterized in that The modification operation includes an addition operation; The modifying the labeled data according to the modifying operation to generate the modified labeled data comprises: In response to the adding operation, obtaining third input data input by the user; Annotate the third input data according to the annotation method to generate newly added annotation data; The newly added annotation data and the annotation data are used as the corrected annotation data.
14. The method according to claim 12, characterized in that The marking method is a rotated rectangle marking method, and the third input data includes four newly added marking coordinates; The step of labeling the third input data according to the labeling method to generate newly labeled data includes: Calculate the four newly added annotation coordinates according to the bounding rectangle algorithm to generate a newly added minimum bounding rectangle; Calculate the newly added minimum bounding rectangle according to the image vertex algorithm to generate four vertex coordinates of the newly added minimum bounding rectangle; The newly added annotation data is generated according to the coordinates of the four vertices of the newly added minimum circumscribed rectangle.
15. A device for labeling image data, characterized in that: The device comprises: An interaction unit, used for receiving first input data and a marking method input by a user; A first generating unit, configured to generate at least one identification data according to the first input data; The labeling unit is used to label the at least one identification data according to the labeling method to generate at least one labeling data.
16. An electronic device, characterized in that: include: one or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the electronic device, enable the electronic device to perform the image data labeling method described in any one of claims 1 to 14.
17. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the electronic device where the computer-readable storage medium is located is controlled to execute the image data labeling method according to any one of claims 1 to 14.