Object size recognition method, device, computer equipment and storage medium
By acquiring and analyzing pixel information in the image area in the image recognition technology, the accurate identification and classification of the target object size is achieved, and the problem of low accuracy in the prior art is solved, and efficiency in business scenarios is improved.
Patent Information
- Application Number
- CN202011499199.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2040-12-17
AI Technical Summary
Existing image recognition technology cannot accurately identify and distinguish similar objects of different sizes, resulting in low accuracy in target object size recognition.
By acquiring the first image area and the second image area in the image to be identified, including reference object information and target object information, the size category prediction is performed using these pixel information, and the size recognition result of the target object relative to the reference object is obtained.
The accuracy of the size recognition of the target object is improved, the size classification of the target object is realized, the efficiency of the size classification of the size of the target object in actual business scenarios is improved, and manpower and material resources are saved.
Smart Images

Figure CN114648568B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an object size recognition method, device, computer equipment and storage medium. Background Art
[0002] Artificial Intelligence (AI) is a comprehensive technology in computer science. By studying the design principles and implementation methods of various intelligent machines, machines can have the functions of perception, reasoning and decision-making. With the rapid development of artificial intelligence technology, image recognition technology based on computer vision technology has occupied an increasingly large proportion in the field of image processing. More and more application scenarios have begun to use image recognition technology to realize the needs of identifying the types of related physical objects, such as human recognition in video surveillance scenarios.
[0003] However, existing image recognition technology can only accurately identify different types of objects, but cannot distinguish the sizes of the same objects, that is, it is impossible to accurately identify and distinguish the same objects of different sizes.
[0004] Therefore, the existing image recognition technology has the problem of low accuracy in recognizing the size of the target object. Summary of the invention
[0005] Based on this, it is necessary to provide an object size recognition method, device, computer equipment and storage medium to improve the size recognition accuracy of the target object in response to the above technical problems.
[0006] In a first aspect, the present application provides a method for identifying object size, the method comprising:
[0007] Acquire a first image region and a second image region in an image to be identified, wherein the first image region contains reference object information, and the second image region contains target object information;
[0008] Acquire pixel information of the first image area and pixel information of the second image area to obtain first pixel information of the first image area and second pixel information of the second image area;
[0009] The size category of the target object information in the to-be-recognized image is predicted based on the first pixel information and the second pixel information to obtain a size recognition result of the target object information relative to the reference object information.
[0010] In some embodiments of the present application, the step of acquiring the first image area and the second image area in the image to be recognized includes:
[0011] Obtain an image to be recognized;
[0012] Using a preset trained object size recognition model, performing object information recognition on the image to be recognized, and obtaining reference object information and target object information in the image to be recognized;
[0013] A first image region in the image to be identified is acquired according to the reference object information, and a second image region in the image to be identified is acquired according to the target object information.
[0014] In some embodiments of the present application, before using the preset trained object size recognition model to perform object information recognition on the image to be recognized and obtaining reference object information and target object information in the image to be recognized, the method further includes:
[0015] Build an initial object size recognition model;
[0016] Acquire an object image set, and divide the object image set into a training set and a test set; the object image set includes a plurality of object images annotated with the reference object information and the target object information;
[0017] Performing preliminary training on the initial object size recognition model using the training set to obtain a preliminary trained object size recognition model;
[0018] The test set is used to test and adjust the initially trained object size recognition model to obtain a trained object size recognition model.
[0019] In some embodiments of the present application, the step of acquiring pixel information of the first image area and pixel information of the second image area to obtain first pixel information of the first image area and second pixel information of the second image area includes:
[0020] Acquire pixel information of the first image area and pixel information of the second image area, wherein the pixel information of the first image area includes long side pixel information and wide side pixel information, and the pixel information of the second image area includes a maximum pixel value and a minimum pixel value;
[0021] Determining first pixel information of the first image area according to the broadside pixel information;
[0022] Second pixel information of the second image area is determined according to the maximum pixel value and the minimum pixel value.
[0023] In some embodiments of the present application, the step of determining second pixel information of the second image area according to the maximum pixel value and the minimum pixel value includes:
[0024] Determine the first axis coordinate and the second axis coordinate corresponding to the pixel maximum value as the pixel maximum value coordinate, and determine the first axis coordinate and the second axis coordinate corresponding to the pixel minimum value as the pixel minimum value coordinate, the first axis coordinate is the X axis coordinate, and the second axis coordinate is the Y axis coordinate;
[0025] Based on the Euclidean distance algorithm, the coordinate distance between the minimum value coordinate and the pixel maximum value coordinate is calculated to obtain the second pixel information of the second image area.
[0026] In some embodiments of the present application, the step of performing size category prediction on the target object information in the image to be identified based on the first pixel information and the second pixel information to obtain a size recognition result of the target object information relative to the reference object information includes:
[0027] Obtaining a first pixel value in the first pixel information and a second pixel value in the second pixel information;
[0028] Calculating the product of the first pixel value and a preset ratio value to obtain a size recognition threshold;
[0029] The size category of the target object in the image to be identified is predicted according to the size recognition threshold and the second pixel value to obtain a size recognition result of the target object.
[0030] In some embodiments of the present application, the size recognition threshold includes a first size recognition threshold and a second size recognition threshold, the first size recognition threshold is less than the second size recognition threshold, and the step of performing size category prediction on the target object in the image to be recognized according to the size recognition threshold and the second pixel value to obtain the size recognition result of the target object includes:
[0031] When the second pixel value is less than the first size recognition threshold, determining that a size recognition result of the target object information relative to the reference object information is a first type of size;
[0032] When the second pixel value is between the first size recognition threshold and the second size recognition threshold, determining that the size recognition result of the target object information relative to the reference object information is a second type of size;
[0033] When the second pixel value is greater than the second size recognition threshold, it is determined that a size recognition result of the target object information relative to the reference object information is a third type of size.
[0034] In a second aspect, the present application provides an object size recognition device, the device comprising:
[0035] An image acquisition module, used to acquire a first image area and a second image area in an image to be identified, wherein the first image area contains reference object information, and the second image area contains target object information;
[0036] A pixel acquisition module, used to acquire pixel information of the first image area and pixel information of the second image area, to obtain first pixel information of the first image area and second pixel information of the second image area;
[0037] The size recognition module is used to predict the size category of the target object information in the image to be recognized based on the first pixel information and the second pixel information, and obtain a size recognition result of the target object information relative to the reference object information.
[0038] In a third aspect, the present application further provides a server, the server comprising:
[0039] one or more processors;
[0040] Memory; and
[0041] One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the object size recognition method.
[0042] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is loaded by a processor to execute the steps in the object size recognition method.
[0043] The object size recognition method, device, computer equipment and storage medium mentioned above can predict the size category of the target object information in the image to be recognized by obtaining the first image area containing the reference object information and the second image area containing the target object information in the image to be recognized, and finally analyze and obtain the size recognition result of the target object information relative to the reference object information, that is, determine the size of the target object in the image to be recognized. Since the present application proposes to introduce a comprehensive analysis of the reference object while recognizing the size of the target object, and the actual size of the reference object is fixed, the actual size of the target object can be accurately identified, and then the size classification of the target object can be realized. By adopting this method, the target object in the image is identified based on artificial intelligence technology, and the relative size of the reference object and the target object is analyzed to determine the actual size of the target object, which can not only improve the accuracy of the size recognition of the target object, but also improve the efficiency of the classification of large and small objects in actual business scenarios based on the rapid classification of the target object size, saving manpower and material resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 is a schematic diagram of a scene of an object size recognition method in an embodiment of the present application;
[0046] Figure 2 is a schematic diagram of the flow of the object size recognition method in an embodiment of the present application;
[0047] Figure 3 is a flow chart of the image region acquisition step in the embodiment of the present application;
[0048] Figure 4 is a flow chart of the steps of obtaining the object size recognition model in an embodiment of the present application;
[0049] Figure 5 is a flowchart of the pixel information acquisition step in an embodiment of the present application;
[0050] Figure 6 is a flowchart of another pixel information acquisition step in an embodiment of the present application;
[0051] Figure 7 It is a flowchart of the step of obtaining the size recognition result in the embodiment of the present application;
[0052] Figure 8 is a flowchart of another step of obtaining a size recognition result in an embodiment of the present application;
[0053] Fig. 9 is a schematic diagram of the structure of an object size recognition device in an embodiment of the present application;
[0054] Fig.10 It is a schematic diagram of the structure of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0056] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.
[0057] In the description of the present application, the word "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in the present application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any technician in the field to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.
[0058] In the embodiment of the present application, the object size recognition method mainly involves computer vision technology (CV) in artificial intelligence (AI). Among them, artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science, which attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence.
[0059] Computer vision is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify, track and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and mapping, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition. In this application, for the image to be identified, CV mainly implements target object recognition (Target recognition) under image detection and image recognition (Image Identification) in image semantic understanding (ISU), identifies and predicts the target object in the image and outputs the prediction result. It is understandable that the target object may be any object determined by actual business needs, such as a person, a vehicle, a courier, or other persons or things.
[0060] In the embodiments of the present application, it should be noted that since the object size recognition method provided by the present application is executed in a computer device, the processing objects of each computer device exist in the form of data or information, such as time, which is actually time information. It can be understood that if size, quantity, position, etc. are mentioned in subsequent embodiments, they are all corresponding data, so that the computer device can process them, and the details will not be repeated here.
[0061] In the embodiment of the present application, it should be noted that the object size recognition method provided in the embodiment of the present application can be applied to Figure 1In the object size recognition system shown. The object size recognition system includes a terminal 100 and a server 200. The terminal 100 can be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. Such a device may include: a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display. The terminal 100 can specifically be a desktop terminal or a mobile terminal. The terminal 100 can specifically be one of a mobile phone, a tablet computer, a laptop computer, etc., or a camera installed at a monitoring site for information collection, storage, and transmission. The server 200 can be an independent server, or a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets, or a cloud server composed of a plurality of servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
[0062] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or less computer equipment as shown in Figure 1 Only one server 200 is shown in the figure. It is understandable that the object size recognition system may also include one or more other servers, which are not specifically limited here. Figure 1 As shown, the object size recognition system may further include a memory for storing data, such as video surveillance data.
[0063] It should also be noted that Figure 1 The scene diagram of the object size recognition system shown is only an example. The object size recognition system and scene described in the embodiment of the present invention are intended to more clearly illustrate the technical solution of the embodiment of the present invention, and do not constitute a limitation on the technical solution provided by the embodiment of the present invention. Ordinary technicians in this field can know that with the evolution of the object size recognition system and the emergence of new business scenarios, the technical solution provided by the embodiment of the present invention is also applicable to similar technical problems.
[0064] See also Figure 2 The present application embodiment provides an object size recognition method, which is mainly applied to the above Figure 1 Taking the server 200 in the example, the method includes steps S201 to S203, which are as follows:
[0065] S201, acquiring a first image region and a second image region in an image to be identified, wherein the first image region contains reference object information, and the second image region contains target object information.
[0066] Among them, the image to be identified refers to an image whose size of the target object needs to be identified, including but not limited to pictures, video frames in videos, etc.; videos include but not limited to short videos, long videos and other formats. Short videos can be videos with a length of less than 10 minutes, and long videos can be videos with a length of more than 10 minutes.
[0067] The first image area and the second image area refer to the collection of all pixels in the partial area of the image to be identified, which respectively contains the preset reference object information and the target object information.
[0068] The reference object information and target object information refer to the pixel information of the pre-set identifiable physical object, and the determination of the reference object depends on the target object in the actual application scenario. For example, if the target object in the actual application scenario is a courier box, the reference object can be a sorting line belt conveyor, and the application scenario at this time is a courier sorting scenario in the logistics field.
[0069] Specifically, the object size recognition method provided by the embodiment of the present application can be applied to application scenarios where the size recognition of the target object is required. The setting of the target object depends on the actual business needs in the application scenario, and the setting of the reference object depends on the actual business scenario in the application scenario, that is, the reference object and the target object should be able to appear in an image at the same time, so as to accurately identify the size of the target object based on the comparison of the reference object. Before the server 200 performs the size recognition task of the target object, the user can send a recognition request to the server 200 through the terminal 100, and the recognition request carries the image to be recognized that needs to be recognized. After receiving the recognition request, the server 200 can obtain the size information of the target object in the image to be recognized according to the object size recognition method. Alternatively, before the server 200 performs the size recognition task of the target object, the server 200 does not need to obtain the recognition request sent by the terminal 100. At this time, the terminal 100 is a camera with a camera function. After the terminal 100 acquires the image to be recognized in a timed or real-time manner, it can be sent to the server 200 to recognize the size of the target object. Furthermore, the terminal 100 may be equipped with a target object recognition device, and the terminal 100 may collect videos or images in a regular or real-time manner. If a target object preset by a user appears in the video or image, an image frame containing the target object may be intercepted and sent to the server 200, so that the server 200 may recognize the size of the image as an image to be recognized. The reference object and target object involved in this embodiment may be set according to actual business needs, and this application does not limit this.
[0070] More specifically, the acquisition of the first image area and the second image area in the image to be identified proposed in the embodiment of the present application can be implemented by an instance segmentation algorithm in the field of artificial intelligence. Because instance segmentation is different from traditional semantic segmentation, that is, semantic segmentation only segments the type of targets in the field of view, while instance segmentation not only segments the type, but also needs to segment whether targets of the same type are the same instance. For example, semantic segmentation will mark the balloon pixels in the image, while instance segmentation will not only mark the balloon pixels in the image, but also output the number of balloons, as well as the pixel colors and pixel positions of different balloons. Therefore, in this embodiment, an instance segmentation algorithm is used to obtain the first image area and the second image area in the image to be identified, so that in the same image, the image area containing the reference object information and the image area containing the target object information can be accurately identified, and the pixel information of different image areas can be marked respectively.
[0071] It should be noted that before the image region acquisition step involved in this embodiment, there should be model pre-training for object information annotation and recognition, that is, prepare some sample set images, and each image in the sample set images should be marked with reference object information and target object information respectively. After the annotation is completed, it is input into the instance segmentation model for learning and training, and the first image region and the second image region in the image to be identified can be obtained through the trained instance segmentation model in actual application. The specific model training implementation steps will be described in detail below.
[0072] In one embodiment, Figure 3 As shown, this step includes: S301, obtaining an image to be identified; S302, using a preset trained object size recognition model to perform object information recognition on the image to be identified, and obtaining reference object information and target object information in the image to be identified; S303, obtaining a first image area in the image to be identified according to the reference object information, and obtaining a second image area in the image to be identified according to the target object information.
[0073] The trained object size recognition model may be a trained neural network model, and may specifically be a Mask-R-CNN model.
[0074] Specifically, in order to perform object information recognition processing on the image to be recognized, and to obtain the reference object information and target object information in the image to be recognized for subsequent analysis and processing, it is necessary to pre-train the object size recognition model so that it has the ability to recognize various types of object information previously annotated in the image, and then obtain the trained object size recognition model. After that, the image to be recognized is input into the trained object size recognition model, and the image recognition result output by the model can be obtained, that is, the object information in the image to be recognized is marked, and the object information is the reference object information and target object information annotated in the early stage according to actual business needs. The marking form can be a bounding box, that is, the object information in the image to be recognized is marked with a bounding box, and the collection of all pixels mainly containing object information is obtained, that is, the image area. Finally, the first image area and the second image area in the image to be recognized are obtained.
[0075] It should be noted that the input of the object size recognition model provided in the present application can be a picture of any size, but the training of the model requires data of a fixed size. In this case, the picture of any size can be cropped to obtain a picture that meets the size requirements to implement model training. The object size recognition model training steps involved in this embodiment will be described in detail below.
[0076] In one embodiment, Figure 4 As shown, before using the preset trained object size recognition model to perform object information recognition on the image to be recognized and obtaining the reference object information and the target object information in the image to be recognized, the method also includes: S401, constructing an initial object size recognition model; S402, obtaining an object image set, and dividing the object image set into a training set and a test set; the object image set includes a plurality of object images that are labeled with the reference object information and the target object information; S403, using the training set to perform preliminary training on the initial object size recognition model to obtain a preliminary trained object size recognition model; S404, using the test set to test and adjust the preliminary trained object size recognition model to obtain a trained object size recognition model.
[0077] The initial object size recognition model may be a pre-trained neural network model or a non-pre-trained neural network model.
[0078] Among them, the object image can be an image used for the object size recognition model and marked with an object identifier. The object identifier in this embodiment can be a reference object identifier and a target object identifier. The reference object identifier can be "1" and the target object identifier can be "0". For example, the images collected in the express sorting workshop contain sorting line belt conveyors and express (boxed, bagged, etc.). The staff can pre-mark the sorting line belt conveyor in the image as "1" and the express in the image as "0". Repeat the annotation of multiple pictures to obtain a large number of object image sets that can be used for model training. The annotation tool used in the annotation process can be labellmg written in Python language, which supports cross-platform operation on Windows, Linux, etc., and the specified target object can be marked with a frame through a visual operation interface.
[0079] Specifically, before the server 200 uses the trained object size recognition model to perform object information recognition processing on the image to be recognized, it is necessary to first construct an initial object size recognition model. If the initial object size recognition model is a neural network model pre-trained by a preset image training set, it will have certain initialization parameters, and part of the model training process can be omitted in the subsequent training process, saving model training time; if the initial object size recognition model is a neural network model that has not been pre-trained, it is necessary to obtain and use the object image set to fully train it until it has the ability to recognize object information. It can be understood that the above-mentioned preset image training set can be a preset image set with the same properties as the object image set, that is, the selection of the image training set is not random, but is biased towards the selection of model parameters that are conducive to the model obtaining suitable for subsequent image recognition.
[0080] More specifically, the model training steps involved in this embodiment also include: the user uploads training images of 10,000 or 100,000 levels through the terminal 100, and annotates these images with objects, so that the server 200 obtains the object image set through the terminal 100; after the server 200 obtains the object image set, it is not only necessary to build an initial object size recognition model, that is, download, install and configure the relevant neural network model, but also to divide the training images uploaded by the user in the object image set into a training set and a test set according to a preset ratio, for example, a ratio of 9:1. Finally, the server 200 can use the training set and the test set to perform preliminary training and test adjustments of the model respectively, until the model finally learns the object recognition capability.
[0081] It should be noted that, although the present embodiment does not distinguish whether the server 200 is a training server that only performs model training tasks, a recognition server that only performs object recognition tasks, or a comprehensive server that can perform both tasks, the server function can be set according to business needs in actual applications, and this application does not limit it. In addition, the conditions for stopping model iterative training may include: 1. The error is less than a certain pre-set smaller value. 2. The change in weight between two iterations is already very small, and a threshold can be set. When it is less than this threshold, the training is stopped. 3. Set the maximum number of iterations, and stop training when the iteration exceeds the maximum number. 4. The recognition accuracy reaches a certain pre-set larger value.
[0082] S202: Acquire pixel information of the first image area and pixel information of the second image area to obtain first pixel information of the first image area and second pixel information of the second image area.
[0083] Among them, pixel refers to the smallest unit in an image represented by a digital sequence, which is composed of small squares in the image. These small squares have a clear position and assigned color values. The color and position of the small squares determine the appearance of the image.
[0084] Among them, the pixel coordinates are the positions of the pixels in the image. To determine the coordinates of the pixels, the coordinate system of the image must first be determined. Common coordinate systems include image coordinate systems, camera coordinate systems, world coordinate systems, etc. The coordinate system used in the embodiments of the present application is the image coordinate system, that is, a direct coordinate system uv in pixels is established with the upper left corner of the image as the origin, and an image coordinate system xy is established with the center point of the image as the origin, with the x-axis parallel to the u-axis and the y-axis parallel to the v-axis.
[0085] Specifically, the object size recognition method proposed in the embodiment of the present application does not directly recognize the size information of the target object using the object size recognition model, but analyzes the reference object information and the target object information in the image to be recognized based on the trained object size recognition model, so as to output the first image area and the second image area. The server 200 can analyze and obtain the pixel information of the first image area and the second image area in the image to be recognized, that is, the positions and color values of the reference object and the target object in the image to be recognized, respectively. After analyzing and obtaining the first pixel information of the first image area and the second pixel information of the second image area, the pixel information can be used for topological calculation to locate the size of the target object in the image to be recognized, and the size is determined relative to the fixed size of the reference object, so the size recognition result is more accurate. The pixel information acquisition steps involved in this embodiment will be described in detail below.
[0086] In one embodiment, Figure 5As shown, this step includes: S501, obtaining pixel information of the first image area and pixel information of the second image area, the pixel information of the first image area includes long side pixel information and wide side pixel information, and the pixel information of the second image area includes maximum pixel value and minimum pixel value; S502, determining first pixel information of the first image area according to the wide side pixel information; S503, determining second pixel information of the second image area according to the maximum pixel value and the minimum pixel value.
[0087] Among them, the long side pixels and wide side pixels are specified parameters that reflect the pixel size of the image. For example, if the pixel size of an image is 1000*500, then its long side pixels are 1000 and its wide side pixels are 500. The long side pixels are the pixel values in the horizontal direction, and the wide side pixels are the pixel values in the vertical direction.
[0088] Specifically, for the first image area containing the reference object information, its pixel information should include the long side pixel information and the wide side pixel information, and for the second image area containing the target object information, it is necessary to solve the maximum pixel value and the minimum pixel value in its pixel information, and the solution method can be used with the help of OpenCV (OpenCV is a cross-platform computer vision and machine learning software library that can run on Linux, Windows, Android and Mac OS operating systems) to identify the maximum pixel value and the minimum pixel value in the second image area. After the server 200 obtains the wide side pixel information of the first image area, it can determine the wide side pixel information as its first pixel information; and after the server 200 obtains the maximum pixel value and the minimum pixel value of the second image area, it is necessary to further calculate its second pixel information based on the maximum pixel value and the minimum pixel value, so as to use the first pixel information and the second pixel information to determine the actual size of the target object in the image to be identified relative to the reference object, that is, to obtain the size recognition result. The second pixel information acquisition step involved in this embodiment will be described in detail below.
[0089] In one embodiment, Figure 6 As shown, the step of determining the second pixel information of the second image area according to the pixel maximum value and the pixel minimum value includes: S601, determining the first axis coordinate and the second axis coordinate corresponding to the pixel maximum value as the pixel maximum value coordinate, and determining the first axis coordinate and the second axis coordinate corresponding to the pixel minimum value as the pixel minimum value coordinate, the first axis coordinate is the X-axis coordinate, and the second axis coordinate is the Y-axis coordinate; S602, based on the Euclidean distance algorithm, calculating the coordinate distance between the minimum value coordinate and the pixel maximum value coordinate to obtain the second pixel information of the second image area.
[0090] Among them, the Euclidean distance or Euclidean metric in the field of mathematics is the "ordinary" (i.e. straight-line) distance between two points in Euclidean space, and its calculation expression is: ρ is the Euclidean distance between point (x2, y2) and point (x1, y1). The Euclidean distance algorithm is to calculate the Euclidean distance between points.
[0091] Specifically, the server 200 can use OpenCV to obtain the maximum pixel value and the minimum pixel value in the second image area, and obtain the maximum pixel value (x_max, y_max) and the minimum pixel value (x_min, y_min), where "x_max" is the first axis coordinate corresponding to the maximum pixel value, "y_max" is the second axis coordinate corresponding to the maximum pixel value, "x_min" is the first axis coordinate corresponding to the minimum pixel value, and "y_min" is the second axis coordinate corresponding to the minimum pixel value. The server 200 analyzes the maximum pixel value and the minimum pixel value in the second image area, and can calculate the second pixel information "L" of the second image area. At this time, "L" represents the diameter of the minimum circumscribed circle of the second image area, which is defined as: For example, the maximum pixel value in the second image area is (40, 50) and the minimum pixel value is (30, 40), then
[0092] S203: Perform size category prediction on the target object information in the to-be-recognized image according to the first pixel information and the second pixel information to obtain a size recognition result of the target object information relative to the reference object information.
[0093] The size recognition results include the first type of size, the second type of size, and the third type of size, etc. The actual categories depend on the actual business needs. This application does not limit the number of size categories of the target object. For example, if the target object is express delivery (boxed, bagged), etc., the first type of size in its size recognition result can be "small", the second type of size can be "medium", and the third type of size can be "large".
[0094] Specifically, after the server 200 analyzes and obtains the first pixel information of the first image area and the second pixel information of the second image area, it can predict the size category of the target object information in the image to be identified based on the first pixel information and the second pixel information, and then determine the relative size of the target object in the image to be identified. At this time, the relative size refers to the actual size of the reference object. In other words, the actual size of the reference object usually remains unchanged, and the server 200 can analyze the first pixel information and the second pixel information to determine the size of the target object relative to the reference object. The size identification steps involved in this embodiment will be described in detail below.
[0095] In one embodiment, Figure 7 As shown, this step includes: S701, obtaining a first pixel value in the first pixel information and a second pixel value in the second pixel information; S702, calculating the product of the first pixel value and a preset ratio value to obtain a size recognition threshold; S703, predicting the size category of the target object in the image to be recognized according to the size recognition threshold and the second pixel value, and obtaining a size recognition result of the target object.
[0096] The preset ratio value is set according to actual business needs and acts on the value of the first pixel value, for example, 0.1, 0.2, 0.5, etc.
[0097] Specifically, the wide side pixel value in the first image area obtained by the server 200 is the first pixel value in its first pixel information, which can be expressed as "h". It should be noted that the present application proposes to use the wide side pixel information in the first image area as the first pixel information instead of the long side pixel information. The reason is that when the method proposed in the present application is applied to the express sorting scenario in the logistics field, since different sizes of express have different sorting systems, that is, the sorting methods are different, all express, including boxed and bagged express, should be differentiated by size before being put on the sorting line, so as to screen out small express and non-small express. Therefore, in practical applications, the sorting line belt conveyor can be selected as a reference object for analyzing the size of express delivery. The structure and composition of the sorting line belt conveyor are well known. It is a long strip device with a fixed width and unlimited length. Therefore, if image acquisition is performed on it, its wide side pixels in the image should be fixed, while the long side pixels depend on the acquisition range of the image, that is, the smaller the acquisition range, the smaller the long side pixels, and the larger the acquisition range, the larger the long side pixels. Therefore, the present application proposes to use the wide side pixel information of the image area of the sorting line belt conveyor in the image as the first pixel information, so that it is not affected by the viewing angle range of the camera to capture the image. The selection of the sorting line belt conveyor as a reference object also takes into account the operating steps in the actual application scenario, that is, selecting the sorting line belt conveyor instead of other equipment is conducive to identifying the size of the express when the express sorting is started, improving the recognition efficiency of the express size, and thus improving the express sorting efficiency.
[0098] More specifically, after the server 200 obtains the first pixel value "h" of the first image area, it can multiply it with the preset ratio value to obtain a size recognition threshold, and then use the size recognition threshold to compare with the second pixel value, so as to predict the size category of the target object in the image to be recognized, and finally obtain the size recognition result of the target object. However, it should be noted that the number of size recognition thresholds involved in the embodiments of the present application is not limited, and one or more size recognition thresholds can be set according to the size category of the target object to be distinguished, that is, when there is only one size recognition threshold, the size recognition results of the target object should include two types; when there are only two size recognition thresholds, the size recognition results of the target object should include three types, and so on.
[0099] In one embodiment, Figure 8 As shown, the size recognition threshold includes a first size recognition threshold and a second size recognition threshold, the first size recognition threshold is less than the second size recognition threshold, and the step of predicting the size category of the target object in the image to be recognized based on the size recognition threshold and the second pixel value to obtain the size recognition result of the target object includes: S801, when the second pixel value is less than the first size recognition threshold, determining that the size recognition result of the target object information relative to the reference object information is a first type of size; S802, when the second pixel value is between the first size recognition threshold and the second size recognition threshold, determining that the size recognition result of the target object information relative to the reference object information is a second type of size; S803, when the second pixel value is greater than the second size recognition threshold, determining that the size recognition result of the target object information relative to the reference object information is a third type of size.
[0100] Among them, the first size, the second size, and the third size can be categories with increasing sizes or decreasing sizes, for example, the first size is "small", the second size is "medium", the third size is "large", etc. In addition, descriptions other than "small", "medium", and "large" can be used, that is, actual size values can be used to distinguish ranges, such as the first size is "0-5", the second size is "5-10", and the third size is "10-15", etc.
[0101] The first size recognition threshold and the second size recognition threshold are thresholds calculated by different preset ratio values. For example, when the preset ratio value is "0.2", the first size recognition threshold is "0.2h", and when the preset ratio value is "0.5", the first size recognition threshold is "0.5h". It can be understood that the first pixel value "h" should be a positive integer, such as "400".
[0102] Specifically, the server 200 obtains the second pixel value and the size recognition threshold, and can compare the values of the two to determine the size recognition result of the target object. In this embodiment, the example size recognition threshold includes two, namely, the first size recognition threshold and the second size recognition threshold, and the first size recognition threshold is less than the second size recognition threshold, then the numerical ranges divided by the first size recognition threshold and the second size recognition threshold are respectively a numerical range less than the first size recognition threshold, a numerical range between the first size recognition threshold and the second size recognition threshold, and a numerical range greater than the second size recognition threshold, and these three numerical ranges correspond to three size types: the first size, the second size, and the third size, and each numerical range is a positive number, so the first size, the second size, and the third size in this embodiment are categories with increasing size values.
[0103] More specifically, the first size recognition threshold is expressed as "0.2h", the second size recognition threshold is expressed as "0.5h", and the second pixel value is expressed as "L". The calculation method of "L" has been described in detail above and will not be repeated here. Therefore, the comparison results between the second pixel value and the first size recognition threshold and the second size recognition threshold, respectively, can be: (1) when L < 0.2h, the size recognition result of the target object is the first type of size; (2) when 0.2h ≤ L ≤ 0.5h, the size recognition result of the target object is the second type of size; (3) when L > 0.5h, the size recognition result of the target object is the third type of size.
[0104] For example, "h=400", then "0.2h=80", "0.5h=200", if L is 50 at this time, the target object is express delivery, and the reference object is the sorting line belt conveyor, then the size recognition result of the target object "express delivery" is the first category size "small items"; if L is 100 at this time, the target object is express delivery, and the reference object is the sorting line belt conveyor, then the size recognition result of the target object "express delivery" is the second category size "medium items" (also called larger small items); if L is 500 at this time, the target object is express delivery, and the reference object is the sorting line belt conveyor, then the size recognition result of the target object "express delivery" is the third category size "large items" (also called non-small items).
[0105] In the above-mentioned object size recognition method, by obtaining the first image area containing the reference object information and the second image area containing the target object information in the image to be recognized, the first pixel information of the first image area and the second pixel information of the second image area can be used to predict the size category of the target object information in the image to be recognized, and finally the size recognition result of the target object information relative to the reference object information is obtained by analysis, that is, the size of the target object in the image to be recognized is determined. Since the present application proposes to introduce a comprehensive analysis of the reference object while recognizing the size of the target object, and the actual size of the reference object is fixed, the actual size of the target object can be accurately identified, and then the size classification of the target object can be realized. By adopting this method, the target object in the image is identified based on artificial intelligence technology, and the relative size of the reference object and the target object is analyzed to determine the actual size of the target object. This can not only improve the accuracy of the size recognition of the target object, but also improve the efficiency of the classification of large and small objects in actual business scenarios based on the rapid classification of the target object size, saving manpower and material resources.
[0106] In order to better implement the object size recognition method provided in the embodiment of the present application, on the basis of the object size recognition method provided in the embodiment of the present application, an object size recognition device is also provided in the embodiment of the present application, such as Fig. 9 As shown, the object size recognition device 900 includes:
[0107] An image acquisition module 910 is used to acquire a first image region and a second image region in an image to be identified, wherein the first image region contains reference object information, and the second image region contains target object information;
[0108] A pixel acquisition module 920 is used to acquire pixel information of the first image area and pixel information of the second image area, and obtain first pixel information of the first image area and second pixel information of the second image area;
[0109] The size recognition module 930 is used to predict the size category of the target object information in the image to be recognized based on the first pixel information and the second pixel information, and obtain a size recognition result of the target object information relative to the reference object information.
[0110] In some embodiments of the present application, the image acquisition module 910 is also used to acquire an image to be identified; use a preset trained object size recognition model to perform object information recognition on the image to be identified, and obtain reference object information and target object information in the image to be identified; acquire a first image area in the image to be identified based on the reference object information, and acquire a second image area in the image to be identified based on the target object information.
[0111] In some embodiments of the present application, the image acquisition module 910 is also used to construct an initial object size recognition model; acquire an object image set, and divide the object image set into a training set and a test set; the object image set includes a plurality of object images that have been labeled with the reference object information and the target object information; use the training set to perform preliminary training on the initial object size recognition model to obtain a preliminarily trained object size recognition model; use the test set to test and adjust the preliminarily trained object size recognition model to obtain a trained object size recognition model.
[0112] In some embodiments of the present application, the pixel acquisition module 920 is also used to acquire pixel information of the first image area and pixel information of the second image area, the pixel information of the first image area includes long side pixel information and wide side pixel information, and the pixel information of the second image area includes maximum pixel value and minimum pixel value; based on the wide side pixel information, the first pixel information of the first image area is determined; based on the maximum pixel value and the minimum pixel value, the second pixel information of the second image area is determined.
[0113] In some embodiments of the present application, the pixel acquisition module 920 is also used to determine the first-axis coordinate and the second-axis coordinate corresponding to the pixel maximum value as the pixel maximum value coordinates, and to determine the first-axis coordinate and the second-axis coordinate corresponding to the pixel minimum value as the pixel minimum value coordinates, the first-axis coordinate is the X-axis coordinate, and the second-axis coordinate is the Y-axis coordinate; based on the Euclidean distance algorithm, the coordinate distance between the minimum value coordinate and the pixel maximum value coordinate is calculated to obtain the second pixel information of the second image area.
[0114] In some embodiments of the present application, the size recognition module 930 is also used to obtain a first pixel value in the first pixel information and a second pixel value in the second pixel information; calculate the product of the first pixel value and a preset ratio value to obtain a size recognition threshold; and predict the size category of the target object in the image to be identified based on the size recognition threshold and the second pixel value to obtain a size recognition result of the target object.
[0115] In some embodiments of the present application, the size recognition threshold includes a first size recognition threshold and a second size recognition threshold, the first size recognition threshold is less than the second size recognition threshold, and the size recognition module 930 is further used to determine that the size recognition result of the target object information relative to the reference object information is a first type of size when the second pixel value is less than the first size recognition threshold; when the second pixel value is between the first size recognition threshold and the second size recognition threshold, determine that the size recognition result of the target object information relative to the reference object information is a second type of size; when the second pixel value is greater than the second size recognition threshold, determine that the size recognition result of the target object information relative to the reference object information is a third type of size.
[0116] In the above embodiment, by obtaining the first image area containing the reference object information and the second image area containing the target object information in the image to be identified, the first pixel information of the first image area and the second pixel information of the second image area can be used to predict the size category of the target object information in the image to be identified, and finally the size recognition result of the target object information relative to the reference object information is obtained by analysis, that is, the size of the target object in the image to be identified is determined. Since the present application proposes to introduce a comprehensive analysis of the reference object while identifying the size of the target object, and the actual size of the reference object is fixed, the actual size of the target object can be accurately identified, and then the size classification of the target object can be achieved. By adopting the scheme provided by the present application, the target object in the image is identified based on artificial intelligence technology, and the relative size of the reference object and the target object is analyzed to determine the actual size of the target object, which can not only improve the accuracy of the size recognition of the target object, but also improve the efficiency of the classification of large and small objects in actual business scenarios based on the rapid classification of the target object size, saving manpower and material resources.
[0117] In some embodiments of the present application, the object size recognition device 900 can be implemented in the form of a computer program. The computer program can be implemented in Fig.10 The computer device shown in the figure is run on the computer device. The memory of the computer device can store various program modules constituting the object size recognition device 900, for example, Fig. 9 The image acquisition module 910, the pixel acquisition module 920 and the size recognition module 930 are shown. The computer program composed of various program modules enables the processor to execute the steps of the object size recognition method of each embodiment of the present application described in this specification.
[0118] For example, Fig.10 The computer device shown can be Fig. 9The image acquisition module 910 in the object size recognition device 900 shown executes step S201. The computer device can execute step S202 through the pixel acquisition module 920. The computer device can execute step S203 through the size recognition module 930. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external computer device through a network connection. When the computer program is executed by the processor, an object size recognition method is implemented.
[0119] Those skilled in the art will understand that Fig.10 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0120] In some embodiments of the present application, a computer device is provided, comprising one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor in the steps of the object size recognition method. The steps of the object size recognition method here may be the steps of the object size recognition method in the above-mentioned embodiments.
[0121] In some embodiments of the present application, a computer-readable storage medium is provided, which stores a computer program, and the computer program is loaded by a processor, so that the processor executes the steps of the above-mentioned object size recognition method. The steps of the object size recognition method here can be the steps of the object size recognition method in each of the above-mentioned embodiments.
[0122] The above is a detailed introduction to an object size recognition method, device, computer equipment and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for identifying object size, characterized in that: The method comprises: Acquire a first image region and a second image region in an image to be identified, wherein the first image region contains reference object information, and the second image region contains target object information; Acquire pixel information of the first image area and pixel information of the second image area to obtain first pixel information of the first image area and second pixel information of the second image area; Acquire a first pixel value in the first pixel information and a second pixel value in the second pixel information, wherein the first pixel value represents a wide side pixel value of the first image area, and the second pixel value represents a minimum circumscribed circle diameter of the second image area; Calculating the product of the first pixel value and a preset ratio value to obtain a size recognition threshold; The size category of the target object in the image to be identified is predicted according to the size recognition threshold and the second pixel value to obtain a size recognition result of the target object.
2. The object size recognition method according to claim 1, characterized in that: The step of acquiring the first image area and the second image area in the image to be recognized comprises: Obtain an image to be recognized; Using a preset trained object size recognition model, performing object information recognition on the image to be recognized, and obtaining reference object information and target object information in the image to be recognized; A first image region in the image to be identified is acquired according to the reference object information, and a second image region in the image to be identified is acquired according to the target object information.
3. The object size recognition method according to claim 2, characterized in that: Before using the preset trained object size recognition model to perform object information recognition on the image to be recognized and obtaining reference object information and target object information in the image to be recognized, the method further includes: Build an initial object size recognition model; Acquire an object image set, and divide the object image set into a training set and a test set; the object image set includes a plurality of object images annotated with the reference object information and the target object information; Performing preliminary training on the initial object size recognition model using the training set to obtain a preliminary trained object size recognition model; The test set is used to test and adjust the initially trained object size recognition model to obtain a trained object size recognition model.
4. The object size recognition method according to claim 1, characterized in that: The step of acquiring pixel information of the first image area and pixel information of the second image area to obtain first pixel information of the first image area and second pixel information of the second image area comprises: Acquire pixel information of the first image area and pixel information of the second image area, wherein the pixel information of the first image area includes long side pixel information and wide side pixel information, and the pixel information of the second image area includes a maximum pixel value and a minimum pixel value; Determining first pixel information of the first image area according to the broadside pixel information; Second pixel information of the second image area is determined according to the maximum pixel value and the minimum pixel value.
5. The object size recognition method according to claim 4, characterized in that: The step of determining second pixel information of the second image area according to the maximum pixel value and the minimum pixel value comprises: Determine the first axis coordinate and the second axis coordinate corresponding to the pixel maximum value as the pixel maximum value coordinate, and determine the first axis coordinate and the second axis coordinate corresponding to the pixel minimum value as the pixel minimum value coordinate, the first axis coordinate is the X axis coordinate, and the second axis coordinate is the Y axis coordinate; Based on the Euclidean distance algorithm, the coordinate distance between the minimum value coordinate and the pixel maximum value coordinate is calculated to obtain the second pixel information of the second image area.
6. The object size recognition method according to claim 1, characterized in that: The size recognition threshold includes a first size recognition threshold and a second size recognition threshold, the first size recognition threshold is less than the second size recognition threshold, and the step of performing size category prediction on the target object in the image to be recognized according to the size recognition threshold and the second pixel value to obtain a size recognition result of the target object includes: When the second pixel value is less than the first size recognition threshold, determining that a size recognition result of the target object information relative to the reference object information is a first type of size; When the second pixel value is between the first size recognition threshold and the second size recognition threshold, determining that the size recognition result of the target object information relative to the reference object information is a second type of size; When the second pixel value is greater than the second size recognition threshold, it is determined that a size recognition result of the target object information relative to the reference object information is a third type of size.
7. An object size recognition device, characterized in that: The device comprises: An image acquisition module, used to acquire a first image area and a second image area in an image to be identified, wherein the first image area contains reference object information, and the second image area contains target object information; A pixel acquisition module, used to acquire pixel information of the first image area and pixel information of the second image area, to obtain first pixel information of the first image area and second pixel information of the second image area; The size recognition module is used to obtain a first pixel value in the first pixel information and a second pixel value in the second pixel information, wherein the first pixel value represents a wide side pixel value of the first image area, and the second pixel value represents a minimum circumscribed circle diameter of the second image area; calculate the product of the first pixel value and a preset ratio value to obtain a size recognition threshold; and predict the size category of a target object in the image to be recognized based on the size recognition threshold and the second pixel value to obtain a size recognition result of the target object.
8. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the object size recognition method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the object size recognition method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image processing method and device and related device
CN109165645A