Disclosure of Invention
In view of the above, it is necessary to provide a method and an apparatus for measuring speed of a TOF module, a computer device and a storage medium, which can reduce the cost of measuring speed.
A method of measuring velocity, the method comprising the steps of:
controlling a TOF module to emit light to a linearly moving target object;
acquiring first distance data of a connecting line between a target object and a TOF module at an initial position;
acquiring a connecting line of an initial position and a TOF module and included angle data between the connecting line and the movement direction of a target object;
receiving light reflected by the target object to generate a plurality of depth images and time information corresponding to the depth images, and acquiring second distance data of a connecting line between the target object corresponding to the depth images and the TOF module;
acquiring displacement data of the target object according to the first distance data, the included angle data and the second distance data;
and acquiring the movement speed of the target object according to the displacement data and the time information.
According to the method, the depth image of the target object is acquired through the TOF module, the displacement data of the target object is obtained according to the depth image, the displacement speed of the object can be rapidly measured, and the cost for measuring the speed of the target object is effectively reduced.
In one embodiment, obtaining first distance data of a connection line between the target object and the TOF module at the start position comprises the following steps:
controlling the TOF module to emit light to a target object located at the initial position;
acquiring an initial depth image generated by light reflected by a target object when the target object is positioned at an initial position;
and acquiring a depth value of the initial depth image, and acquiring first distance data according to the depth value.
When the target object is located at the initial position, the target object does not start to move, first distance data between the target object and the TOF module is fixed, light rays are transmitted to the target object located at the initial position through the TOF module to obtain an initial depth image, the first distance data are obtained according to the depth value of the initial depth image, and subsequent measurement of the movement speed of the target object is facilitated.
In one embodiment, the method for generating a plurality of depth images and time information corresponding to the plurality of depth images by receiving light reflected from a target object and obtaining second distance data of a connecting line between the target object corresponding to the plurality of depth images and a TOF module includes: :
receiving light rays reflected by the target object at different position points, generating depth images corresponding to the target object at the different position points, and acquiring time information of the target object at the different positions;
and according to the depth images of the target object at different position points, obtaining second distance data of a connecting line between the target object and the TOF module at different position points.
The target object can pass through different position points in the moving process, the TOF module can obtain a corresponding depth image at each position point, and second distance data of a connecting line between the target object and the TOF module at each position point can be obtained by obtaining the depth image of the target object at each position point, so that the moving speed of the target object can be conveniently calculated subsequently.
In one embodiment, the method for acquiring the displacement speed of the target object according to the displacement data and the time information comprises the following steps:
acquiring the time interval between the current position and the previous position of the target object according to the time information;
obtaining the displacement distance between the current position and the previous position of the target object according to the displacement data;
and acquiring the displacement speed of the target object according to the displacement distance and the time interval of the target object between the current position and the previous position.
By acquiring the current position of the target object, the time interval and the displacement distance of the previous position, the real-time displacement speed of the target object during the movement between two different positions can be obtained, and therefore a plurality of different real-time displacement speeds can be obtained in the whole movement process of the target object.
In one embodiment, before controlling the TOF module to emit light to the object performing linear motion, the method further includes:
controlling a TOF module to shoot images to obtain image data;
acquiring a field angle area of the TOF module according to the image data;
and when the target object is detected in the field angle of the TOF module, controlling the TOF module to emit light to the target object which moves linearly.
Through the field angle area of obtaining TOF, when testing the speed to the target object, only need make the target object enter into the field angle area can, improved the convenience of testing the speed.
In one embodiment, after obtaining the displacement velocity of the target object according to the displacement data and the time information, the method further includes the steps of:
and outputting the depth image of the target object and the displacement speed of the target object.
By outputting the depth image and the displacement speed of the target object, a user can conveniently know the image information and the displacement speed of the target object in real time.
A speed measurement device, the device comprising:
the light emission control module is used for controlling the TOF module to emit light to a linearly moving target object;
the first distance acquisition module is used for acquiring first distance data of a connecting line between the target object and the TOF module at the initial position;
the angle acquisition module is used for acquiring the connecting line of the initial position and the TOF module and the included angle data between the connecting line and the movement direction of the target object;
the second distance acquisition module is used for receiving the light rays reflected by the target object to generate a plurality of depth images and time information corresponding to the plurality of depth images, and acquiring second distance data of a connecting line between the target object corresponding to the plurality of depth images and the TOF module;
the displacement distance acquisition module is used for acquiring displacement data of the target object according to the first distance data, the included angle data and the second distance data;
and the speed acquisition module is used for acquiring the movement speed of the target object according to the displacement data and the time information.
Above-mentioned device gathers the depth map of target object through the TOF module to obtain the displacement data of target object according to the depth map, the measurement that can be quick obtains the displacement speed of object, cost when effectual reduction is tested the speed to the target object.
A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the above method when executing the computer program.
A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program realizes the steps of the above-mentioned method when being executed by a processor.
According to the computer equipment and the computer readable storage medium, the depth image of the target object is acquired through the TOF module, the displacement data of the target object is obtained according to the depth image, the displacement speed of the object can be rapidly obtained through measurement, and the cost spent on speed measurement of the target object is effectively reduced.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, as shown in fig. 1, there is provided a method of measuring speed, the method comprising the steps of:
and S400, controlling the TOF module to emit light to the linearly moving target object.
Specifically, the TOF module may be connected to a processor (e.g., a computer or a microprocessor, etc.), and then the processor generates a control signal according to a corresponding software program, etc. and sends the control signal to the TOF module to control the TOF module, where the TOF module includes an emitter and a TOF camera, the emitter is used for emitting light, the TOF camera is used for receiving the reflected light and generating a depth image, and further, in one embodiment, the emitter may be an infrared light emitter, and in other embodiments, the emitter may be a laser emitter, etc. The target may be a moving object such as a moving cart, and the target is set to move linearly.
S500, first distance data of a connecting line between the target object and the TOF module at the initial position is obtained.
After the light emitted by the TOF module is incident on the target object, the light is reflected back to the TOF module by the target object and received by the TOF module to form a depth image, wherein the depth image includes corresponding depth information, and distance data between the target object and the TOF module can be calculated from the depth information.
S600, obtaining a connecting line of the initial position and the TOF module and included angle data between the connecting line and the movement direction of the target object.
Specifically, the target object inevitably has an initial position in the moving process, the initial position can be determined according to actual conditions, after the initial position of the target object is determined, a connection line between the TOF module and the initial position can be obtained, and the target object only moves linearly, so that included angle data exists between the moving direction of the target object and the connection line between the initial position and the TOF module, and the included angle data can be obtained through angle measurement and then sent to the processor. Specifically, in one embodiment, the included angle may be obtained by measuring with an angle measuring instrument, and the processor may obtain the included angle by performing communication connection with the angle measuring instrument, or in other embodiments, the TOF module may automatically obtain the included angle and send the included angle to the processor. For example, when the transmitter of the TOF module emits light towards the initial position, the angle measuring instrument records the orientation of the transmitter once, when the transmitter emits light towards the direction parallel to the movement of the target object, the angle measuring instrument records the orientation of the transmitter once again, the included angle can be obtained according to the orientations recorded twice, and then the processor can obtain angle data after data communication with the processor.
S700, receiving the light reflected by the target object to generate a plurality of depth images and time information corresponding to the depth images, and acquiring second distance data of a connecting line between the target object corresponding to the depth images and the TOF module.
The target object is at the in-process of motion, the TOF module can be continuous launches light to the target object, then the target object launches back light and gives the TOF module, thereby can generate a plurality of depth image, reflect back at light and receive by the TOF module, current time information can be noted correspondingly, this time information can directly be recorded through the TOF module, also can record through setting up corresponding time recorder, the treater is through being connected with the TOF module, carry out data communication, then acquire depth image and time information, the treater can follow each depth image and obtain the distance between corresponding target object and the TOF module, this distance is just for second distance data.
And S800, obtaining displacement data of the target object according to the first distance data, the included angle data and the second distance data.
Specifically, the edge length theorem can be calculated through a triangle, the target object is a point of the triangle at the initial position, the TOF module is located at a second point of the triangle, the position point of the target object in the motion process is a third point of the triangle, three edge lengths of the triangle are determined through the three points, the first distance data and the second distance data are the edge lengths of two edges in the triangle, the displacement data of the target object is the edge length of the last edge in the triangle, the edge lengths of the two edges in the triangle and an included angle are known, and the processor can calculate the edge length of the last edge in the triangle, namely the displacement data of the target object.
And S900, acquiring the movement speed of the target object according to the displacement data and the time information.
In the process of displacement of the target object, the displacement data represent the distance from one position point to another position point of the target object, the time information represent the time spent by the target object to move from one position point to another position point, and the processor can calculate the movement speed of the target object according to the displacement data and the time information.
According to the method, the depth image of the target object is acquired through the TOF module, the displacement data of the target object is obtained according to the depth image, the displacement speed of the object can be rapidly measured, and the cost for measuring the speed of the target object is effectively reduced.
In one embodiment, step S500 includes the steps of: controlling the TOF module to emit light to a target object located at the initial position; acquiring an initial depth image generated by light reflected by a target object when the target object is positioned at an initial position; and acquiring a depth value of the initial depth image, and acquiring first distance data according to the depth value. Specifically, the TOF module may obtain a depth image through a CMOS (Complementary Metal Oxide Semiconductor) pixel array and an active modulation light source technology, and each pixel in the array may measure the brightness of a corresponding target object and the arrival time of a reflected light signal, so as to obtain a depth value in the depth image and calculate a distance depth (i.e., a distance between the target object and the TOF module). When the target object is located at the initial position, the target object does not start to move, the first distance data between the target object and the TOF module is fixed, and the TOF module is used for transmitting light to the target object located at the initial position, so that the subsequent measurement of the movement speed of the target object is facilitated.
In one embodiment, step S700 further comprises the steps of: receiving light rays reflected by the target object at different position points, generating depth images corresponding to the target object at the different position points, and acquiring time information of the target object at the different positions; and according to the depth images of the target object at different position points, obtaining second distance data of a connecting line between the target object and the TOF module at different position points.
Specifically, when the target object is at different positions, the TOF module can acquire and obtain depth images of the target object at the different positions, and the processor obtains the link distance between the TOF module and the target object at the different positions according to the depth images. For example, a first distance from the TOF module when the object is in the first position and a second distance from the TOF module when the object is in the second position. It can be understood that the first position and the second position may overlap or may be different position points (that is, the first distance and the second distance may be the same or different), when the object is at the first position, the object reflects the light emitted by the TOF module back to the TOF module, and when the TOF module receives the light reflected back by the object at the first position to form a depth image, the TOF module may record time information once, where the time information corresponds to the depth image, and of course, when the TOF module is at the second position, the depth image and the corresponding time information also exist.
The target object can pass through different position points in the moving process, the TOF module can obtain a corresponding depth image at each position point, and second distance data of a connecting line between the target object and the TOF module at each position point can be obtained by obtaining the depth image of the target object at each position point, so that the moving speed of the target object can be conveniently calculated subsequently.
In one embodiment, as shown in fig. 2, step S900 includes the steps of:
s910, acquiring the time interval between the current position and the previous position of the target object according to the time information.
And S920, obtaining the displacement distance between the current position and the previous position of the target object according to the displacement data.
S930, acquiring the displacement speed of the target object according to the displacement distance and the time interval of the target object between the current position and the previous position.
It will be appreciated that there is a time interval when the object moves from one location to another, and accordingly the displacement distance between the object moving from one location to another may be obtained by the processor, and by calculating the displacement velocity between the current location and the previous location of the object, the real-time displacement velocity of the object may be obtained, for example, when the time interval approaches zero.
By acquiring the current position of the target object, the time interval and the displacement distance of the previous position, the real-time displacement speed of the target object during the movement between two different positions can be obtained, and therefore a plurality of different real-time displacement speeds can be obtained in the whole movement process of the target object.
In one embodiment, as shown in fig. 3, step S400 further includes the following steps:
and S100, controlling a TOF module to shoot images to obtain image data.
And S200, acquiring a view field angle area of the TOF module according to the image data.
S300, when the fact that the object exists in the field angle of the TOF module is detected, the TOF module enters a step of acquiring a depth image and time information generated by the ray reflected by the object.
The processor can control the TOF module in advance to shoot images, and after the images are shot, the shooting range of the TOF module can be obtained, so that a view field angle area is further obtained, and the TOF module can measure the speed of the target object as long as the target object enters the view field angle area. It should be understood that the field angle is also called field of view, and the size of the field angle region determines the field of view range of the optical instrument.
Through the field angle area of obtaining TOF, when testing the speed to the target object, only need make the target object enter into the field angle area can, improved the convenience of testing the speed.
In one embodiment, as shown in fig. 3, the step S900 is followed by the steps of:
and S940, outputting the depth image of the target object and the displacement speed of the target object.
The depth image can be displayed through a display interface and the like, and the displacement speed can be output through voice. It should be understood that the depth image outputted at this time includes image information of the target object, for example, when the target object is an automobile, the image information of the automobile is outputted.
Further, in an embodiment, the displacement speed of the target object may be a real-time displacement speed, for example, each time the processor calculates the displacement speed of the target object at a position point, the processor outputs a depth image of the target object in sequence and a current displacement speed, which may facilitate a user to know a current motion state of the target object in real time.
By outputting the depth image and the displacement speed of the target object, a user can conveniently know the image information and the displacement speed of the target object in real time.
In one embodiment, as shown in fig. 4, there is provided a speed measuring device including:
the light emission control module 400 is used for controlling the TOF module to emit light to the target object which moves linearly. The first distance acquiring module 500 is configured to acquire first distance data of a connection line between the target object and the TOF module at the start position. The angle obtaining module 600 is configured to obtain data of an included angle between a connection line between the start position and the TOF module and a moving direction of the target object. The second distance obtaining module 700 is configured to receive the light reflected from the target object to generate a plurality of depth images and time information corresponding to the plurality of depth images, and obtain second distance data of a connection line between the target object and the TOF module corresponding to the plurality of depth images. The displacement distance obtaining module 800 is configured to obtain displacement data of the target object according to the first distance data, the included angle data, and the second distance data. The speed obtaining module 900 is configured to obtain a moving speed of the target object according to the displacement data and the time information.
Above-mentioned device gathers the depth map of target object through the TOF module to obtain the displacement data of target object according to the depth map, the measurement that can be quick obtains the displacement speed of object, cost when effectual reduction is tested the speed to the target object.
In one embodiment, the first distance obtaining module 500 further includes a depth value obtaining unit for controlling the TOF module to emit light to the target object located at the initial position; acquiring an initial depth image generated by light reflected by a target object when the target object is positioned at an initial position; and acquiring a depth value of the initial depth image, and acquiring first distance data according to the depth value.
When the target object is located at the initial position, the target object does not start to move, the first distance data between the target object and the TOF module is fixed, and the TOF module is used for transmitting light to the target object located at the initial position, so that the subsequent measurement of the movement speed of the target object is facilitated.
In one embodiment, the second distance obtaining module 700 further includes a position point distance obtaining unit, configured to receive light reflected from the target at different position points, generate depth images corresponding to the target at the different position points, and obtain time information of the target at the different position points; and according to the depth images of the target object at different position points, obtaining second distance data of a connecting line between the target object and the TOF module at different position points.
The target object can pass through different position points in the moving process, the TOF module can obtain a corresponding depth image at each position point, and second distance data of a connecting line between the target object and the TOF module at each position point can be obtained by obtaining the depth image of the target object at each position point, so that the moving speed of the target object can be conveniently calculated subsequently.
In one embodiment, the speed acquiring module 900 further comprises a time interval acquiring unit for acquiring a time interval between the current position and the previous position of the object according to the time information. The position point distance obtaining unit is used for obtaining the displacement distance of the target object between the current position and the previous position according to the displacement data. The speed detection unit is used for acquiring the displacement speed obtained by the current detection of the target object according to the displacement distance and the time interval of the target object between the current position and the previous position.
By acquiring the current position of the target object, the time interval and the displacement distance of the previous position, the real-time displacement speed of the target object during the movement between two different positions can be obtained, and therefore a plurality of different real-time displacement speeds can be obtained in the whole movement process of the target object.
In one embodiment, as shown in fig. 5, the speed measuring device further includes: the image acquisition module 100 is used for controlling the TOF module to shoot images before the light emission control module 400 controls the TOF module to emit light to the target object which makes linear motion, so as to obtain image data. The region acquiring module 200 is configured to acquire a field angle region of the TOF module according to the image data. The object detecting module 300 is configured to turn to the light emission control module 400 to control the TOF module to emit light to the object doing linear motion when detecting that an object is located within the field angle of the TOF module.
Through the field angle area of obtaining TOF, when testing the speed to the target object, only need make the target object enter into the field angle area can, improved the convenience of testing the speed.
In one embodiment, as shown in fig. 5, the speed measuring device further includes: the output module 940 is configured to output the depth image of the target object and the displacement speed of the target object after the speed obtaining module 900 obtains the displacement speed of the target object according to the displacement data and the time information. By outputting the depth image and the displacement speed of the target object, a user can conveniently know the image information and the displacement speed of the target object in real time.
In one embodiment, as shown in fig. 6, for better explaining the present application in detail, an example of measuring the displacement speed of the target object is provided, wherein a rectangular coordinate system is established with a position point of the TOF module as an origin, the target object moves linearly parallel to the Y axis, when the target object moves on the X axis, a shortest linear distance exists between the target object and the TOF module, when the target object continues to move, the TOF module emits a light beam onto the target object according to a certain frequency, when the light beam irradiates the target object and returns to be received by the TOF module, the TOF module can obtain a depth image of the target object at the current position point, after the subsequent processor obtains the depth image, the depth information is obtained from the depth image, the distance between the TOF module and the current position point of the target object is calculated, and then the shortest linear distance is obtained by combining, the displacement data of the target object from the X-axis position to the current position point can be calculated through the triangle pythagorean theorem, then the time of the target object from the X-axis position to the current position point is obtained according to the frequency of the rays emitted by the TOF module, and finally the displacement speed of the target object can be calculated.
A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor realizes the steps of the above method when executing the computer program.
The computer equipment collects the depth image of the target object through the TOF module, obtains the displacement data of the target object according to the depth image, can quickly measure the displacement speed of the object, and effectively reduces the cost spent on speed measurement of the target object.
A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program realizes the steps of the above-mentioned method when being executed by a processor.
The computer-readable storage medium collects the depth image of the target object through the TOF module, obtains the displacement data of the target object according to the depth image, can quickly measure the displacement speed of the object, and effectively reduces the cost for measuring the speed of the target object.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.