Model training and obstacle detection method and device and automatic driving vehicle
By normalizing the focal length of the obstacle spatial coordinates collected by the image sensor, the model is trained to adapt to the image sensors of different cameras, which solves the problem of inaccurate model predictions for different camera images in autonomous driving technology and improves obstacle depth prediction. accuracy and model generalization ability.
Patent Information
- Application Number
- CN202410732563.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-09-10
AI Technical Summary
In existing autonomous driving technology, model training only supports the use of cameras with the same internal parameters to collect images, and cannot effectively utilize sample images from different cameras, resulting in inaccurate model predictions of obstacle depths in images collected by various cameras.
By obtaining the spatial coordinates of the sample obstacles collected by the image sensor, perform normalization based on the focal length, obtain the normalized depth value, train the preset model, and calculate the depth value of the obstacle to ensure the model's generalization ability and accurate prediction. sex.
It achieves the accuracy of the model in predicting the depth of obstacles in images collected by different cameras, improves the generalization ability of the deep learning neural network, and avoids the impact of camera internal parameters on model training.
Smart Images

Figure CN118629005A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of autonomous driving technology, and in particular to technical fields such as artificial intelligence, model training, and intelligent transportation. Background Art
[0002] In the field of autonomous driving, models are usually used to detect images captured by cameras to obtain the spatial position of obstacles, especially the depth or distance of obstacles. In order to ensure the accuracy of model prediction, a large number of sample images are required when training the model. However, the relevant technology only supports the use of sample images captured by cameras with the same intrinsic parameters for model training. Therefore, how to use sample images from multiple cameras (different cameras can have different intrinsic parameters) to train the model, avoid the model training being affected by the intrinsic parameters of different cameras, and then ensure that the final model can accurately predict the spatial position (especially depth or distance) of obstacles for images captured by various cameras, becomes a problem that needs to be solved. Summary of the invention
[0003] The present invention provides a model training and obstacle detection method, device, electronic device, storage medium and autonomous driving vehicle.
[0004] According to one aspect of the present disclosure, a model training method is provided, comprising:
[0005] Acquire the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor;
[0006] Normalizing the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle;
[0007] The preset model is trained based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
[0008] According to another aspect of the present disclosure, there is provided an obstacle detection method, comprising:
[0009] Acquire the image to be detected collected by the target image sensor;
[0010] Inputting the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected;
[0011] A depth value of each obstacle is calculated based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
[0012] According to one aspect of the present disclosure, there is provided a model training device, comprising:
[0013] A spatial coordinate acquisition module, used to acquire the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor;
[0014] A normalization processing module, configured to normalize the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle;
[0015] The model training module is used to train the preset model based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
[0016] According to another aspect of the present disclosure, there is provided an obstacle detection device, comprising:
[0017] The image acquisition module to be detected is used to obtain the image to be detected collected by the target image sensor;
[0018] A prediction module, used for inputting the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected;
[0019] The obstacle depth calculation module is used to calculate the depth value of each obstacle based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
[0020] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0021] at least one processor; and
[0022] a memory communicatively connected to the at least one processor; wherein,
[0023] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any embodiment of the present disclosure.
[0024] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method according to any embodiment of the present disclosure.
[0025] According to another aspect of the present disclosure, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method according to any one of the embodiments of the present disclosure is implemented.
[0026] According to another aspect of the present disclosure, an autonomous driving vehicle is provided, comprising the above-mentioned electronic device.
[0027] By adopting the above scheme, the depth of the sample obstacle contained in the sample image is normalized based on the focal length of the image sensor that collects the sample image. In this way, when the normalized depth of the sample obstacle is used to train the preset model, the influence of the internal parameters of the image sensor such as the focal length on the model training stage can be avoided, so that the model training stage can learn sample images from different image sensors, improve the generalization ability of the deep learning neural network, and further ensure that the trained target model is not affected by the focal length of the camera, and accurately predicts the normalized depth of obstacles for images from various image sensors, ultimately ensuring the accuracy of the model prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0029] Figure 1 is a flowchart of a model training method according to an embodiment of the present disclosure;
[0030] Figure 2 is a flow chart of an obstacle detection method according to an embodiment of the present disclosure;
[0031] Figure 3 is a schematic diagram of the structure of a model training device according to an embodiment of the present disclosure;
[0032] Figure 4 is a schematic diagram of the structure of a model training device according to another embodiment of the present invention;
[0033] Figure 5 is a schematic diagram of the structure of a model training device according to another embodiment of the present invention;
[0034] Figure 6 is a schematic diagram of the structure of a model training device according to another embodiment of the present invention;
[0035] Figure 7 is a schematic diagram of the structure of an obstacle detection device according to an embodiment of the present disclosure;
[0036] Figure 8 is a schematic diagram of the structure of an obstacle detection device according to another embodiment of the present disclosure;
[0037] Fig. 9is a block diagram of an electronic device for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0038] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0039] In one aspect, an embodiment of the present disclosure provides a model training method, such as Figure 1 As shown, including:
[0040] S101, obtaining the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor.
[0041] S102: Normalize the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle.
[0042] S103: Training a preset model based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
[0043] The above-mentioned model training method can be implemented by an electronic device. The electronic device can be a terminal or a server. Exemplarily, the electronic device can be a vehicle-mounted terminal, or other terminal device with computing capabilities. Exemplarily, the server can be a single server, or it can be one or more servers in a server cluster, or it can be a server in a distributed system (or it can be called a computing node). It should be understood that the above is only an exemplary description of the execution subject that can execute the model training method provided in this embodiment. In actual processing, it may not be limited to the device types mentioned in the above examples. As long as the electronic device that can execute the model training method provided in this embodiment is within the protection scope of this embodiment.
[0044] By adopting the above scheme, the depth of the sample obstacle contained in the sample image is normalized based on the focal length of the image sensor that collects the sample image. In this way, when the normalized depth of the sample obstacle is used to train the preset model, the influence of the internal parameters of the image sensor such as the focal length on the model training stage can be avoided, so that the model training stage can learn sample images from different image sensors, improve the generalization ability of the deep learning neural network, and further ensure that the trained target model is not affected by the focal length of the camera, and accurately predicts the normalized depth of obstacles for images from various image sensors, ultimately ensuring the accuracy of the model prediction results.
[0045] In some possible implementations, acquiring the spatial coordinates of each of the one or more sample obstacles contained in the sample image may include: acquiring a sample image acquired by an image sensor at a first acquisition position at a first moment; acquiring the spatial coordinates of each of the one or more optional obstacles detected by the position sensor at the first acquisition position at a first moment; and determining one or more sample obstacles from all initial obstacles contained in the sample image based on each optional obstacle and its spatial coordinates, and determining the spatial coordinates of each sample obstacle contained in the sample image.
[0046] The image sensor may be any device or sensor with an image acquisition function. Preferably, the image sensor may be any one of a monocular camera, a monocular camera head, etc.; accordingly, the sample image may be a monocular sample image.
[0047] The position sensor may be any sensor having a spatial coordinate detection function. For example, the position sensor may be a radar, such as a laser radar, a millimeter wave radar, etc., and all possible types of position sensors or radars are not limited or enumerated here.
[0048] The first acquisition position and the first time can be determined according to actual conditions, and this embodiment does not limit them. That is, the image sensor and the position sensor simultaneously acquire data at the same position to obtain the sample image and the spatial coordinates of at least one sample obstacle.
[0049] Specifically, the image sensor and the position sensor can be co-located at the same position of the target device and facing the same direction. The target device can be a fixed device whose position does not change, or a movable device whose position can change, for example, the movable device can include any one of a vehicle, an autonomous vehicle, an unmanned vehicle, a drone, etc. This application does not limit or exhaust all possible types of target devices.
[0050] The detection ranges of the position sensor and the image sensor may be the same or different. For example, the detection range of the position sensor may be 120 meters, 150 meters, or 200 meters, etc., and the detection range of the image sensor may be greater than 200 meters, such as 300 meters or greater. The detection ranges of the position sensor and the image sensor are not limited or exhaustive here.
[0051] In the embodiment of the present application, obstacles with spatial coordinates detected by the position sensor are referred to as optional obstacles, and obstacles whose images can be detected by the image sensor are referred to as initial obstacles.
[0052] In some examples, the detection ranges of the position sensor and the image sensor may be different. In this case, the optional obstacles may not be exactly the same as the initial obstacles; for example, assuming that the sensing detection range of the position sensor is smaller than the image detection range of the image sensor, the number of initial obstacles may be greater than or equal to the number of optional obstacles.
[0053] The determining, based on each optional obstacle and its spatial coordinates, one or more sample obstacles from all initial obstacles included in the sample image, and determining the spatial coordinates of each sample obstacle included in the sample image may refer to: determining, from the one or more initial obstacles, one or more matching obstacles that match the one or more optional obstacles; using the one or more matching obstacles as the one or more sample obstacles included in the sample image, and using the spatial coordinates of each matching obstacle as the spatial coordinates of each sample obstacle in the one or more sample obstacles included in the sample image.
[0054] Among them, determining one or more matching obstacles that match the one or more optional obstacles from the one or more initial obstacles may be as follows: determining whether the i-th initial obstacle matches (or is the same as) any one of the one or more optional obstacles; if it matches (or is the same as) any one of the one or more optional obstacles, determining that the i-th initial obstacle is a matching obstacle; if it does not match (or is not the same as) any one of the one or more optional obstacles, determining that the i-th initial obstacle is not a matching obstacle, i is an integer greater than or equal to 1, and the i-th initial obstacle is any one of the one or more initial obstacles. Since the processing of each initial obstacle in the one or more initial obstacles is the same as that of the i-th initial obstacle, they will not be described one by one.
[0055] For example, assuming that the image sensor can collect a sample image with a range greater than 200 meters, the sample image includes 10 initial obstacles, the position sensor can detect the spatial coordinates of 6 optional obstacles within a range of 120 meters, and the 10 initial obstacles in the sample image include these 6 optional obstacles, which are 6 matching obstacles. Finally, the spatial coordinates of these 6 matching obstacles can be used as the spatial coordinates of the 6 sample obstacles contained in the sample image. In other words, there are still 4 initial obstacles in the sample image that are far away (i.e., beyond the detection range of the position sensor), so accurate spatial coordinates cannot be obtained, that is, only the sample obstacles at a close distance (i.e., within the detection range of the position sensor) in the sample image may have corresponding spatial coordinates. It should be understood that this is only an exemplary description, and in actual processing, the initial obstacles contained in the sample image may all have corresponding spatial coordinates, and this embodiment does not limit or exhaust all possibilities.
[0056] In some examples, the detection range of the position sensor and the image sensor may be the same, in which case the optional obstacle and the initial obstacle may be the same. In this example, based on each optional obstacle and its spatial coordinates, one or more sample obstacles are determined from all the initial obstacles contained in the sample image, and the processing method of determining the spatial coordinates of each sample obstacle contained in the sample image may be the same as the above example, and will not be repeated here.
[0057] In some possible implementations, normalizing the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain the normalized depth value of each sample obstacle may include: dividing the depth value in the spatial coordinates of the nth sample obstacle by the focal length of the image sensor to obtain the normalized normalized depth value of the nth sample obstacle, wherein n is an integer greater than or equal to 1, and the nth sample obstacle is any one of the one or more sample obstacles included in the sample image. Since the manner of obtaining the normalized depth value by processing each sample obstacle included in the sample image is the same as that of the nth sample obstacle, they are not described one by one.
[0058] Among them, the spatial coordinates of the nth sample obstacle may include the three-dimensional (3D, Three Dimensions) information of the nth sample obstacle in the spatial coordinate system. The spatial coordinate system may include coordinate axes in three directions with the position sensor as the origin, wherein the three directions may be the orientation direction of the position sensor, the horizontal direction (along the horizontal plane, which may be to the right or to the left), and the vertical direction (the direction perpendicular to the horizontal plane). Accordingly, the spatial coordinates of the nth sample obstacle may refer to the position (or coordinate) in the horizontal direction, the position (or coordinate) in the vertical direction, and the position (or coordinate) in the orientation direction of the position sensor in the spatial coordinate system, wherein the position (or coordinate) in the orientation direction of the position sensor is the depth value of the nth sample obstacle.
[0059] For example, the position of the position sensor and the image sensor (the position sensor and the image sensor are in the same position) is used as the origin of the spatial coordinate system, the orientation of the sensor (the position sensor and the image sensor are in the same orientation) is used as the z-axis of the spatial coordinate system, the horizontal direction (either left or right) is used as the x-axis of the spatial coordinate system, and the vertical direction is used as the y-axis of the spatial coordinate system. The spatial coordinates of the nth sample obstacle may include the position (or coordinate) on the x-axis, the position (or coordinate) on the y-axis, and the position (or coordinate) on the z-axis in the spatial coordinate system, i.e., the depth value of the nth sample obstacle. It should be understood that this is only an exemplary description, and the coordinate axes of the three directions of the spatial coordinate system in actual processing may be different from the above examples, and are not limited or exhaustive here.
[0060] For another example, suppose the depth value of the nth sample obstacle is represented as z c_n , the focal length of the image sensor is represented as f, and the normalized depth value of the nth sample obstacle is represented as z c_n _f, the normalized depth value can be calculated using the following formula: c_n _f=z c_n / f.
[0061] In some possible implementations, the preset model is trained based on the sample image and the normalized depth value of each sample obstacle to obtain the target model, including: inputting the sample image into the preset model to obtain a prediction result output by the preset model, wherein the prediction result includes the normalized predicted depth of each predicted obstacle among one or more predicted obstacles contained in the sample image; calculating the depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle; and training the preset model based on the depth loss to obtain the target model.
[0062] In this implementation, the normalized depth value of each sample obstacle may be used as a training label corresponding to the sample image.
[0063] The one or more predicted obstacles included in the prediction result may be all the initial obstacles in the sample image. That is, the preset model may predict each initial obstacle in the sample image, thereby outputting a prediction result containing the normalized predicted depth of all the initial obstacles. For example, if the sample image contains 10 initial obstacles, the prediction result may include 10 predicted obstacles.
[0064] The above embodiments have explained that, since the detection ranges of the position sensor and the image sensor may be different, not all the initial obstacles contained in the sample image are necessarily the sample obstacles in the training label. The calculation of the depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle may refer to: determining the sample obstacle corresponding to each predicted obstacle; and calculating the depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of the sample obstacle corresponding to each predicted obstacle.
[0065] By adopting the solution provided in this embodiment, the depth loss is learned based on the normalized predicted depth of the predicted obstacle output by the preset model and the normalized depth of the sample obstacle during model training, and then the preset model is trained based on the depth loss direction. Through such a training method, the preset model can more accurately learn the normalized depth of the obstacles in the image, thereby ensuring the accuracy of the prediction results of the trained target model.
[0066] In some possible implementations, the method further includes: obtaining relevant information of the two-dimensional detection frame of each sample obstacle. The prediction result also includes relevant prediction information of the two-dimensional detection frame of each predicted obstacle. The calculation of the depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle includes: determining the predicted obstacle corresponding to each sample obstacle based on the relevant prediction information of the two-dimensional detection frame of each predicted obstacle and the relevant information of the two-dimensional detection frame of each sample obstacle; and calculating the depth loss based on the normalized predicted depth of the predicted obstacle corresponding to each sample obstacle and the normalized depth of each sample obstacle.
[0067] The above embodiments have explained that one or more predicted obstacles included in the prediction result may be all the initial obstacles in the sample image, and the sample obstacles included in the sample image may be part or all of all the initial obstacles. Therefore, this embodiment can combine the relevant prediction information of the two-dimensional detection frame of the predicted obstacle and the relevant information of the two-dimensional detection frame of the sample obstacle to determine the predicted obstacle corresponding to each sample obstacle; and there may be a part of the predicted obstacles in the prediction result that do not have corresponding sample obstacles, and this part of the predicted obstacles may not be used to calculate the depth loss.
[0068] The relevant information of the two-dimensional detection frame of each sample obstacle in the sample image may also be included in the training label corresponding to the sample image. The relevant information of the two-dimensional detection frame of each sample obstacle may include at least one of the following: the center point of the two-dimensional detection frame of each sample obstacle, the width of the two-dimensional detection frame of each sample obstacle, and the height of the two-dimensional detection frame of each sample obstacle.
[0069] Furthermore, the two-dimensional detection frame of any sample obstacle may refer to: the two-dimensional detection frame of the sample obstacle in the coordinate system of the image sensor (which may be referred to as the camera coordinate system). The coordinate system of the image sensor may include coordinate axes in two directions with the specified position in the image as the origin, wherein the two directions may be the horizontal direction (such as the horizontal direction of the image) and the vertical direction (such as the vertical direction of the image), and the specified position may be configured according to actual conditions, such as the lower left corner of the image, or the middle of the image, etc., and the specified position is not limited or exhaustive here. The center point of the two-dimensional detection frame of any sample obstacle may refer to the horizontal position (or coordinate) and the vertical position (or coordinate) of the center point of the two-dimensional detection frame of the sample obstacle in the camera coordinate system; the width of the two-dimensional detection frame of any sample obstacle may refer to the width of the sample obstacle in the horizontal direction in the camera coordinate system; the height of the two-dimensional detection frame of any sample obstacle may refer to the height of the sample obstacle in the vertical direction in the camera coordinate system.
[0070] The relevant prediction information of the two-dimensional detection frame of each predicted obstacle may include at least one of the following: the predicted center point of the two-dimensional detection frame of each predicted obstacle, the predicted width of the two-dimensional detection frame of each predicted obstacle, and the predicted height of the two-dimensional detection frame of each predicted obstacle. The relevant prediction information of the two-dimensional detection frame of the predicted obstacle is similar to the description of the relevant information of the two-dimensional detection frame of the sample obstacle, and is not repeated here.
[0071] The determining the predicted obstacle corresponding to each sample obstacle based on the relevant prediction information of the two-dimensional detection frame of each predicted obstacle and the relevant information of the two-dimensional detection frame of each sample obstacle may include: judging whether the relevant prediction information of the two-dimensional detection frame of the m-th predicted obstacle exists in the training label corresponding to the sample image, and if the relevant prediction information of the two-dimensional detection frame of the m-th predicted obstacle is the same as the relevant information of the two-dimensional detection frame of the n-th sample obstacle, then determining that the m-th predicted obstacle is the predicted obstacle corresponding to the n-th sample obstacle; if the relevant prediction information of the two-dimensional detection frame of the m-th predicted obstacle is different from the relevant information of the two-dimensional detection frame of each sample obstacle, then determining that the m-th predicted obstacle does not have a corresponding sample obstacle in the training label corresponding to the sample image. Wherein, m and n are both integers greater than or equal to 1, the m-th predicted obstacle is any one of all the predicted obstacles, and the n-th sample obstacle is any one of all the sample obstacles. The same processing as that of the mth predicted obstacle is performed for each predicted obstacle, and finally the predicted obstacle corresponding to each sample obstacle can be obtained. The processing of each predicted obstacle will not be described one by one here.
[0072] Calculating the depth loss based on the normalized predicted depth of the predicted obstacle corresponding to each sample obstacle and the normalized depth of each sample obstacle may include: calculating the nth depth sub-loss based on the normalized predicted depth of the predicted obstacle corresponding to the nth sample obstacle and the normalized depth of the nth sample obstacle; judging whether there are remaining sample obstacles, and if there are no remaining sample obstacles, calculating the depth loss based on the nth depth sub-losses. In addition, it may also include: if there are remaining sample obstacles, selecting the n+1th sample obstacle from the remaining sample obstacles, and continuing to calculate the n+1th depth sub-loss based on the normalized predicted depth of the predicted obstacle corresponding to the n+1th sample obstacle and the normalized depth of the n+1th sample obstacle, and so on, until all depth sub-losses are calculated, and calculating the depth loss based on all depth sub-losses. Wherein, the n+1th sample obstacle is any one of all sample obstacles, and the n+1th sample obstacle is different from the nth sample obstacle.
[0073] The calculation of the nth depth sub-loss based on the normalized predicted depth of the predicted obstacle corresponding to the nth sample obstacle and the normalized depth of the nth sample obstacle can be as follows: calculating the distance between the normalized predicted depth of the predicted obstacle corresponding to the nth sample obstacle and the normalized depth of the nth sample obstacle to obtain the nth depth sub-loss. Since the calculation method for calculating the corresponding depth sub-loss for each sample obstacle and its corresponding predicted obstacle is the same, it will not be described one by one. Among them, the specific method of calculating the normalized predicted depth of the predicted obstacle corresponding to the nth sample obstacle and the normalized depth of the nth sample obstacle is not limited in this embodiment. For example, it can be to calculate the difference between the normalized predicted depth of the predicted obstacle corresponding to the nth sample obstacle and the normalized depth of the nth sample obstacle, etc.
[0074] The calculation of the depth loss based on the n depth sub-losses may be to calculate the depth loss on the n depth sub-losses using a first loss function. The first loss function may be configured according to actual conditions, such as using a calculation function of the sum of all absolute differences between the true value and the predicted value, or using a calculation function of the sum of all square differences between the true value and the predicted value, etc. All possible function types of the first loss function are not limited or enumerated here.
[0075] In this way, by using the sample image and the normalized depth of each sample obstacle to train the preset model, the preset model can learn the relationship between obstacles at different positions in the sample image and the normalized depth, so that the trained target model can more accurately analyze the obstacles in the image to obtain the normalized depth, thereby ensuring that a more accurate depth value of the obstacle can be obtained in the end. Specifically, the training label corresponding to the sample image may only contain the spatial coordinates of the close-range sample obstacle and the relevant information of the corresponding two-dimensional detection frame. When the preset model is trained using the sample image and the training label, the preset model can learn the relationship between the normalized depth value of the sample obstacle at different positions and the two-dimensional detection frame. The trained target model can generalize the relationship between the two-dimensional detection frame and the normalized depth of the obstacle to obstacles at a long distance, thereby improving the generalization ability of the deep learning neural network, thereby achieving more accurate prediction of the normalized depth of obstacles at various positions (including close and long distances) in the image through the target model, ensuring that a more accurate depth value of the obstacle can be obtained in the end.
[0076] In some possible implementations, the method may further include: obtaining a three-dimensional projection center point of each sample obstacle in the coordinate system of the image sensor based on the spatial coordinates of each sample obstacle and the internal parameters of the image sensor; and obtaining a center point offset of each sample obstacle based on the three-dimensional projection center point of each sample obstacle and the center point of the two-dimensional detection box of each sample obstacle.
[0077] The center point offset of each sample obstacle in the sample image may also be included in the training label corresponding to the sample image.
[0078] Based on the spatial coordinates of each sample obstacle and the internal parameters of the image sensor, obtaining the three-dimensional projection center point of each sample obstacle in the coordinate system of the image sensor may include: dividing the horizontal coordinate in the spatial coordinates of the nth sample obstacle by the depth value of the nth sample obstacle to obtain the nth horizontal position value; dividing the vertical coordinate in the spatial coordinates of the nth sample obstacle by the depth value of the nth sample obstacle to obtain the nth vertical position value; and calculating the three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor based on the internal parameters of the image sensor, the nth horizontal position value, and the nth vertical position value, wherein the three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor may include: the horizontal three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor (or simply the horizontal three-dimensional projection center point of the nth sample obstacle), and the vertical three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor (or simply the vertical three-dimensional projection center point of the nth sample obstacle).
[0079] The internal parameters of the image sensor may be preconfigured, and the internal parameters of the image sensor may at least include the focal length of the image sensor, the optical center of the image sensor (or the position of the optical center, i.e., the position of the optical center in the coordinate system of the image sensor), etc. Here, all parameters that may be included in the internal parameters of the image sensor are not limited or exhaustive.
[0080] For example, based on the intrinsic parameters of the image sensor, the nth horizontal position value, and the nth vertical position value, the three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor can be calculated using the following formula:
[0081]
[0082] Among them, x c_n Represents the horizontal coordinate of the nth sample obstacle in the spatial coordinates, y c_n Represents the vertical coordinate of the nth sample obstacle in the spatial coordinates, zc_n Indicates the depth value of the nth sample obstacle. The focal length of the image sensor includes the horizontal focal length f x and the vertical focal length f y , the optical center of the image sensor includes the optical center or optical center position u0 in the horizontal direction and the optical center or optical center position v0 in the vertical direction; u _n represents the horizontal 3D projection center point of the nth sample obstacle in the coordinate system of the image sensor, v _n It represents the vertical three-dimensional projection center point of the nth sample obstacle in the coordinate system of the image sensor.
[0083] Obtaining the center point offset of each sample obstacle based on the three-dimensional projection center point of each sample obstacle and the center point of the two-dimensional detection frame of each sample obstacle may include: obtaining the center point horizontal offset (for example, expressed as △x ) corresponding to the nth sample obstacle based on the difference between the horizontal three-dimensional projection center point of the nth sample obstacle and the horizontal center point of the two-dimensional detection frame of the nth sample obstacle. _n ); Based on the difference between the vertical three-dimensional projection center point of the nth sample obstacle and the vertical center point of the two-dimensional detection frame of the nth sample obstacle, the vertical offset of the center point corresponding to the nth sample obstacle is obtained (for example, expressed as △y _n ).
[0084] Since the method for calculating the center point offset for each sample obstacle is the same as that for the nth sample obstacle, it will not be described in detail.
[0085] In this way, by calculating the center point offset of each sample obstacle in the coordinate system of the image sensor between the center point of the three-dimensional projection of each sample obstacle and the center point of the two-dimensional detection frame of each sample obstacle, the offset between the center point of the two-dimensional detection frame of each sample obstacle in the coordinate system of the image sensor and the position where the three-dimensional projection point should be located can be obtained. Training the preset model based on such features can enable the preset model to more accurately predict the position of the three-dimensional projection center point of each obstacle in the image.
[0086] In some possible implementations, the prediction result further includes: a predicted offset of the center point of each predicted obstacle. The training of the preset model based on the depth loss to obtain the target model includes: calculating the offset loss based on the predicted offset of the center point of the predicted obstacle corresponding to each sample obstacle and the offset of the center point of each sample obstacle; and training the preset model based on the depth loss and the offset loss to obtain the target model.
[0087] The predicted center point offset of each predicted obstacle is: the offset between the three-dimensional projection center point of each predicted obstacle in the coordinate system of the image sensor and the center point of the two-dimensional predicted detection box of each predicted obstacle in the sample image. Taking the mth predicted obstacle as an example, the predicted center point offset of the mth predicted obstacle may include: the horizontal offset of the center point corresponding to the mth predicted obstacle (for example, expressed as pre△x _m , "pre" means prediction), the vertical offset of the center point corresponding to the mth predicted obstacle (for example, expressed as pre△y _m ).
[0088] In this implementation manner, the method of determining the predicted obstacle corresponding to each sample obstacle is the same as that in the above-mentioned embodiment and will not be described in detail.
[0089] Calculating the offset loss based on the predicted center point offset of the predicted obstacle corresponding to each sample obstacle and the center point offset of each sample obstacle may include: calculating the nth offset quantum loss based on the predicted center point offset of the predicted obstacle corresponding to the nth sample obstacle and the center point offset of the nth sample obstacle; determining whether there are remaining sample obstacles, and if there are no remaining sample obstacles, calculating the offset loss based on n offset quantum losses. In addition, it may also include: if there are remaining sample obstacles, selecting the n+1th sample obstacle from the remaining sample obstacles, and continuing to calculate the n+1th offset quantum loss based on the predicted center point offset of the predicted obstacle corresponding to the n+1th sample obstacle and the center point offset of the n+1th sample obstacle, and so on, until all offset quantum losses are calculated, and calculating the offset loss based on all offset quantum losses.
[0090] The calculation of the nth offset quantum loss based on the predicted offset of the center point of the predicted obstacle corresponding to the nth sample obstacle and the offset of the center point of the nth sample obstacle can be: calculating the distance between the predicted offset of the center point of the predicted obstacle corresponding to the nth sample obstacle and the offset of the center point of the nth sample obstacle to obtain the nth offset quantum loss. Since the calculation method for calculating the corresponding offset quantum loss for each sample obstacle and its corresponding predicted obstacle is the same, it is not repeated one by one. Among them, the specific method of calculating the distance between the predicted offset of the center point of the predicted obstacle corresponding to the nth sample obstacle and the offset of the center point of the nth sample obstacle is not limited in this embodiment. For example, it can be to calculate the difference between the predicted offset of the center point of the predicted obstacle corresponding to the nth sample obstacle and the offset of the center point of the nth sample obstacle, etc.
[0091] The calculation of the offset loss based on the n offset quantum losses may be to use a first loss function to calculate the offset loss for the n offset quantum losses. The description of the first loss function is the same as that in the above embodiment and will not be repeated.
[0092] In this way, the preset model is trained by the center point offset of each sample obstacle and the predicted center point offset of each predicted obstacle. The preset model can learn the normalized depth of each obstacle while learning the relationship between the offset of the center point of the two-dimensional detection box of the obstacle in the coordinate system of the image sensor and the position where the three-dimensional projection point should be located, thereby improving the generalization ability of the deep learning neural network. The trained target model can thus more accurately predict the offset of the three-dimensional projection center point of each obstacle (including close and long-distance obstacles) in the image relative to the two-dimensional detection box, providing a basis for subsequently combining the intrinsic parameters of the image sensor to accurately restore the actual position of the obstacle in space.
[0093] In some possible implementations, the method may further include: obtaining the display attribute of each sample obstacle contained in the sample image, wherein the display attribute of each sample obstacle is used to indicate whether each sample obstacle is complete in the sample image. The prediction result also includes the predicted display attribute of each predicted obstacle; the training of the preset model based on the depth loss and the offset loss to obtain the target model includes: calculating the attribute loss based on the predicted display attribute of the predicted obstacle corresponding to each sample obstacle and the display attribute of each sample obstacle; training the preset model based on the depth loss, the offset loss and the attribute loss to obtain the target model.
[0094] The display attribute of each sample obstacle in the sample image may also be included in the training label corresponding to the sample image.
[0095] Taking the nth sample obstacle as an example, whether the nth sample obstacle is complete in the sample image may also refer to whether the nth sample obstacle is truncated in the sample image. In one case, the nth sample obstacle may be truncated or incomplete in the sample image because a part of the nth sample obstacle is located outside the sample image. For example, the nth sample obstacle is a vehicle and is located on the right side of the sample image. The vehicle itself should have a right body, but only the left body of the vehicle can be displayed in the sample image. In this case, the vehicle is incomplete or truncated in the sample image. In another case, the nth sample obstacle may be truncated or incomplete in the sample image because a part of the nth sample obstacle is blocked by other objects in the sample image. For example, the nth sample obstacle is vehicle 1, and vehicle 2 also exists in the sample image. A part of vehicle 1 is blocked by vehicle 2. In this case, vehicle 1 is incomplete or truncated in the sample image.
[0096] Still taking the nth sample obstacle as an example, the display attribute of the nth sample obstacle can be represented by an indicator value. For example, when the display attribute of the nth sample obstacle is the first indicator value, it means that the nth sample obstacle is complete or not truncated in the sample image; for example, when the display attribute of the nth sample obstacle is the second indicator value, it means that the nth sample obstacle is incomplete or truncated in the sample image; wherein the first indicator value and the second indicator value are different and can be configured according to actual conditions, for example, the first indicator value can be 0 and the second indicator value can be 1, or vice versa. The embodiment of the present application does not limit or enumerate all possible values of the first indicator value and the second indicator value. As long as the first indicator value and the second indicator value are different, they are within the protection scope of the present embodiment.
[0097] The predicted display attribute of any predicted obstacle can be the probability that the display attribute of the predicted obstacle is predicted as a positive class. The positive class can be configured according to actual conditions, for example, the positive class can be configured as the predicted obstacle being truncated in the sample image. The probability value can be greater than or equal to the first indicator value and less than or equal to the second indicator value, for example, the first indicator value is 0 and the second indicator value (i.e., the label value of the positive class) is 1. Assuming that the predicted display attribute of any predicted obstacle is 0.8, that is, the probability that the display attribute of the predicted obstacle is predicted as a positive class (truncated in the sample image) is 0.8.
[0098] The method for determining the predicted obstacle corresponding to each sample obstacle is the same as that in the above embodiment and will not be described in detail.
[0099] Calculating the attribute loss based on the predicted display attribute of the predicted obstacle corresponding to each sample obstacle and the display attribute of each sample obstacle may include: obtaining the nth attribute sub-loss based on the predicted display attribute of the predicted obstacle corresponding to the nth sample obstacle and the display attribute of the nth sample obstacle; determining whether there are remaining sample obstacles, and if there are no remaining sample obstacles, calculating the attribute loss based on the nth attribute sub-losses. In addition, it may also include: if there are remaining sample obstacles, selecting the n+1th sample obstacle from the remaining sample obstacles, and continuing to calculate the n+1th attribute sub-loss based on the predicted display attribute of the predicted obstacle corresponding to the n+1th sample obstacle and the display attribute of the n+1th sample obstacle, and so on, until all attribute sub-losses are calculated, and calculating the attribute loss based on all attribute sub-losses.
[0100] The nth attribute sub-loss is obtained based on the predicted display attribute of the predicted obstacle corresponding to the nth sample obstacle and the display attribute of the nth sample obstacle, and the second loss function is used to calculate the predicted display attribute of the predicted obstacle corresponding to the nth sample obstacle and the display attribute of the nth sample obstacle to obtain the nth attribute sub-loss. The second loss function can be a function for calculating the cross entropy loss or any function for calculating the binary classification loss, which is not limited or exhaustive in this embodiment.
[0101] The attribute loss is calculated based on the n attribute sub-losses, which may be obtained by adding the n attribute sub-losses, or by calculating the sum of the square values of the n attribute sub-losses, etc. All possible ways of calculating the attribute loss are not limited or enumerated here.
[0102] For example, assuming that vehicle A can be fully displayed in the sample image, that is, not truncated, then the vehicle A can be used as a sample obstacle with a display attribute of not truncated or complete. The two-dimensional detection frame of the vehicle A frames the entire vehicle A displayed in the sample image. At this time, the real three-dimensional projection center point of the vehicle A should also be located within the sample image (that is, within the display range or display range of the sample image). The horizontal offset of the center point corresponding to the vehicle A is expressed as △x _A , the vertical offset of the center point is expressed as △y _A ;
[0103] Assume that the same vehicle A cannot be fully displayed in another sample image, i.e., it is truncated. Then, the vehicle A can be regarded as a sample obstacle with a display attribute of truncated or incomplete. The two-dimensional detection frame of the vehicle A only frames the part of the vehicle A displayed in the sample image. At this time, the real three-dimensional projection center point of the vehicle A may be located outside the sample image (i.e., it falls outside the display range or display range of the sample image). The horizontal offset of the center point corresponding to the vehicle A is expressed as △x _A_t , the vertical offset of the center point is expressed as △y _A_t , where “t” indicates that vehicle A is truncated in the sample image;
[0104] When the display attributes of the same vehicle A in different sample images are different, the part of the vehicle A framed by the two-dimensional detection frame is different. Therefore, the relationship between the center point of the real three-dimensional projection and the center point of the two-dimensional detection frame in different sample images should also be different. Therefore, the same vehicle A has different display attributes under different △x _A_t , △x _A should be different, and △y _A_t , △y _A Should also be different.
[0105] Based on this, the embodiment of the present application adds the display attributes of each sample obstacle as a content of the training label corresponding to the sample image, so that while training the preset model to learn the center point offset of the obstacle, the center point offset of the obstacle under different display attributes can be learned, thereby ensuring that the target model finally trained can more accurately predict the center point offset of the obstacle under different display attributes, providing a basis for subsequently combining the internal parameters of the image sensor to accurately restore the actual position of the obstacle in space.
[0106] In one aspect, an embodiment of the present disclosure provides an obstacle detection method, such as Figure 2 As shown, including:
[0107] S201, obtaining an image to be detected collected by a target image sensor.
[0108] S202: Input the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected.
[0109] S203: Calculate a depth value of each obstacle based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
[0110] The above obstacle detection method can be implemented by an electronic device. The electronic device can be a terminal or a server. Exemplarily, the electronic device can be a vehicle-mounted terminal, or other terminal device with computing capabilities. Exemplarily, the server can be a single server, or it can be one or more servers in a server cluster, or it can be a server of a distributed system (or it can be called a computing node). It should be understood that the above is only an exemplary description of the execution subject that can execute the obstacle detection method provided by this embodiment. In actual processing, it may not be limited to the device types mentioned in the above examples. As long as the electronic device that can execute the obstacle detection method provided by this embodiment is within the protection scope of this embodiment.
[0111] The target model may be obtained by training using the model training method provided in the aforementioned embodiment, and will not be repeated in this embodiment.
[0112] By adopting the above scheme, the target model analyzes the collected image to be detected to obtain the normalized predicted depth of each obstacle, and then processes the normalized depth of the obstacle based on the focal length of the target image sensor to obtain the depth value of each obstacle. This avoids the problem of being unable to accurately predict the depth of the obstacle due to the influence of different focal lengths of different cameras during the target model analysis process, thereby ensuring the accuracy of the depth of the obstacle finally obtained.
[0113] In some possible implementations, acquiring the image to be detected acquired by the target image sensor may include: acquiring a current image acquired by the target image sensor in real time, and using the current image as the image to be detected.
[0114] The target image sensor may be any device or sensor having an image acquisition function. Preferably, the target image sensor may be any one of a monocular camera, a monocular camera head, and the like.
[0115] The target image sensor may collect the current image in the following manner: the target image sensor periodically collects the current image based on a collection period, and this embodiment does not limit the period length of the collection period.
[0116] Calculating the depth value of each obstacle based on the normalized predicted depth of each obstacle and the focal length of the target image sensor may include: multiplying the normalized depth value of the kth obstacle by the focal length of the target image sensor to obtain the depth value of the kth obstacle. Wherein, k is an integer greater than or equal to 1, and the kth obstacle is any one of the one or more obstacles in the image to be detected included in the prediction result. For example, assuming that the depth value of the kth obstacle is represented by z c_k, the focal length of the target image sensor is denoted as f, and the normalized depth value of the kth obstacle is denoted as z c_k_f , the depth value can be calculated using the following formula: c_k =z c_k _ f ×f.
[0117] Since the manner of processing each obstacle in the image to be detected included in the prediction result to obtain a depth value is the same as that of the kth obstacle, they will not be described one by one.
[0118] The depth value of each obstacle may refer to the real depth value of each obstacle; further, the real depth value of each obstacle may refer to the real depth value of each obstacle in a spatial coordinate system, and the relevant description of the spatial coordinate system is similar to that of the aforementioned embodiment, except that the origin of the spatial coordinate system in this embodiment is the location of the target image sensor, and other relevant descriptions are the same as those of the aforementioned embodiment, and therefore will not be repeated.
[0119] In some possible implementations, the prediction result also includes the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle. The method also includes: calculating the three-dimensional projection center point of each obstacle in the coordinate system of the target image sensor based on the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle; and obtaining the spatial coordinates of each obstacle based on the depth value of each obstacle, the three-dimensional projection center point of each obstacle and the internal parameters of the target image sensor.
[0120] Still taking any obstacle as the kth obstacle as an example, the predicted offset of the center point of the kth obstacle includes: the horizontal offset of the center point corresponding to the kth obstacle (for example, expressed as △x _k ), the vertical offset of the center point corresponding to the kth obstacle (for example, expressed as △y _k ). The center point of the two-dimensional detection frame of the k-th obstacle includes: the horizontal center point of the two-dimensional detection frame of the k-th obstacle (for example, represented by x _k ), the vertical center point of the two-dimensional detection box of the k-th obstacle (for example, represented by y _k ). The relationship between the center point of the two-dimensional detection frame and the coordinate system of the target image sensor is similar to the related description of the relationship between the center point of the two-dimensional detection frame and the coordinate system of the image sensor in the aforementioned embodiment, and will not be repeated.
[0121] Calculating the three-dimensional projection center point of each obstacle in the coordinate system of the target image sensor based on the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle may include: adding the horizontal offset of the center point corresponding to the k-th obstacle and the horizontal center point of the two-dimensional detection frame of the k-th obstacle to obtain the horizontal three-dimensional projection center point of the k-th obstacle in the coordinate system of the target image sensor; adding the vertical offset of the center point corresponding to the k-th obstacle and the vertical center point of the two-dimensional detection frame of the k-th obstacle to obtain the vertical three-dimensional projection center point of the k-th obstacle in the coordinate system of the target image sensor.
[0122] The internal parameters of the target image sensor may be preconfigured, and the internal parameters of the target image sensor may at least include the optical center of the target image sensor (or the optical center position, i.e., the position of the optical center in the coordinate system of the target image sensor), etc. The optical center of the target image sensor includes the optical center or the optical center position u0 in the horizontal direction and the optical center or the optical center position v0 in the vertical direction. Here, all parameters that may be included in the internal parameters of the image sensor are not limited or exhaustive.
[0123] Based on the depth value of each obstacle, the three-dimensional projection center point of each obstacle and the internal parameters of the target image sensor, the spatial coordinates of each obstacle are obtained, which may include: multiplying the horizontal three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle to obtain the horizontal coordinates of the kth obstacle in the spatial coordinate system; multiplying the vertical three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle to obtain the vertical coordinates of the kth obstacle in the spatial coordinate system; using the depth value of the kth obstacle, the horizontal coordinates of the kth obstacle, and the vertical coordinates of the kth obstacle as the spatial coordinates of the kth obstacle in the spatial coordinate system. The description of the internal parameters of the target image sensor is similar to the description of the internal parameters of the image sensor in the aforementioned embodiment, and will not be repeated.
[0124] Optionally, multiplying the horizontal three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle to obtain the horizontal coordinate of the kth obstacle in the spatial coordinate system may include: multiplying the horizontal three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle, and then multiplying it by the internal parameter of the target image sensor to obtain the horizontal coordinate of the kth obstacle in the spatial coordinate system. Multiplying the vertical three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle to obtain the vertical coordinate of the kth obstacle in the spatial coordinate system may include: multiplying the vertical three-dimensional projection center point of the kth obstacle by the depth value of the kth obstacle, and then multiplying it by the internal parameter of the target image sensor to obtain the vertical coordinate of the kth obstacle in the spatial coordinate system.
[0125] Since the method of calculating the spatial coordinates for each obstacle is the same as that for the kth obstacle, they will not be described one by one.
[0126] Furthermore, the prediction result may also include a predicted display attribute of each obstacle, wherein the predicted display attribute of each obstacle is used to indicate whether each obstacle is complete in the image to be detected.
[0127] The predicted display attributes of each obstacle are given in the prediction results, and can also be used to further detect whether the horizontal 3D projection center point and the vertical 3D projection center point of each obstacle are accurate. For example, if the predicted display attribute of the kth obstacle indicates that the kth obstacle is truncated in the image to be detected, then the horizontal 3D projection center point and the vertical 3D projection center point of the kth obstacle may fall outside the display range of the image to be detected. If the calculated horizontal 3D projection center point and the vertical 3D projection center point are within the display range of the image to be detected, it may indicate that the calculation is wrong, and the spatial coordinates of the kth obstacle can be recalculated or discarded.
[0128] In this way, the target model can be used to predict the center point prediction offset of each obstacle and the center point of the two-dimensional detection frame of each obstacle, and then calculate the three-dimensional projection center point of each obstacle in the coordinate system of the target image sensor. Combined with the intrinsic parameters of the target image sensor and the depth value of each obstacle, the spatial coordinates of each obstacle can be restored, ensuring the processing efficiency and accuracy of the spatial coordinates of each obstacle.
[0129] Another aspect of the present disclosure provides a model training device, such as Figure 3 As shown, including:
[0130] A spatial coordinate acquisition module 301 is used to acquire the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor;
[0131] A normalization processing module 302 is used to normalize the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle;
[0132] The model training module 303 is used to train the preset model based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
[0133] The model training module is used to input the sample image into the preset model to obtain a prediction result output by the preset model, wherein the prediction result includes a normalized predicted depth of each predicted obstacle among one or more predicted obstacles contained in the sample image; calculate a depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle; and train the preset model based on the depth loss to obtain the target model.
[0134] like Figure 4 As shown, the device also includes:
[0135] A two-dimensional detection frame acquisition module 401 is used to acquire relevant information of the two-dimensional detection frame of each sample obstacle;
[0136] The prediction result also includes relevant prediction information of the two-dimensional detection frame of each predicted obstacle; the model training module is used to determine the predicted obstacle corresponding to each sample obstacle based on the relevant prediction information of the two-dimensional detection frame of each predicted obstacle and the relevant information of the two-dimensional detection frame of each sample obstacle; and calculate the depth loss based on the normalized predicted depth of the predicted obstacle corresponding to each sample obstacle and the normalized depth of each sample obstacle.
[0137] like Figure 5 As shown, the device also includes:
[0138] The offset calculation module 501 is used to obtain the three-dimensional projection center point of each sample obstacle in the coordinate system of the image sensor based on the spatial coordinates of each sample obstacle and the internal parameters of the image sensor; and obtain the center point offset of each sample obstacle based on the three-dimensional projection center point of each sample obstacle and the center point of the two-dimensional detection frame of each sample obstacle.
[0139] The prediction result also includes: a predicted offset of the center point of each predicted obstacle;
[0140] The model training module is used to calculate the offset loss based on the predicted offset of the center point of the predicted obstacle corresponding to each sample obstacle and the offset of the center point of each sample obstacle; and train the preset model based on the depth loss and the offset loss to obtain the target model.
[0141] like Figure 6 As shown, the device also includes:
[0142] The obstacle display attribute acquisition module 601 is used to acquire the display attribute of each sample obstacle contained in the sample image, wherein the display attribute of each sample obstacle is used to indicate whether each sample obstacle is complete in the sample image;
[0143] The prediction result also includes the predicted display attributes of each predicted obstacle; the model training module is used to calculate the attribute loss based on the predicted display attributes of the predicted obstacle corresponding to each sample obstacle and the display attributes of each sample obstacle; the preset model is trained based on the depth loss, the offset loss and the attribute loss to obtain the target model.
[0144] Another aspect of the present disclosure provides an obstacle detection device, such as Figure 7 As shown, including:
[0145] The image acquisition module 701 is used to acquire the image to be detected collected by the target image sensor;
[0146] A prediction module 702 is used to input the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected;
[0147] The obstacle depth calculation module 703 is used to calculate the depth value of each obstacle based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
[0148] The prediction result also includes the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle;
[0149] like Figure 8 As shown, the device also includes:
[0150] The spatial coordinate calculation module 801 is used to calculate the three-dimensional projection center point of each obstacle in the coordinate system of the target image sensor based on the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle; and obtain the spatial coordinates of each obstacle based on the depth value of each obstacle, the three-dimensional projection center point of each obstacle and the internal parameters of the target image sensor.
[0151] For the description of specific functions and examples of each module and submodule of the device in the embodiment of the present disclosure, reference can be made to the relevant description of the corresponding steps in the above method embodiment, which will not be repeated here.
[0152] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0153] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0154] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0155] like Fig. 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0156] Multiple components in the electronic device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the electronic device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0157] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above. For example, in some embodiments, the various methods may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to execute the method in any other appropriate manner (e.g., by means of firmware).
[0158] According to another aspect of the present disclosure, an autonomous driving vehicle is provided, comprising the above-mentioned electronic device.
[0159] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0160] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0161] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0162] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0163] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0164] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0165] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0166] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A model training method, include: Acquire the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor; Normalizing the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle; The preset model is trained based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
2. The method according to claim 1, in, The step of training a preset model based on the sample image and the normalized depth value of each sample obstacle to obtain a target model includes: Inputting the sample image into the preset model to obtain a prediction result output by the preset model, wherein the prediction result includes a normalized predicted depth of each predicted obstacle among one or more predicted obstacles contained in the sample image; Calculating a depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle; The preset model is trained based on the depth loss to obtain the target model.
3. The method according to claim 2, in, The method further includes: obtaining relevant information of the two-dimensional detection frame of each sample obstacle; The prediction result also includes relevant prediction information of the two-dimensional detection frame of each predicted obstacle; The calculating the depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle includes: determining the predicted obstacle corresponding to each sample obstacle based on relevant prediction information of the two-dimensional detection frame of each predicted obstacle and relevant information of the two-dimensional detection frame of each sample obstacle; and calculating the depth loss based on the normalized predicted depth of the predicted obstacle corresponding to each sample obstacle and the normalized depth of each sample obstacle.
4. The method according to claim 3, in, The method further comprises: Based on the spatial coordinates of each sample obstacle and the internal parameters of the image sensor, obtaining a three-dimensional projection center point of each sample obstacle in the coordinate system of the image sensor; Based on the three-dimensional projection center point of each sample obstacle and the center point of the two-dimensional detection frame of each sample obstacle, the center point offset of each sample obstacle is obtained.
5. The method according to claim 4, in, The prediction result also includes: a predicted offset of the center point of each predicted obstacle; The preset model is trained based on the depth loss to obtain the target model, including: calculating the offset loss based on the predicted offset of the center point of the predicted obstacle corresponding to each sample obstacle and the offset of the center point of each sample obstacle; and the preset model is trained based on the depth loss and the offset loss to obtain the target model.
6. The method according to claim 5, in, The method further includes: acquiring a display attribute of each sample obstacle contained in the sample image, wherein the display attribute of each sample obstacle is used to indicate whether each sample obstacle is complete in the sample image; The prediction result also includes the predicted display attributes of each predicted obstacle; the training of the preset model based on the depth loss and the offset loss to obtain the target model includes: calculating the attribute loss based on the predicted display attributes of the predicted obstacle corresponding to each sample obstacle and the display attributes of each sample obstacle; training the preset model based on the depth loss, the offset loss and the attribute loss to obtain the target model.
7. An obstacle detection method, include: Acquire the image to be detected collected by the target image sensor; Inputting the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected; A depth value of each obstacle is calculated based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
8. The method according to claim 7, in, The prediction result also includes the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle; The method further includes: calculating a three-dimensional projection center point of each obstacle in a coordinate system of the target image sensor based on a center point of a two-dimensional detection frame of each obstacle and a predicted offset of the center point of each obstacle; and obtaining a spatial coordinate of each obstacle based on a depth value of each obstacle, the three-dimensional projection center point of each obstacle, and an internal parameter of the target image sensor.
9. A model training device, include: A spatial coordinate acquisition module, used to acquire the spatial coordinates of each sample obstacle in one or more sample obstacles contained in a sample image, wherein the sample image is acquired by an image sensor; A normalization processing module, configured to normalize the depth value in the spatial coordinates of each sample obstacle based on the focal length of the image sensor to obtain a normalized depth value of each sample obstacle; The model training module is used to train the preset model based on the sample image and the normalized depth value of each sample obstacle to obtain a target model.
10. The device according to claim 9, in, The model training module is used to input the sample image into the preset model to obtain a prediction result output by the preset model, wherein the prediction result includes a normalized predicted depth of each predicted obstacle among one or more predicted obstacles contained in the sample image; calculate a depth loss based on the normalized predicted depth of each predicted obstacle and the normalized depth of each sample obstacle; and train the preset model based on the depth loss to obtain the target model.
11. The device according to claim 10, in, The device further includes: a two-dimensional detection frame acquisition module, configured to acquire relevant information of the two-dimensional detection frame of each sample obstacle; The prediction result also includes relevant prediction information of the two-dimensional detection frame of each predicted obstacle; the model training module is used to determine the predicted obstacle corresponding to each sample obstacle based on the relevant prediction information of the two-dimensional detection frame of each predicted obstacle and the relevant information of the two-dimensional detection frame of each sample obstacle; and calculate the depth loss based on the normalized predicted depth of the predicted obstacle corresponding to each sample obstacle and the normalized depth of each sample obstacle.
12. The device according to claim 11, in, The device also includes: The offset calculation module is used to obtain the three-dimensional projection center point of each sample obstacle in the coordinate system of the image sensor based on the spatial coordinates of each sample obstacle and the internal parameters of the image sensor; and obtain the center point offset of each sample obstacle based on the three-dimensional projection center point of each sample obstacle and the center point of the two-dimensional detection frame of each sample obstacle.
13. The device according to claim 12, in, The prediction result also includes: a predicted offset of the center point of each predicted obstacle; The model training module is used to calculate the offset loss based on the predicted offset of the center point of the predicted obstacle corresponding to each sample obstacle and the offset of the center point of each sample obstacle; and train the preset model based on the depth loss and the offset loss to obtain the target model.
14. The device according to claim 13, in, The device further includes: an obstacle display attribute acquisition module, configured to acquire the display attribute of each sample obstacle contained in the sample image, wherein the display attribute of each sample obstacle is used to indicate whether each sample obstacle is complete in the sample image; The prediction result also includes the predicted display attributes of each predicted obstacle; the model training module is used to calculate the attribute loss based on the predicted display attributes of the predicted obstacle corresponding to each sample obstacle and the display attributes of each sample obstacle; the preset model is trained based on the depth loss, the offset loss and the attribute loss to obtain the target model.
15. An obstacle detection device, include: The image acquisition module to be detected is used to obtain the image to be detected collected by the target image sensor; A prediction module, used for inputting the image to be detected into a target model to obtain a prediction result output by the target model, wherein the prediction result includes a normalized predicted depth of each obstacle among one or more obstacles contained in the image to be detected; The obstacle depth calculation module is used to calculate the depth value of each obstacle based on the normalized predicted depth of each obstacle and the focal length of the target image sensor.
16. The device according to claim 15, in, The prediction result also includes the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle; The device also includes: a spatial coordinate calculation module, which is used to calculate the three-dimensional projection center point of each obstacle in the coordinate system of the target image sensor based on the center point of the two-dimensional detection frame of each obstacle and the predicted offset of the center point of each obstacle; and obtain the spatial coordinates of each obstacle based on the depth value of each obstacle, the three-dimensional projection center point of each obstacle and the internal parameters of the target image sensor.
17. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 6 or claims 7 and 8.
18. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 6, or claims 7 and 8.
19. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 6, or claims 7 and 8.
20. An autonomous driving vehicle comprising the electronic device as claimed in claim 17.
