WO2021115268A1 - Method and apparatus for determining running direction of metro train, and terminal and storage medium - Google Patents

Method and apparatus for determining running direction of metro train, and terminal and storage medium Download PDF

Info

Publication number
WO2021115268A1
WO2021115268A1 PCT/CN2020/134578 CN2020134578W WO2021115268A1 WO 2021115268 A1 WO2021115268 A1 WO 2021115268A1 CN 2020134578 W CN2020134578 W CN 2020134578W WO 2021115268 A1 WO2021115268 A1 WO 2021115268A1
Authority
WO
WIPO (PCT)
Prior art keywords
subway
acceleration data
data
running direction
acceleration
Prior art date
Application number
PCT/CN2020/134578
Other languages
French (fr)
Chinese (zh)
Inventor
刘文龙
Original Assignee
Oppo广东移动通信有限公司
上海瑾盛通信科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司, 上海瑾盛通信科技有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021115268A1 publication Critical patent/WO2021115268A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/30Services specially adapted for particular environments, situations or purposes
    • H04W4/40Services specially adapted for particular environments, situations or purposes for vehicles, e.g. vehicle-to-pedestrians [V2P]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/02Services making use of location information
    • H04W4/025Services making use of location information using location based information parameters
    • H04W4/027Services making use of location information using location based information parameters using movement velocity, acceleration information

Definitions

  • the embodiments of the present application relate to the field of artificial intelligence, and in particular to a method, device, terminal, and storage medium for determining the direction of subway operation.
  • the subway can provide people with convenient and fast rail transit services.
  • the embodiments of the present application provide a method, device, terminal, and storage medium for determining the direction of subway operation.
  • the technical solution is as follows:
  • an embodiment of the present application provides a method for determining a subway running direction, the method is used in a terminal, and the method includes:
  • first acceleration data collected by the linear acceleration sensor where the first acceleration data includes acceleration data in various directions in the terminal coordinate system
  • an embodiment of the present application provides a device for determining the direction of subway operation.
  • the device is used in a terminal, and the device includes:
  • the acquiring module is configured to acquire the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
  • a data conversion module configured to convert the first acceleration data into second acceleration data, the second acceleration data including acceleration data in various directions in the world coordinate system;
  • the first determining module is configured to determine the running direction of the subway according to the second acceleration data within the target duration.
  • an embodiment of the present application provides a terminal, the terminal includes a processor and a memory; the memory stores at least one instruction, and the at least one instruction is used to be executed by the processor to implement the above-mentioned aspects.
  • a computer-readable storage medium stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the method for determining a subway running direction as described in the above aspect.
  • the embodiments of the present application provide a computer program product or computer program.
  • the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
  • the processor of the terminal reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the terminal executes the method for determining the subway running direction provided in the various optional implementations of the foregoing aspects.
  • Fig. 1 shows a flowchart of a method for determining a subway running direction provided by an exemplary embodiment of the present application
  • Fig. 2 shows a flowchart of a method for determining a subway running direction shown in an exemplary embodiment of the present application
  • Fig. 3 is a schematic diagram of a terminal coordinate system and a world coordinate system shown in an exemplary embodiment of the present application;
  • Fig. 4 shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application
  • Fig. 5 is a schematic diagram showing the direction of gravity and the direction of magnetic force on the earth according to an exemplary embodiment of the present application
  • Fig. 6 is a framework diagram of a running direction prediction model shown in an exemplary embodiment of the present application.
  • Fig. 7 shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application
  • FIG. 8 shows a flowchart of a process of determining that a subway is in an acceleration phase shown in an exemplary embodiment of the present application
  • FIG. 9 is a schematic diagram of a process of audio data preprocessing according to an exemplary embodiment of the present application.
  • FIG. 10 shows a flow chart of a method for determining whether a user takes the subway correctly according to an exemplary embodiment of the present application
  • Fig. 11 shows a structural block diagram of a device for determining a subway running direction provided by an exemplary embodiment of the present application
  • FIG. 12 shows a structural block diagram of a terminal provided by an exemplary embodiment of the present application.
  • the "plurality” mentioned herein means two or more.
  • “And/or” describes the association relationship of the associated objects, indicating that there can be three types of relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone.
  • the character “/” generally indicates that the associated objects before and after are in an "or” relationship.
  • two methods are usually used to determine the direction of the subway.
  • One is to determine the direction of the subway by the direction of the instantaneous acceleration: when the user rides the subway, the acceleration sensor in the terminal can record the instantaneous acceleration and pass the instantaneous acceleration.
  • the direction of acceleration determines the running direction of the subway at this time; the other is to determine the running direction of the subway through the compass (electronic compass) direction.
  • the acceleration direction recorded by the acceleration sensor in the terminal will be affected by the terminal posture, that is, the user holding the terminal in different postures will cause the instantaneous acceleration detected by the terminal
  • the instantaneous acceleration collected by the acceleration sensor in the terminal includes not only the acceleration of the subway, but also the acceleration generated by the user’s movement on the terminal; in addition, the subway will produce a certain amount of acceleration during the acceleration process.
  • the oscillating phenomenon makes the accuracy of determining the direction of subway operation only by using a certain instantaneous acceleration direction, and the accuracy is low.
  • using the electronic compass to determine the direction of the subway because the subway operation will affect the accuracy of the electronic compass, therefore, directly using the electronic compass to determine the direction of the subway, the accuracy is low.
  • an embodiment of the present application provides a method for determining the running direction of a subway, and the method includes a process as shown in FIG.
  • Step 101 Obtain linear acceleration in the terminal coordinate system.
  • Step 102 Convert the linear acceleration in the terminal coordinate system to the acceleration in the world coordinate system through the coordinate system conversion module.
  • Step 103 Acquire acceleration data in the world coordinate system for a period of time.
  • a period of time can be the acceleration phase of the subway, and the acceleration data converted into the world coordinate system corresponding to the acceleration phase of the subway is cached.
  • Step 104 Input the acquired acceleration data in the world coordinate system for a period of time into the running direction prediction model.
  • the acceleration data buffered for a period of time is input into the running direction prediction model, and the prediction probability of each candidate direction can be output.
  • Step 105 Determine the subway running direction according to the predicted probability of each candidate running direction.
  • the candidate direction with the highest predicted probability can be determined as the subway running direction.
  • the method for determining the running direction of the subway adopted in the embodiment of this application converts the linear acceleration in the terminal coordinate system acquired by the terminal into the acceleration in the world coordinate system. Due to the uniqueness of the world coordinate system, the terminal attitude pair acquisition is avoided. The impact of the acceleration direction obtained, thereby improving the accuracy of determining the direction of the subway; in addition, by obtaining the acceleration data in the world coordinate system for a period of time, and inputting it into the prediction model of the direction of travel, in order to determine the direction of the subway for a period of time. Comprehensive analysis of the acceleration data to determine the direction of the subway can avoid the problem of inaccurate determination of the direction of the subway due to the instability of a single acceleration direction.
  • FIG. 2 shows a flowchart of a method for determining a subway running direction shown in an exemplary embodiment of the present application.
  • the method for determining the running direction of the subway is used in a terminal as an example for description, and the method includes:
  • Step 201 In the subway acceleration phase, first acceleration data collected by the linear acceleration sensor is acquired, and the first acceleration data includes acceleration data in various directions in the terminal coordinate system.
  • the terminal is provided with a linear acceleration sensor, and the data acquired by the linear acceleration sensor is acceleration data after excluding the influence of gravity, and is acceleration data in the terminal coordinate system.
  • the linear acceleration sensor collects acceleration data in various directions in the terminal coordinate system to obtain the first acceleration data in the terminal coordinate system.
  • the first acceleration data can be expressed as a vector as Where x ⁇ is the acceleration component in the X-axis direction in the terminal coordinate system, y ⁇ is the acceleration component in the Y-axis direction in the terminal coordinate system, and z ⁇ is the acceleration component in the Z-axis direction in the terminal coordinate system.
  • the terminal coordinate system may be as shown in (A) in FIG. 3, and the terminal coordinate system changes with the posture of the terminal.
  • Step 202 Convert the first acceleration data into second acceleration data, where the second acceleration data includes acceleration data in various directions in the world coordinate system.
  • the terminal coordinate system Since the terminal posture will change with the user’s holding posture, the terminal coordinate system will also change with the user’s holding posture, which causes the acceleration direction corresponding to the first acceleration data to change at any time.
  • the acceleration direction determines the reference value of the subway running direction. Therefore, the first acceleration data needs to be converted into the corresponding second acceleration data in the world coordinate system, and the world coordinate system will not be affected by the terminal posture.
  • the world coordinate system may be as shown in (B) of FIG. 3, where the Z axis in the world coordinate system is perpendicular to the ground upward, the Y axis points to the north, and the X axis points to the east.
  • the first acceleration data is converted into the second acceleration data in the world coordinate system according to the data conversion relationship between the world coordinate system and the terminal coordinate system.
  • the relationship between the second acceleration data and the first acceleration data is among them, Represents the second acceleration data, R represents the data conversion relationship between the first acceleration data and the second acceleration data, Indicates the first acceleration data; according to the first acceleration data And data conversion relationship R, where x ⁇ is the acceleration component of the first acceleration data in the X-axis direction in the terminal coordinate system, and y ⁇ is the acceleration component of the first acceleration data in the Y-axis direction in the terminal coordinate system, z ⁇ is the acceleration component of the first acceleration data in the Z-axis direction in the terminal coordinate system; the second acceleration data can be obtained Among them, x ⁇ is the acceleration component of the second acceleration data in the X-axis direction in the world coordinate system, y ⁇ is the acceleration component of the second acceleration data in the Y-axis direction in the world coordinate system, and
  • Step 203 Determine the running direction of the subway according to the second acceleration data within the target duration.
  • the embodiment of the present application uses all the acceleration directions during the subway acceleration time period to synthesize Determine the direction of the subway.
  • the target duration is preset by the developer, and the target duration may be determined by the developer by comprehensively analyzing the acceleration time in actual subway operation.
  • the target duration may be the acceleration duration when the subway starts, or it may be a period of time in the acceleration duration.
  • the terminal continuously collects the first acceleration data within the target duration, converts it into the second acceleration data, and stores it in the terminal, so that the acceleration data in the target duration can be subsequently comprehensively analyzed.
  • the target duration may be 10s, that is, the terminal continuously collects the first acceleration data within 10s, and converts it into second acceleration data in real time, so as to comprehensively analyze the subway running direction based on the second acceleration data within 10s.
  • the terminal performs a comprehensive analysis according to the second acceleration data buffered to obtain the overall acceleration direction corresponding to the second acceleration data within the target duration, and determines the acceleration direction as the subway running direction.
  • the terminal collects acceleration data (first acceleration data) in various directions in the terminal coordinate system through the linear acceleration sensor, and converts the first acceleration data.
  • a gravity acceleration sensor and a magnetometer are provided in the terminal;
  • Converting the first acceleration data to the second acceleration data includes:
  • the gravity acceleration data collected by the gravity acceleration sensor and the magnetic data collected by the magnetometer are based on the terminal coordinate system;
  • the first acceleration data is converted into the second acceleration data.
  • linear acceleration sensors, gravity acceleration sensors and magnetometers collect data according to the target sampling frequency
  • n is an integer greater than or equal to 2;
  • the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then the n-1th conversion matrix Determined as the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
  • the acceleration data and the n-th magnetic force data determine the n-th conversion matrix
  • Converting the first acceleration data to the second acceleration data through the conversion matrix includes:
  • the first acceleration data is converted into the second acceleration data.
  • determining the direction of subway operation according to the second acceleration data within the target duration includes:
  • the running direction prediction result includes the predicted probability corresponding to each candidate running direction
  • the subway running direction is determined.
  • the running direction prediction model adopts the convolutional neural network CNN structure, and the running direction prediction model is trained based on the sample acceleration data and the sample running direction;
  • the sample acceleration data is the acceleration data in all directions in the world coordinate system during the acceleration phase of the subway, and the sample running direction is the actual running direction of the subway.
  • the method further includes:
  • the target subway running direction is the running direction when the subway runs from the current station to the terminal station;
  • the subway acceleration phase includes the subway startup phase
  • the method before acquiring the first acceleration data collected by the linear acceleration sensor, the method further includes:
  • the ambient sound includes the subway closing alarm bell
  • the ambient sound includes the subway closing alarm bell
  • the subway startup stage including:
  • the audio feature matrix into the voice recognition model to obtain the alarm ringtone recognition result output by the voice recognition model.
  • the alarm ringtone recognition result is used to indicate whether the ambient sound contains the subway closing alarm ringtone;
  • the alarm bell recognition result indicates that the ambient sound includes a subway closing alarm bell, it is determined that it is in the subway startup stage.
  • determining the conversion matrix according to the gravity acceleration data and the magnetic force data includes:
  • the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system
  • the conversion matrix between the world coordinate system and the terminal coordinate system is determined.
  • a prediction model of the running direction can be preset in the terminal, and the second acceleration data can be used as the model input, so as to output each candidate The predicted probability of the running direction is used to judge the current running direction of the subway.
  • FIG. 4 shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application.
  • the method for determining the running direction of the subway is used in a terminal as an example for description, and the method includes:
  • Step 401 In the subway acceleration phase, first acceleration data collected by the linear acceleration sensor is acquired.
  • step 201 For the implementation of this step, reference may be made to step 201, which is not described in detail in this embodiment.
  • Step 402 Obtain the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer.
  • the gravity acceleration data and the magnetic force data are based on the terminal coordinate system.
  • the terminal is provided with a gravity acceleration sensor and a magnetometer.
  • the gravity acceleration sensor collects gravity acceleration data in the terminal coordinate system
  • the magnetometer collects magnetic force data in the terminal coordinate system.
  • the gravity acceleration data in the terminal coordinate system acquired by the gravity sensor can be expressed as Among them, G x is the acceleration component of the gravitational acceleration data in the X-axis direction, G y is the acceleration component of the gravitational acceleration data in the Y-axis direction, and G z is the acceleration component of the gravitational acceleration data in the Z-axis direction;
  • the magnetic data in the terminal coordinate system can be expressed as Wherein, M x is a magnetic data magnetic field component data in the Y-axis direction, M z for the component of the magnetic field data in the Z-axis direction magnetic field component in the X-axis direction, M y.
  • FIG. 5 Schematically, a schematic diagram of the gravity and magnetic force of the earth is shown in Figure 5, where G is vertically downward, that is, the direction of the Z axis in the world coordinate system shown in (B) in Figure 3 is opposite; due to the magnetic induction The direction of the line is from the south pole of the earth to the north pole of the earth. Therefore, the direction of the magnetic force is shown as M in Figure 5.
  • step 401 and step 402 can be performed at the same time, and there is no sequence, that is, when it is determined that the subway is in the acceleration phase, the linear acceleration sensor, the gravity acceleration sensor, and the magnetometer in the terminal start to collect data at the same time.
  • Step 403 Determine a conversion matrix according to the gravity acceleration data and the magnetic force data, and the conversion matrix is used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system.
  • the process of determining the conversion matrix according to the gravitational acceleration data and the magnetic force data may include the following steps:
  • the conversion relationship between the first acceleration data and the second acceleration data collected by the terminal is determined based on the representation relationship of the unit vector in the world coordinate system and the terminal coordinate system. Since the unit vector in the world coordinate system is related to the gravitational acceleration and magnetic force data, for example, the direction of the Z-axis unit vector in the world coordinate system is opposite to the gravitational acceleration, and the corresponding gravity acceleration data can be used to represent the Z-axis unit vector in the world coordinate system. Therefore, in a possible implementation manner, the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system can be determined according to the gravitational acceleration data and the magnetic force data collected by the terminal.
  • the unit vector of the X axis of the world coordinate system can be expressed in the terminal coordinate system as:
  • H x , H y , and H z are the unit vectors of the X axis of the world coordinate system, respectively, corresponding to the components in the X, Y, and Z directions of the terminal coordinate system.
  • the X-axis unit vector in the known world coordinate system And the Z-axis unit vector Since the Y axis is perpendicular to the plane formed by the X axis and the Z axis, according to the vector And vector You can get the unit vector of the Y axis
  • the obtained three-axis unit vectors (unit vectors) of the world coordinate system are expressed in the terminal coordinate system (target vectors) as:
  • the unit vector is a vector in the world coordinate system
  • the target vector is the representation of the same unit vector in the terminal coordinate system
  • the unit vector and the target vector are the representation of the same vector in different coordinate systems.
  • the conversion relationship between the world coordinate system and the terminal coordinate system can be calculated according to the relationship between the unit vector and the target vector, and the same acceleration data in the terminal coordinate system and the world coordinate system can be correspondingly obtained. The conversion relationship.
  • R is the conversion matrix. From the formula (4), it can be known that the conversion matrix R is related to gravitational acceleration data and magnetic force data. Therefore, in a possible implementation manner, when the terminal collects the first acceleration data through the linear acceleration sensor, the corresponding gravitational acceleration and magnetic force data are respectively acquired through the gravity acceleration sensor and the magnetometer, and the corresponding gravitational acceleration and magnetic force data are obtained according to the above conversion matrix R and gravity. According to the relationship between the acceleration value and the magnetic data, the conversion matrix R corresponding to the first acceleration data at this time is obtained.
  • Step 404 Convert the first acceleration data into second acceleration data through the conversion matrix.
  • the terminal obtains the conversion matrix corresponding to the first acceleration data
  • the first acceleration data and the conversion matrix are brought into formula (1), and the world coordinate system corresponding to the first acceleration data can be obtained. Under the second acceleration data.
  • the first acceleration data is denoted as L_ACC ⁇
  • the conversion matrix corresponding to the first acceleration data is R
  • Step 405 Input the second acceleration data within the target duration into the running direction prediction model to obtain the running direction prediction result output by the running direction prediction model.
  • the running direction prediction result includes the predicted probability corresponding to each candidate running direction.
  • the running direction prediction model adopts a convolutional neural network (Convolutional Neural Network, CNN) structure, and the training process of the model is as follows:
  • the training sample data includes the sample acceleration data and the sample running direction.
  • the sample acceleration data is the acceleration data of the subway in various directions under the world coordinate system, and the sample running direction is the actual running direction of the subway.
  • the developer collects the acceleration data of the subway acceleration phase of each subway station in advance. Since the acceleration data is the acceleration data in the terminal coordinate system, in order to avoid the influence of the terminal attitude on the acceleration direction, it is The steps described above are converted into acceleration data in the world coordinate system, and then the acceleration data is marked according to the actual running direction of the subway at the station. For example, the actual running direction of the subway is divided into southeast, southwest, northeast, Northwest, etc., and each actual operating direction is marked as 0, 1, 2, 3, etc., that is, 0 represents the southeast direction, 1 represents the southwest direction, 2 represents the northeast direction, and 3 represents the northwest direction.
  • the actual running direction of the subway at the station can be obtained according to map applications.
  • the actual running direction of the subway may also include east, south, west, north, etc., or a more detailed division, for example, 30° from north to east.
  • the embodiment of the present application does not limit the representation of the running direction of the sample.
  • the CNN model structure is shown in FIG. 6, the first convolutional layer 601 and the second convolutional layer 602 are used to extract the characteristics of the input sample acceleration data, and the first fully connected layer 603 and the second convolutional layer
  • the second fully connected layer 604 integrates the category-discriminatory information in the convolutional layers 601 and 602, and finally a normalized exponential function (Softmax) 605 is used to classify the integrated information of the fully connected layer to obtain the running direction prediction result.
  • Softmax normalized exponential function
  • the loss function of the CNN model in this embodiment of the application may adopt a cross-entropy loss function, or other loss functions, such as focal loss function (Focal loss), the loss used for the prediction direction model in this embodiment of the application Functions do not constitute limitations.
  • Loss focal loss function
  • a Tensorflow system can be used to train a CNN classification model, and a cross-entropy loss function and a gradient descent algorithm can be used until the model converges.
  • the running direction prediction model can also use other traditional machine learning classifiers or deep learning classification models, which are not limited in this embodiment.
  • the buffered second acceleration data is input into the trained direction prediction model to obtain the prediction results of each running direction, that is, the prediction probability corresponding to each candidate running direction, where each candidate running direction is The actual running direction of the subway pre-calibrated during the model training process.
  • the prediction results include: the probability that the second acceleration data indicates that the subway direction is southeast is 0.01, the probability that the subway direction is southwest is 0.005, and the probability that the subway direction is northeast is 0.98, the probability of the subway running direction northwest is 0.005.
  • Step 406 Determine the subway running direction according to the predicted probability of each candidate running direction.
  • the running direction with the highest predicted probability is determined as the subway running direction.
  • the gravity sensor and the magnetometer are used to collect the gravity acceleration data and the magnetic force data respectively, so as to obtain the conversion matrix corresponding to the first acceleration data at this time; in addition, by pre-setting in the terminal Set the running direction prediction model, and input the cached second acceleration data into the running direction prediction model, and determine the subway running direction according to the output result of the running direction prediction model, which can improve the accuracy of determining the subway running direction based on the second acceleration data ;
  • the second acceleration data in the input running direction prediction model is acceleration data within a period of time, it can also avoid the problem of inaccurate determination of the subway running direction caused by the instability of a single acceleration direction, and further improve the determination of the subway running direction Accuracy.
  • the attitude of the terminal may change during the collection process, causing the gravity acceleration data and magnetic force data to be changed, and due to the conversion matrix and the gravity acceleration data and magnetic force collected by the terminal in real time If the data is related, the corresponding gravitational acceleration and magnetic data changes will also cause the transformation matrix to change. If the same transformation matrix is used for different collection times, it is obvious that the change of the terminal attitude will cause the determined subway running direction to appear Therefore, in order to further improve the accuracy of the acquired second acceleration data, it is necessary to determine the conversion matrix in real time according to the gravity acceleration data and the magnetic force data, so that the determined conversion matrix conforms to the current holding posture of the terminal.
  • steps 402 to 404 may be replaced with steps 407 to 410.
  • Step 407 Obtain the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2.
  • the linear acceleration sensor, the gravitational acceleration sensor, and the magnetometer in the terminal all perform data collection according to the target sampling frequency, so as to obtain the first acceleration data.
  • the acceleration data, the gravitational acceleration data, and the magnetic force data are all data at the same time, so that the acquired second acceleration data has more reference value.
  • the first acceleration data, gravitational acceleration data, and magnetic data acquired within the target duration are all 200, and the nth gravitational acceleration data is the nth acquisition
  • the obtained gravitational acceleration data, the nth magnetic force data is the magnetic force data collected for the nth time.
  • Step 408 If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then the n-th 1
  • the conversion matrix is determined as the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data.
  • the conversion matrix corresponding to each collection time is related to the gravitational acceleration data and magnetic data collected at the current collection time, in a possible implementation manner, the gravitational acceleration data or magnetic data at adjacent collection time can be compared. , To determine whether the terminal posture has changed, and thus whether the conversion matrix has changed.
  • a similarity threshold is preset in the terminal, and if the terminal determines that the similarity between the nth reacceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the nth magnetic force data and the nth -1 The similarity of the magnetic data is greater than the similarity threshold, it is determined that the posture of the terminal has not changed significantly at the time of the two acquisitions. Therefore, there is no need to recalculate the conversion matrix, and the n-1th conversion matrix can be directly determined as the nth conversion matrix. In order to reduce the amount of calculation of the terminal and save power consumption.
  • the similarity calculation formula can be:
  • d is the similarity, Is the nth gravitational acceleration data, Is the n-1th gravitational acceleration data, convert d to a percentage, that is, obtain the similarity between the nth re-acceleration data and the n-1th gravitational acceleration data.
  • the similarity between the nth magnetic force data and the n-1th magnetic force data can be obtained by referring to the above formula.
  • the similarity threshold may be 98%, that is, when the terminal determines that the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is 98.5%, the similarity between the nth magnetic force data and the n-1th magnetic force data If it is 99% and the similarity is greater than 98%, it is determined that the posture of the terminal has not changed significantly at the time of the two acquisitions, and the n-1th conversion matrix can be used continuously.
  • Step 409 If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic data and the n-1th magnetic data is less than the similarity threshold, then The nth gravitational acceleration data and the nth magnetic force data determine the nth conversion matrix.
  • the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, or the similarity between the nth magnetic data and the n-1th magnetic data is less than the similarity Threshold, it is determined that the attitude of the terminal may change significantly at the time of the two collections, that is, the n-1th conversion matrix has no reference value during the nth collection of data. Therefore, it is necessary to re-based the nth gravitational acceleration data and the nth magnetic force.
  • the data calculates the nth transformation matrix.
  • the similarity threshold may be 98%. If the terminal calculates that the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is 60%, which is less than the similarity threshold, the nth magnetic data and the nth -1 The similarity between the magnetic data is 99%, which is greater than the similarity threshold. It can be seen that the gravitational acceleration has changed significantly. Correspondingly, it is determined that the terminal attitude may change significantly at the time of the two acquisitions. The nth magnetic force data calculates the nth conversion matrix.
  • Step 410 Convert the first acceleration data into second acceleration data through the nth conversion matrix.
  • the first acceleration data collected for the nth time is converted into the nth second acceleration data through the determined nth conversion matrix.
  • the above similarity is greater than the similarity threshold.
  • the terminal Since the terminal needs to collect the first acceleration data when it is determined that the subway is in the acceleration phase, and usually the subway accelerates during the start-up phase, in order to improve the accuracy of the timing of collecting the first acceleration data, it is determined to determine the direction of the subway.
  • the terminal can determine whether the subway is activated by identifying whether the ambient sound includes the subway closing alarm bell, so as to achieve accurate control of the timing of the first acceleration data collection.
  • FIG. 8 shows a flowchart of the process of determining that the subway is in the acceleration phase shown in an exemplary embodiment of the present application.
  • This embodiment uses the method for determining the direction of the subway to be used in the terminal as an example for description.
  • the method includes:
  • Step 801 Collect environmental sounds through a microphone.
  • the terminal can acquire user location information in real time, and when it is determined that the user enters the subway according to the user location information, the terminal can turn on the microphone to collect ambient sound in real time.
  • the terminal confirms that the user enters the subway, and can turn on the microphone to collect ambient sound in real time.
  • the terminal may use a low-power microphone to collect ambient sound in real time.
  • step 802 when it is recognized that the ambient sound includes the subway door-closing alarm bell, it is determined that it is in the subway startup stage.
  • the terminal pre-stores the audio data of the subway closing alarm bell. After the terminal collects the ambient sound through the microphone in real time, it can convert the ambient sound into audio data and perform data processing on the audio data. , So as to identify whether the processed audio data contains the audio data corresponding to the subway closing alarm bell. If it is recognized that the ambient sound contains audio data corresponding to the subway door-closing alarm bell, it is determined that the subway is activated.
  • the pre-stored subway closing alarm ringtone in the terminal can be the user turning on the microphone to collect the subway closing alarm ringtone and save it when taking the subway; or the terminal can obtain the subway corresponding to the subway when the terminal obtains the city's transportation route map.
  • the door-closing alarm ringtone is converted into audio data and saved to the local.
  • the environmental sound may contain a variety of noises
  • the method for determining whether the subway closing alarm ring is included in the current ambient sound to determine whether the subway is activated may include the following steps:
  • the voice recognition model cannot directly recognize audio data, it is necessary to pre-process the audio data to obtain digital features that can be recognized by the voice recognition model. Since the terminal microphone collects ambient sound in real time, its audio data is not stable as a whole, but its parts can be regarded as stable data, and the sound recognition model can only recognize the stable data, so the terminal first divides the corresponding audio data into frames Processing to obtain audio data corresponding to different audio frames.
  • the audio data pre-processing process may be as shown in Figure 9.
  • the audio data is first subjected to the pre-emphasis module 901 for pre-emphasis processing.
  • the pre-emphasis process uses a high-pass filter, which is only allowed to be higher than a certain frequency. The signal components pass through, and the signal components below this frequency are suppressed, thereby removing unnecessary low-frequency interference such as human conversation, footsteps, and mechanical noise in the audio data, and flattening the frequency spectrum of the audio signal.
  • the mathematical expression of the high-pass filter is:
  • a is the correction coefficient, which generally ranges from 0.95 to 0.97
  • z is the audio signal.
  • the noise-removed audio data is subjected to framing processing by the framing and windowing module 902 to obtain audio data corresponding to different audio frames.
  • audio data containing 1024 data points is divided into one frame.
  • the sampling frequency of the audio data is selected as 16000 Hz
  • the duration of one frame of audio data is 64 ms.
  • the audio data is not directly divided into frames in a back-to-back manner, but after each frame of data is fetched , And then slide 32ms to fetch the next frame of data, that is, the data of two adjacent frames overlap by 32ms.
  • a frame of audio data has no obvious periodicity, that is, the left end of the frame and the right end of the frame are not continuous, and after Fourier transform, it will be compared with the original data. Errors will occur. The more frames are divided, the greater the error will be. Therefore, in order to make the framed audio data continuous and each frame of audio data exhibits the characteristics of a periodic function, it is necessary to perform frame and window processing by the frame and window module 902 .
  • a Hamming window is used to perform windowing processing on audio frames. Multiply each frame of data by the Hamming window function, and the resulting audio data has obvious periodicity.
  • the functional form of the Hamming window is:
  • n is an integer
  • n ranges from 0 to M
  • M is the number of Fourier transform points.
  • 1024 data points are taken as Fourier transform points in this embodiment.
  • the audio data after the audio data is framed and windowed, it needs to perform feature extraction to obtain a feature matrix that can be recognized by the voice recognition model, that is, extract the Mel-Frequency Cepstral coefficient of the audio frame. Coefficients, MFCC).
  • the terminal first inputs the audio frame data to the Fourier transform module 903 for processing. Fourier transform, and then input the audio frame data after Fourier transform to the energy spectrum calculation module 904 to calculate the energy spectrum of the audio frame data.
  • the energy spectrum needs to be input to the Mel filter processing module 905 for filtering processing; the mathematical expression of the filtering processing is:
  • f is the frequency point after Fourier transform.
  • the terminal After obtaining the Mel spectrum of the audio frame, the terminal uses a discrete cosine transform (Discrete Cosine Transform, DCT) module 906 to log it, and the obtained DCT coefficient is the MFCC feature.
  • DCT Discrete Cosine Transform
  • the embodiment of the present application selects 40-dimensional MFCC features.
  • the length of the audio data input window is selected to be 1056 ms, and the time length of one frame of signal is 64 ms.
  • the terminal inputs the audio feature matrix obtained after feature extraction of the audio frame into the voice recognition model, and the model recognizes whether the current audio frame contains the subway closing alarm bell, and outputs the recognition result.
  • the terminal cannot obtain the subway closing alarm bell of the current city autonomously, the user needs to collect the subway closing alarm bell in advance. After the subway closing alarm bell is collected, the audio of the subway closing alarm bell will be included. The data is also subjected to the framing processing and feature extraction process in the above step 1, and the audio feature matrix of the subway closing alarm bell is saved locally.
  • the audio feature matrix after preprocessing the environmental sound and the audio feature matrix corresponding to the subway door-closing alarm bell can be directly input into the voice recognition model to facilitate the sound
  • the recognition model is used to compare the similarity of the two audio feature matrices to obtain the similarity of the output of the voice recognition model, so as to determine whether the ambient sound contains the subway closing alarm bell according to the similarity.
  • a similarity threshold is set. When the output of the voice recognition model is similar If the degree is greater than the similarity threshold, it is determined that the ambient sound includes the subway closing alarm bell; conversely, if the similarity is lower than the similarity threshold, it is determined that the ambient sound does not include the subway closing alarm bell.
  • the similarity threshold used to determine whether the ambient sound includes a subway closing alarm bell may be 90%.
  • the voice recognition model has the function of comparing the similarity between two audio data; correspondingly, in the actual application process, the audio feature matrix obtained after the environmental sound preprocessing and the pre-stored audio matrix input containing the subway closing alarm bell can be directly input
  • the alarm bell recognition result output by the voice recognition model is obtained, that is, the similarity of the two audio feature matrices.
  • the terminal processes the audio data into frames before recognizing the subway closing alarm bell, and the time of one frame of audio is very short, when an audio frame contains the target alarm bell, it cannot be ruled out that there are other similar sounds or features
  • the terminal sets a predetermined time period, and when the output result of the voice recognition model indicates that the number of audio frames containing the subway door-closing alarm bell within the predetermined time period reaches the number threshold, it is determined that the ambient sound includes the subway door-closing alarm bell, that is, it is determined that the subway is started.
  • the terminal sets the predetermined duration to 5 seconds and the number threshold to 2.
  • the terminal recognizes that 2 or more audio frames contain the subway closing alarm bell within 5 seconds, it determines that the current ambient sound is Including the subway closing alarm bell, which confirms the subway start.
  • the environmental sound is collected by a microphone, and the environmental sound is preprocessed to obtain an audio matrix, which is input into the voice recognition model, and the output of the alarm bell recognition result is used to determine whether the environmental sound contains the target alarm bell. In this way, it is determined whether the subway is started, the accuracy of determining the start of the subway is improved, and the timing of the first acceleration data collection is accurately controlled.
  • the terminal determines the running direction of the subway based on the second acceleration data, it can be compared with the running direction the user expects to take the subway. If the two directions match, it is determined that the user is taking the correct ride. , It is determined that the user has taken the wrong ride, so as to promptly remind the user to transfer, and reduce the time waste caused by taking the wrong subway.
  • FIG. 10 shows a flowchart of a method for determining whether a user is taking the subway correctly according to an exemplary embodiment of the present application.
  • the method is applied to a terminal as an example for description. Methods include:
  • Step 1001 Determine the end station according to the current station and the target station, and the target station is located between the current station and the end station.
  • the current station indicates the station where the subway currently stops, that is, the user starts to take the subway from the current station; the target station indicates the next station to which the subway starts from the current station.
  • the method for determining the current station and the target station may be that when the user takes the terminal to take the subway, the terminal collects the prompt sound when the subway starts or arrives, and the prompt sound contains the name of the current station and the station of the next station. name.
  • the terminal determines the actual terminal station of the subway operation by obtaining the names of the current station and the target station (next station).
  • the terminal can also obtain the user's location information in real time through map applications, and determine the user's current site and target site based on the user's location information and subway route map, thereby determining the terminal station. This does not constitute a limitation.
  • step 1002 according to the current station and the terminal station, the target subway running direction is searched from the database.
  • the target subway running direction is the running direction when the subway runs from the current station to the terminal station.
  • the database stores subway information of major cities across the country, and the database may include correspondences between cities, subway line identifiers, station names, actual operating directions, and terminal directions.
  • the database may be as shown in Table 1.
  • the terminal determines that the current station is station A and the terminal station is station B, then according to the current station and the terminal station, searching from the database (Table 1) shows that the target subway running direction is To the northeast.
  • step 1003 if the determined subway running direction does not match the target subway running direction, a transfer prompt is performed.
  • a transfer prompt is performed so that the user can get off the train in time , To avoid wasting time caused by taking the wrong subway.
  • the transfer prompt may be a voice reminder, a vibration reminder, etc., and the embodiment of the present application does not limit the manner of the transfer prompt.
  • a confirmation reminder may also be issued, so that the user can determine that the current subway is taking the correct subway without changing.
  • this embodiment may be executed after step 406 shown in FIG. 4 or step 203 shown in FIG. 2.
  • the determined subway operation direction can be compared with the actual subway operation direction searched in the database, so as to promptly remind the user to transfer when the user takes the wrong subway, and avoid taking the wrong subway. The resulting wasted time.
  • the terminal station of the actual subway operation can be determined according to the determined direction of subway operation and the name of the current station, so as to determine the actual subway line the user is currently taking according to the current station and terminal station. Thereby feedback to the user, so that the user can confirm whether the subway line is consistent with the subway line the user expects to take.
  • the process of determining the subway line the user rides on according to the subway running direction may include the following steps:
  • the current station is the station where the subway that the user rides currently stops at.
  • the terminal may collect the subway opening prompt sound or the subway arrival prompt sound to obtain the current station where the user is located.
  • the current station where the user is located can also be determined by obtaining the user's location information and subway route map.
  • the target station may be the terminal station of the subway operation currently taken by the user, or the next station reached by the subway operation taken by the user, or any station between the current station and the terminal station in the current subway operation route.
  • the subway information database of major cities across the country is established in the terminal, and the terminal station or the next station that the subway is going to at the current station can be determined in the database according to the current station and the running direction of the subway.
  • the database can refer to the above embodiment, and this embodiment will not be repeated here.
  • the running direction of the subway determined according to the second acceleration data in the above embodiment may be different from the actual running direction of the subway, it is because for the same subway line where the starting point and the end station of the subway are opposite, the corresponding subway running direction The opposite is true.
  • the subway line runs from station A to station B.
  • the corresponding subway direction is northeast.
  • the corresponding The running direction of the subway is the southwest direction. Therefore, in a possible implementation manner, the corresponding running terminal can be found from the database according to the determined running direction of the subway and the current station.
  • the complete subway route corresponding to the subway the user is currently riding on can be determined according to the current site and the target site, and the subway route is fed back to the user for the user to determine Whether the current subway ride is the subway that they expect to ride, if not, the user can transfer the subway in time to avoid the user from increasing the transportation cost of the user's travel due to the mistake of taking the subway.
  • the target station to which the subway currently traveled by the user is based on the predicted subway running direction in the above embodiment, so as to feedback the current subway running direction to the user, that is, the end of the subway running. This allows the user to determine whether the subway station is consistent with the subway station the user expects to take according to the subway operating station, so as to find out whether the subway is taken incorrectly in time, and avoid the waste of time caused by taking the wrong subway.
  • FIG. 11 shows a structural block diagram of an apparatus for determining a subway running direction provided by an exemplary embodiment of the present application.
  • the device can be implemented as all or a part of the terminal through software, hardware or a combination of the two.
  • the device includes:
  • the acquiring module 1101 is configured to acquire the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
  • the data conversion module 1102 is configured to convert the first acceleration data into second acceleration data, and the second acceleration data includes acceleration data in various directions in the world coordinate system;
  • the first determining module 1103 is configured to determine the running direction of the subway according to the second acceleration data within the target duration.
  • a gravity acceleration sensor and a magnetometer are provided in the terminal;
  • the data conversion module 1102 includes:
  • An acquiring unit configured to acquire the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer, the gravity acceleration data and the magnetic force data being based on the terminal coordinate system;
  • a first determining unit configured to determine a conversion matrix according to the gravity acceleration data and the magnetic force data, the conversion matrix being used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system;
  • the data conversion unit is configured to convert the first acceleration data into the second acceleration data through the conversion matrix.
  • the linear acceleration sensor, the gravity acceleration sensor, and the magnetometer perform data collection according to a target sampling frequency
  • the obtaining unit is further used for:
  • n is an integer greater than or equal to 2;
  • the first determining unit is further configured to:
  • the n-1th conversion matrix is determined to be the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
  • the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic force data and the n-1th magnetic force data Less than the similarity threshold, determine the nth conversion matrix according to the nth gravitational acceleration data and the nth magnetic force data;
  • the data conversion unit is further used for:
  • the first acceleration data is converted into the second acceleration data through the nth conversion matrix.
  • the first determining module 1103 includes:
  • the first output unit is configured to input the second acceleration data within the target duration into a running direction prediction model to obtain a running direction prediction result output by the running direction prediction model.
  • the running direction prediction result includes each candidate The predicted probability corresponding to the running direction;
  • the second determining unit is configured to determine the running direction of the subway according to the predicted probability of each candidate running direction.
  • the running direction prediction model adopts a CNN structure, and the running direction prediction model is obtained by training based on sample acceleration data and sample running direction;
  • the sample acceleration data is the acceleration data of each direction in the world coordinate system during the acceleration phase of the subway, and the sample running direction is the actual running direction of the subway.
  • the device further includes:
  • a second determining module configured to determine an end station based on a current station and a target station, where the target station is located between the current station and the end station;
  • the searching module is configured to search for a target subway running direction from a database according to the current station and the terminal station, where the target subway running direction is the running direction of the subway when the subway runs from the current station to the terminal station;
  • the prompting module is used to perform transfer prompts if the determined running direction of the subway does not match the target running direction of the subway.
  • the subway acceleration phase includes a subway startup phase
  • the device further includes:
  • Collection module used to collect ambient sound through a microphone
  • the third determining module is configured to determine that the subway is in the start-up phase when it is recognized that the ambient sound includes the subway door-closing alarm bell.
  • the third determining module includes:
  • a feature extraction unit configured to perform audio feature extraction on the environmental sound to obtain an audio feature matrix
  • the second output unit is configured to input the audio feature matrix into a voice recognition model to obtain a warning bell recognition result output by the voice recognition model, and the warning bell recognition result is used to indicate whether the ambient sound contains the subway Door-closing alarm bell;
  • the third determining unit is configured to determine that it is in the start-up phase of the subway if the alarm bell recognition result indicates that the environmental sound includes the subway door-closing alarm bell.
  • the first determining unit is further configured to:
  • the terminal when the subway is in the acceleration phase, the terminal collects acceleration data (first acceleration data) in various directions in the terminal coordinate system through the linear acceleration sensor, and transforms the first acceleration data to obtain the world coordinate system Acceleration data (second acceleration data) in each direction, so as to determine the subway running direction according to the second acceleration data within the target duration.
  • first acceleration data acceleration data
  • second acceleration data world coordinate system Acceleration data
  • the influence of the terminal attitude on the acquired acceleration direction is avoided, thereby improving the accuracy of determining the direction of subway operation.
  • the comprehensive analysis of the second acceleration data within the target duration to determine the direction of the subway the problem of inaccurate determination of the direction of the subway due to the instability of a single acceleration direction can be avoided.
  • FIG. 12 shows a structural block diagram of a terminal 1200 according to an exemplary embodiment of the present application.
  • the terminal 1200 may be an electronic device with an application installed and running, such as a smart phone, a tablet computer, an e-book, or a portable personal computer.
  • the terminal 1200 in this application may include one or more of the following components: a processor 1210, a memory 1220, a screen 1230, and a sensor 1240.
  • the processor 1210 may include one or more processing cores.
  • the processor 1210 uses various interfaces and lines to connect various parts of the entire terminal 1200, and executes the terminal by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1220, and calling data stored in the memory 1220.
  • the processor 1210 may adopt at least one of digital signal processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA).
  • DSP Digital Signal Processing
  • FPGA Field-Programmable Gate Array
  • PLA Programmable Logic Array
  • the processor 1210 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like.
  • the CPU mainly processes the operating system, user interface, and application programs;
  • the GPU is used for rendering and drawing the content that needs to be displayed on the screen 1230;
  • the modem is used for processing wireless communication. It is understandable that the above-mentioned modem may not be integrated into the processor 1210, but may be implemented by a communication chip alone.
  • the memory 1220 may include random access memory (RAM) or read-only memory (ROM).
  • the memory 1220 includes a non-transitory computer-readable storage medium.
  • the memory 1220 may be used to store instructions, programs, codes, code sets or instruction sets.
  • the memory 1220 may include a program storage area and a data storage area, where the program storage area may store instructions for implementing the operating system and instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.) ,
  • the instructions used to implement the foregoing various method embodiments, etc., the operating system may be the Android system (including the system based on the in-depth development of the Android system), the IOS system developed by Apple (including the system based on the in-depth development of the IOS system) Or other systems.
  • the data storage area can also store data created during use of the terminal 1200 (such as phone book, audio and video data, chat record data) and the like.
  • the screen 1230 may be a capacitive touch display screen, which is used to receive a user's touch operation on or near any suitable object such as a finger, a touch pen, etc., and display the user interface of each application program.
  • the touch screen is usually set on the front panel of the terminal 1200.
  • the touch screen can be designed as a full screen, curved screen or special-shaped screen.
  • the touch display screen can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in the embodiments of the present application.
  • the sensor 1240 is used to collect sensor data.
  • the sensor 1240 may include a linear acceleration sensor, a gravity acceleration sensor, and a magnetometer.
  • the linear acceleration sensor is used to collect first acceleration data
  • the gravity acceleration sensor is used to obtain gravity acceleration.
  • Data, a magnetometer is used to obtain magnetic data.
  • the terminal 1200 may further include a temperature sensor, a humidity sensor, a pressure sensor, a proximity sensor, etc., which are not limited in the embodiment of the present application.
  • the structure of the terminal 1200 shown in the above drawings does not constitute a limitation on the terminal 1200, and the terminal may include more or less components than those shown in the figure, or a combination of certain components. Components, or different component arrangements.
  • the terminal 1200 also includes radio frequency circuits, photographing components, sensors other than the above-mentioned sensors, audio circuits, wireless fidelity (WiFi) components, power supplies, Bluetooth components and other components, which will not be repeated here.
  • WiFi wireless fidelity
  • the embodiments of the present application also provide a computer-readable medium that stores at least one instruction, and the at least one instruction is loaded and executed by the processor to realize the subway running direction as described in each of the above embodiments.
  • the method of determining is also provided.
  • a computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
  • the processor of the terminal reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the terminal executes the method for determining the subway running direction provided in the various optional implementations of the foregoing aspects.
  • the functions described in the embodiments of the present application can be implemented by hardware, software, firmware, or any combination thereof.
  • these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on the computer-readable medium.
  • the computer-readable medium includes a computer storage medium and a communication medium, where the communication medium includes any medium that facilitates the transfer of a computer program from one place to another.
  • the storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Navigation (AREA)

Abstract

Disclosed are a method and apparatus for determining a running direction of a metro train, and a terminal and a storage medium, wherein same belong to the field of artificial intelligence. The method comprises: at a metro train acceleration stage, acquiring first acceleration data collected by a linear acceleration sensor, wherein the first acceleration data comprises acceleration data of all directions under a terminal coordinate system; converting the first acceleration data into second acceleration data, wherein the second acceleration data comprises acceleration data of all directions under a world coordinate system; and determining the running direction of a metro train according to the second acceleration data within a target time range. The first acceleration data collected by the terminal is converted into second acceleration data, such that the attitude of the terminal is prevented from affecting the acquisition of an acceleration direction; and the second acceleration data within the target time range is comprehensively analyzed, such that the problem of the determined running direction of a metro train being inaccurate caused due to the instability of a single acceleration direction can be avoided.

Description

地铁运行方向的确定方法、装置、终端及存储介质Method, device, terminal and storage medium for determining subway running direction
本申请要求于2019年12月10日提交的申请号为201911259924.2、发明名称为“地铁运行方向的确定方法、装置、终端及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on December 10, 2019 with the application number 201911259924.2 and the invention title "Method, device, terminal and storage medium for determining the direction of subway operation", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请实施例涉及人工智能领域,特别涉及一种地铁运行方向的确定方法、装置、终端及存储介质。The embodiments of the present application relate to the field of artificial intelligence, and in particular to a method, device, terminal, and storage medium for determining the direction of subway operation.
背景技术Background technique
地铁作为一种日常交通工具,能够为人们带来便捷快速的轨道交通服务。As a daily means of transportation, the subway can provide people with convenient and fast rail transit services.
由于地铁运行具有方向性,因此在乘坐地铁时,人们需要根据目的地站点和当前所处站点,选择乘坐相应运行方向的地铁。然而,目前地铁的运行方向需要人为判断,相应的,当所乘坐地铁的运行方向有误时,需要乘坐者自主感知后进行换乘。Due to the directional nature of the subway operation, when taking the subway, people need to choose the subway in the corresponding direction according to the destination station and the current station. However, the current running direction of the subway requires human judgment. Correspondingly, when the running direction of the subway is wrong, the passengers are required to make a transfer after self-perception.
发明内容Summary of the invention
本申请实施例提供了一种地铁运行方向的确定方法、装置、终端及存储介质。所述技术方案如下:The embodiments of the present application provide a method, device, terminal, and storage medium for determining the direction of subway operation. The technical solution is as follows:
一方面,本申请实施例提供了一种地铁运行方向的确定方法,所述方法用于终端,所述方法包括:On the one hand, an embodiment of the present application provides a method for determining a subway running direction, the method is used in a terminal, and the method includes:
在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,所述第一加速度数据中包括终端坐标系下各个方向的加速度数据;During the subway acceleration phase, acquiring first acceleration data collected by the linear acceleration sensor, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
将所述第一加速度数据转换为第二加速度数据,所述第二加速度数据中包括世界坐标系下各个方向的加速度数据;Converting the first acceleration data into second acceleration data, where the second acceleration data includes acceleration data in various directions in the world coordinate system;
根据目标时长内的所述第二加速度数据,确定地铁运行方向。Determine the running direction of the subway according to the second acceleration data within the target duration.
另一方面,本申请实施例提供了一种地铁运行方向的确定装置,所述装置用于终端,所述装置包括:On the other hand, an embodiment of the present application provides a device for determining the direction of subway operation. The device is used in a terminal, and the device includes:
获取模块,用于在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,所述第一加速度数据中包括终端坐标系下各个方向的加速度数据;The acquiring module is configured to acquire the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
数据转换模块,用于将所述第一加速度数据转换为第二加速度数据,所述第二加速度数据中包括世界坐标系下各个方向的加速度数据;A data conversion module, configured to convert the first acceleration data into second acceleration data, the second acceleration data including acceleration data in various directions in the world coordinate system;
第一确定模块,用于根据目标时长内的所述第二加速度数据,确定地铁运行方向。The first determining module is configured to determine the running direction of the subway according to the second acceleration data within the target duration.
另一方面,本申请实施例提供了一种终端,所述终端包括处理器和存储器;所述存储器存储有至少一条指令,所述至少一条指令用于被所述处理器执行以实现如上述方面所述的地铁运行方向的确定方法。On the other hand, an embodiment of the present application provides a terminal, the terminal includes a processor and a memory; the memory stores at least one instruction, and the at least one instruction is used to be executed by the processor to implement the above-mentioned aspects. The method for determining the running direction of the subway.
另一方面,提供了一种计算机可读存储介质,所述存储介质存储有至少一条指令,所述至少一条指令用于被处理器执行以实现如上述方面所述的地铁运行方向的确定方法。In another aspect, a computer-readable storage medium is provided, the storage medium stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the method for determining a subway running direction as described in the above aspect.
另一方面,本申请实施例提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。终端的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该终端执行上述方面的各种可选实现方式中提供的地铁运行方向的确定方法。On the other hand, the embodiments of the present application provide a computer program product or computer program. The computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the terminal reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the terminal executes the method for determining the subway running direction provided in the various optional implementations of the foregoing aspects.
附图说明Description of the drawings
图1示出了本申请一个示例性实施例提供的地铁运行方向的确定方法的流程图;Fig. 1 shows a flowchart of a method for determining a subway running direction provided by an exemplary embodiment of the present application;
图2示出了本申请一个示例性实施例示出的地铁运行方向的确定方法的流程图;Fig. 2 shows a flowchart of a method for determining a subway running direction shown in an exemplary embodiment of the present application;
图3是本申请一个示例性实施例示出的终端坐标系和世界坐标系的示意图;Fig. 3 is a schematic diagram of a terminal coordinate system and a world coordinate system shown in an exemplary embodiment of the present application;
图4示出了本申请另一个示例性实施例示出的地铁运行方向的确定方法的流程图;Fig. 4 shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application;
图5是本申请一个示例性实施例示出的地球重力方向和磁力方向的示意图;Fig. 5 is a schematic diagram showing the direction of gravity and the direction of magnetic force on the earth according to an exemplary embodiment of the present application;
图6是本申请一个示例性实施例示出的运行方向预测模型的框架图;Fig. 6 is a framework diagram of a running direction prediction model shown in an exemplary embodiment of the present application;
图7示出了本申请另一个示例性实施例示出的地铁运行方向的确定方法的流程图;Fig. 7 shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application;
图8示出了本申请一个示例性实施例示出的确定地铁处于加速阶段过程的流程图;FIG. 8 shows a flowchart of a process of determining that a subway is in an acceleration phase shown in an exemplary embodiment of the present application;
图9是本申请一个示例性实施例示出的音频数据预处理的过程示意图;FIG. 9 is a schematic diagram of a process of audio data preprocessing according to an exemplary embodiment of the present application;
图10示出了本申请一个示例性实施例示出的确定用户乘坐地铁是否正确的方法的流程图;FIG. 10 shows a flow chart of a method for determining whether a user takes the subway correctly according to an exemplary embodiment of the present application;
图11示出了本申请一个示例性实施例提供的地铁运行方向的确定装置的结构框图;Fig. 11 shows a structural block diagram of a device for determining a subway running direction provided by an exemplary embodiment of the present application;
图12示出了本申请一个示例性实施例提供的终端的结构方框图。FIG. 12 shows a structural block diagram of a terminal provided by an exemplary embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solutions, and advantages of the present application clearer, the implementation manners of the present application will be described in further detail below in conjunction with the accompanying drawings.
在本文中提及的“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。The "plurality" mentioned herein means two or more. "And/or" describes the association relationship of the associated objects, indicating that there can be three types of relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects before and after are in an "or" relationship.
相关技术中,通常采用两种方式进行地铁运行方向的确定,一种是通过瞬时加速度的方向来确定地铁运行方向:当用户乘坐地铁时,终端中的加速度传感器可以记录瞬时加速度,并通过该瞬时加速度的方向来确定此时地铁的运行方向;另一种是通过指南针(电子罗盘)方向来确定地铁运行方向。In related technologies, two methods are usually used to determine the direction of the subway. One is to determine the direction of the subway by the direction of the instantaneous acceleration: when the user rides the subway, the acceleration sensor in the terminal can record the instantaneous acceleration and pass the instantaneous acceleration. The direction of acceleration determines the running direction of the subway at this time; the other is to determine the running direction of the subway through the compass (electronic compass) direction.
显然,采用相关技术中地铁运行方向的确定方式,一方面,终端中的加速度传感器记录的加速度方向会受到终端姿态的影响,即用户以不同的姿态持握终端,会导致终端检测到的瞬时加速度方向存在差异;且若用户在地铁中处于移动状态,终端中加速度传感器采集到的瞬时加速度不仅包括地铁的加速度,还包括用户移动对终端产生的加速度;此外,地铁在加速过程中会产生一定的震荡现象,使得仅利用某一瞬时加速度方向确定地铁的运行方向,准确度较低。另一方面,利用电子罗盘来确定地铁的运行方向,由于地铁运行会影响电子罗盘的精度,因此,直接利用电子罗盘来确定地铁的运行方向,精确度较低。Obviously, using the method of determining the direction of subway operation in related technologies, on the one hand, the acceleration direction recorded by the acceleration sensor in the terminal will be affected by the terminal posture, that is, the user holding the terminal in different postures will cause the instantaneous acceleration detected by the terminal There are differences in directions; and if the user is moving in the subway, the instantaneous acceleration collected by the acceleration sensor in the terminal includes not only the acceleration of the subway, but also the acceleration generated by the user’s movement on the terminal; in addition, the subway will produce a certain amount of acceleration during the acceleration process. The oscillating phenomenon makes the accuracy of determining the direction of subway operation only by using a certain instantaneous acceleration direction, and the accuracy is low. On the other hand, using the electronic compass to determine the direction of the subway, because the subway operation will affect the accuracy of the electronic compass, therefore, directly using the electronic compass to determine the direction of the subway, the accuracy is low.
为了解决上述问题,本申请实施例提供了一种地铁运行方向的确定方法,该方法包括的流程如图1所示。In order to solve the above-mentioned problem, an embodiment of the present application provides a method for determining the running direction of a subway, and the method includes a process as shown in FIG.
步骤101,获取终端坐标系下的线性加速度。Step 101: Obtain linear acceleration in the terminal coordinate system.
步骤102,通过坐标系转换模块将终端坐标系下的线性加速度转换为世界坐标系下的加速度。Step 102: Convert the linear acceleration in the terminal coordinate system to the acceleration in the world coordinate system through the coordinate system conversion module.
步骤103,获取一段时间内的世界坐标系下的加速度数据。Step 103: Acquire acceleration data in the world coordinate system for a period of time.
一段时间可以是地铁加速阶段,对应缓存地铁加速度阶段的转换为世界坐标系的加速度数据。A period of time can be the acceleration phase of the subway, and the acceleration data converted into the world coordinate system corresponding to the acceleration phase of the subway is cached.
步骤104,将获取到的一段时间内的世界坐标系下的加速度数据输入运行方向预测模型。Step 104: Input the acquired acceleration data in the world coordinate system for a period of time into the running direction prediction model.
将缓存一段时间之后的加速度数据输入运行方向预测模型,可以输出各个候选方向的预测概率。The acceleration data buffered for a period of time is input into the running direction prediction model, and the prediction probability of each candidate direction can be output.
步骤105,根据各个候选运行方向的预测概率,确定地铁运行方向。Step 105: Determine the subway running direction according to the predicted probability of each candidate running direction.
可以将预测概率最高的候选方向确定为地铁运行方向。The candidate direction with the highest predicted probability can be determined as the subway running direction.
本申请实施例中采用的地铁运行方向的确定方法,通过将终端获取到的终端坐标系下的线性加速度转换为世界坐标系中的加速度,由于世界坐标系的唯一性,避免了终端姿态对获 取到的加速度方向的影响,从而提高了确定地铁运行方向的准确性;此外,通过获取一段时间内的世界坐标系下的加速度数据,并将其输入运行方向预测模型中,以便对一段时间内的加速度数据进行综合分析,来确定地铁运行方向,可以避免单个加速度方向不稳定导致确定地铁运行方向不准确的问题。The method for determining the running direction of the subway adopted in the embodiment of this application converts the linear acceleration in the terminal coordinate system acquired by the terminal into the acceleration in the world coordinate system. Due to the uniqueness of the world coordinate system, the terminal attitude pair acquisition is avoided. The impact of the acceleration direction obtained, thereby improving the accuracy of determining the direction of the subway; in addition, by obtaining the acceleration data in the world coordinate system for a period of time, and inputting it into the prediction model of the direction of travel, in order to determine the direction of the subway for a period of time. Comprehensive analysis of the acceleration data to determine the direction of the subway can avoid the problem of inaccurate determination of the direction of the subway due to the instability of a single acceleration direction.
请参考图2,其示出了本申请一个示例性实施例示出的地铁运行方向的确定方法的流程图。本实施例以地铁运行方向的确定方法用于终端为例进行说明,该方法包括:Please refer to FIG. 2, which shows a flowchart of a method for determining a subway running direction shown in an exemplary embodiment of the present application. In this embodiment, the method for determining the running direction of the subway is used in a terminal as an example for description, and the method includes:
步骤201,在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,第一加速度数据中包括终端坐标系下各个方向的加速度数据。Step 201: In the subway acceleration phase, first acceleration data collected by the linear acceleration sensor is acquired, and the first acceleration data includes acceleration data in various directions in the terminal coordinate system.
其中,终端中设置有线性加速度传感器,该线性加速度传感器获取的数据为排除重力影响之后的加速度数据,且为终端坐标系下的加速度数据。The terminal is provided with a linear acceleration sensor, and the data acquired by the linear acceleration sensor is acceleration data after excluding the influence of gravity, and is acceleration data in the terminal coordinate system.
在一种可能的实施方式中,当终端识别到地铁处于加速阶段时,即通过线性加速度传感器采集终端坐标系下各个方向的加速度数据,得到终端坐标系下的第一加速度数据。比如,第一加速度数据可以用向量表示为
Figure PCTCN2020134578-appb-000001
其中x α为终端坐标系下X轴方向的加速度分量,y α为终端坐标系下Y轴方向的加速度分量,z α为终端坐标系下Z轴方向的加速度分量。
In a possible implementation, when the terminal recognizes that the subway is in an acceleration phase, the linear acceleration sensor collects acceleration data in various directions in the terminal coordinate system to obtain the first acceleration data in the terminal coordinate system. For example, the first acceleration data can be expressed as a vector as
Figure PCTCN2020134578-appb-000001
Where x α is the acceleration component in the X-axis direction in the terminal coordinate system, y α is the acceleration component in the Y-axis direction in the terminal coordinate system, and z α is the acceleration component in the Z-axis direction in the terminal coordinate system.
示意性的,终端坐标系可以如图3中的(A)所示,该终端坐标系随着终端姿态而发生改变。Illustratively, the terminal coordinate system may be as shown in (A) in FIG. 3, and the terminal coordinate system changes with the posture of the terminal.
步骤202,将第一加速度数据转换为第二加速度数据,第二加速度数据中包括世界坐标系下各个方向的加速度数据。Step 202: Convert the first acceleration data into second acceleration data, where the second acceleration data includes acceleration data in various directions in the world coordinate system.
由于终端姿态会随着用户的持握姿势不同而发生改变,使得终端坐标系也会随用户的握持姿态发生改变,从而导致第一加速度数据对应的加速度方向随时发生改变,不具有根据第一加速度方向确定地铁运行方向的参考价值,因此,需要将该第一加速度数据转换为世界坐标系下对应的第二加速度数据,且世界坐标系不会受终端姿态的影响。Since the terminal posture will change with the user’s holding posture, the terminal coordinate system will also change with the user’s holding posture, which causes the acceleration direction corresponding to the first acceleration data to change at any time. The acceleration direction determines the reference value of the subway running direction. Therefore, the first acceleration data needs to be converted into the corresponding second acceleration data in the world coordinate system, and the world coordinate system will not be affected by the terminal posture.
示意性的,世界坐标系可以如图3中的(B)所示,其中,世界坐标系中的Z轴垂直地面向上,Y轴指向北,X轴指向东。Illustratively, the world coordinate system may be as shown in (B) of FIG. 3, where the Z axis in the world coordinate system is perpendicular to the ground upward, the Y axis points to the north, and the X axis points to the east.
在一种可能的实施方式中,根据世界坐标系与终端坐标系中的数据转换关系,将第一加速度数据转换为世界坐标系下的第二加速度数据。比如,若第二加速度数据与第一加速度数据之间的关系为
Figure PCTCN2020134578-appb-000002
其中,
Figure PCTCN2020134578-appb-000003
表示第二加速度数据,R表示第一加速度数据与第二加速度数据之间的数据转换关系,
Figure PCTCN2020134578-appb-000004
表示第一加速度数据;则根据第一加速度数据
Figure PCTCN2020134578-appb-000005
和数据转换关系R,其中,x α为终端坐标系下,第一加速度数据在X轴方向上的加速度分量,y α为终端坐标系下,第一加速度数据在Y轴方向上的加速度分量,z α为终端坐标系下,第一加速度数据在Z轴方向上的加速度分量;可以得到第二加速度数据
Figure PCTCN2020134578-appb-000006
其中,x β为世界坐标系下,第二加速度数据在X轴方向上的加速度分量,y β为世界坐标系下,第二加速度数据在Y轴方向上的加速度分量,z β为世界坐标系下,第二加速度数据在Z轴方向上的加速度分量。
In a possible implementation manner, the first acceleration data is converted into the second acceleration data in the world coordinate system according to the data conversion relationship between the world coordinate system and the terminal coordinate system. For example, if the relationship between the second acceleration data and the first acceleration data is
Figure PCTCN2020134578-appb-000002
among them,
Figure PCTCN2020134578-appb-000003
Represents the second acceleration data, R represents the data conversion relationship between the first acceleration data and the second acceleration data,
Figure PCTCN2020134578-appb-000004
Indicates the first acceleration data; according to the first acceleration data
Figure PCTCN2020134578-appb-000005
And data conversion relationship R, where x α is the acceleration component of the first acceleration data in the X-axis direction in the terminal coordinate system, and y α is the acceleration component of the first acceleration data in the Y-axis direction in the terminal coordinate system, z α is the acceleration component of the first acceleration data in the Z-axis direction in the terminal coordinate system; the second acceleration data can be obtained
Figure PCTCN2020134578-appb-000006
Among them, x β is the acceleration component of the second acceleration data in the X-axis direction in the world coordinate system, y β is the acceleration component of the second acceleration data in the Y-axis direction in the world coordinate system, and z β is the world coordinate system Next, the acceleration component of the second acceleration data in the Z-axis direction.
步骤203,根据目标时长内的第二加速度数据,确定地铁运行方向。Step 203: Determine the running direction of the subway according to the second acceleration data within the target duration.
由于地铁在加速阶段单个点的加速度方向非常不稳定,但是在整个加速时间段来看,加速度的总体方向是稳定的,因此,本申请实施例利用地铁加速时间段内的所有加速度的方向来综合判断地铁的运行方向。Since the acceleration direction of a single point of the subway is very unstable during the acceleration phase, the overall direction of the acceleration is stable during the entire acceleration time period. Therefore, the embodiment of the present application uses all the acceleration directions during the subway acceleration time period to synthesize Determine the direction of the subway.
其中,目标时长是开发人员预先设置的,该目标时长可以是开发人员综合分析地铁实际运行中的加速时间来确定的。可选的,目标时长可以是地铁启动时的加速度时长,也可以是该加速度时长中的一段时间。Among them, the target duration is preset by the developer, and the target duration may be determined by the developer by comprehensively analyzing the acceleration time in actual subway operation. Optionally, the target duration may be the acceleration duration when the subway starts, or it may be a period of time in the acceleration duration.
在一种可能的实施方式中,终端在目标时长内连续采集第一加速度数据,将其转换为第二加速度数据,并存储在终端中,以便后续对目标时长中的加速度数据进行综合分析。比如,目标时长可以是10s,即终端在10s内连续采集第一加速度数据,并实时将其转换为第二加速度数据,从而根据10s内的第二加速度数据来综合分析地铁运行方向。In a possible implementation manner, the terminal continuously collects the first acceleration data within the target duration, converts it into the second acceleration data, and stores it in the terminal, so that the acceleration data in the target duration can be subsequently comprehensively analyzed. For example, the target duration may be 10s, that is, the terminal continuously collects the first acceleration data within 10s, and converts it into second acceleration data in real time, so as to comprehensively analyze the subway running direction based on the second acceleration data within 10s.
在一种可能的实施方式中,终端根据缓存的第二加速度数据进行综合分析,得到该目标时长内的第二加速度数据总体对应的加速度方向,并将该加速度方向确定为地铁运行方向。In a possible implementation manner, the terminal performs a comprehensive analysis according to the second acceleration data buffered to obtain the overall acceleration direction corresponding to the second acceleration data within the target duration, and determines the acceleration direction as the subway running direction.
综上所述,本申请实施例中,当地铁处于加速阶段时,终端通过线性加速度传感器采集终端坐标系下各个方向的加速度数据(第一加速度数据),并对该第一加速度数据进行转换,得到世界坐标系下各个方向的加速度数据(第二加速度数据),从而根据目标时长内的第二加速度数据,确定地铁运行方向。通过将终端采集到的第一加速度数据转换为第二加速度数据,由于世界坐标系的唯一性,避免了终端姿态对获取到的加速度方向的影响,从而提高了确定地铁运行方向的准确性,此外,通过对目标时长内的第二加速度数据进行综合分析,来确定地铁运行方向,可以避免单个加速度方向不稳定导致确定地铁运行方向不准确的问题。To sum up, in the embodiment of the present application, when the subway is in the acceleration phase, the terminal collects acceleration data (first acceleration data) in various directions in the terminal coordinate system through the linear acceleration sensor, and converts the first acceleration data. Obtain acceleration data (second acceleration data) in each direction in the world coordinate system, so as to determine the subway running direction according to the second acceleration data within the target duration. By converting the first acceleration data collected by the terminal into the second acceleration data, due to the uniqueness of the world coordinate system, the influence of the terminal attitude on the acquired acceleration direction is avoided, thereby improving the accuracy of determining the direction of subway operation. In addition, , Through the comprehensive analysis of the second acceleration data within the target duration to determine the direction of the subway, the problem of inaccurate determination of the direction of the subway due to the instability of a single acceleration direction can be avoided.
可选的,终端中设置有重力加速度传感器和磁力计;Optionally, a gravity acceleration sensor and a magnetometer are provided in the terminal;
将第一加速度数据转换为第二加速度数据,包括:Converting the first acceleration data to the second acceleration data includes:
获取重力加速度传感器采集到的重力加速度数据,以及磁力计采集到的磁力数据,重力加速度数据和磁力数据基于终端坐标系;Obtain the gravity acceleration data collected by the gravity acceleration sensor and the magnetic data collected by the magnetometer. The gravity acceleration data and the magnetic data are based on the terminal coordinate system;
根据重力加速度数据和磁力数据确定转换矩阵,转换矩阵用于将终端坐标系下的加速度数据转换为世界坐标系下的加速度数据;Determine the conversion matrix according to the gravity acceleration data and the magnetic data, and the conversion matrix is used to convert the acceleration data in the terminal coordinate system into the acceleration data in the world coordinate system;
通过转换矩阵,将第一加速度数据转换为第二加速度数据。Through the conversion matrix, the first acceleration data is converted into the second acceleration data.
可选的,线性加速度传感器、重力加速度传感器和磁力计按照目标采样频率进行数据采集;Optionally, linear acceleration sensors, gravity acceleration sensors and magnetometers collect data according to the target sampling frequency;
获取重力加速度传感器采集到的重力加速度数据,以及磁力计采集到的磁力数据,包括:Obtain the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer, including:
获取重力加速度传感器采集到的第n重力加速度数据,以及磁力计采集到的第n磁力数据,n为大于等于2的整数;Obtain the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2;
根据重力加速度数据和磁力数据确定转换矩阵,包括:Determine the conversion matrix based on the gravitational acceleration data and the magnetic force data, including:
若第n重力加速度数据与第n-1重力加速度数据的相似度大于相似度阈值,且第n磁力数据与第n-1磁力数据的相似度大于相似度阈值,则将第n-1转换矩阵确定为第n转换矩阵,第n-1转换矩阵根据第n-1重力加速度数据和第n-1磁力数据确定得到;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then the n-1th conversion matrix Determined as the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
若第n重力加速度数据与第n-1重力加速度数据的相似度小于相似度阈值,和/或,第n磁力数据与第n-1磁力数据的相似度小于相似度阈值,则根据第n重力加速度数据和第n磁力数据确定第n转换矩阵;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic data and the n-1th magnetic data is less than the similarity threshold, then according to the nth gravity The acceleration data and the n-th magnetic force data determine the n-th conversion matrix;
通过转换矩阵,将第一加速度数据转换为第二加速度数据,包括:Converting the first acceleration data to the second acceleration data through the conversion matrix includes:
通过第n转换矩阵,将第一加速度数据转换为第二加速度数据。Through the nth conversion matrix, the first acceleration data is converted into the second acceleration data.
可选的,根据目标时长内的第二加速度数据,确定地铁运行方向,包括:Optionally, determining the direction of subway operation according to the second acceleration data within the target duration includes:
将目标时长内的第二加速度数据输入运行方向预测模型,得到运行方向预测模型输出的运行方向预测结果,运行方向预测结果中包括各个候选运行方向对应的预测概率;Input the second acceleration data within the target duration into the running direction prediction model to obtain the running direction prediction result output by the running direction prediction model. The running direction prediction result includes the predicted probability corresponding to each candidate running direction;
根据各个候选运行方向的预测概率,确定地铁运行方向。According to the predicted probability of each candidate running direction, the subway running direction is determined.
可选的,运行方向预测模型采用卷积神经网络CNN结构,运行方向预测模型根据样本加速度数据和样本运行方向训练得到;Optionally, the running direction prediction model adopts the convolutional neural network CNN structure, and the running direction prediction model is trained based on the sample acceleration data and the sample running direction;
样本加速度数据是地铁加速阶段,世界坐标系下各个方向的加速度数据,样本运行方向是地铁的实际运行方向。The sample acceleration data is the acceleration data in all directions in the world coordinate system during the acceleration phase of the subway, and the sample running direction is the actual running direction of the subway.
可选的,根据目标时长内的第二加速度数据,确定地铁运行方向之后,方法还包括:Optionally, after determining the subway running direction according to the second acceleration data within the target duration, the method further includes:
根据当前站点和目标站点确定终点站点,目标站点位于当前站点与终点站点之间;Determine the end station based on the current station and the target station, and the target station is located between the current station and the end station;
根据当前站点和终点站点,从数据库中查找目标地铁运行方向,目标地铁运行方向是地铁由当前站点运行至终点站点时的运行方向;According to the current station and the terminal station, find the target subway running direction from the database. The target subway running direction is the running direction when the subway runs from the current station to the terminal station;
若确定出的地铁运行方向与目标地铁运行方向不匹配,则进行换乘提示。If the determined subway running direction does not match the target subway running direction, a transfer prompt will be given.
可选的,地铁加速阶段包括地铁启动阶段;Optionally, the subway acceleration phase includes the subway startup phase;
在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据之前,方法还包括:In the subway acceleration stage, before acquiring the first acceleration data collected by the linear acceleration sensor, the method further includes:
通过麦克风采集环境音;Collect ambient sound through a microphone;
当识别出环境音中包括地铁关门警铃声时,确定处于地铁启动阶段。When it is recognized that the ambient sound includes the subway closing alarm bell, it is determined that the subway is in the start-up phase.
可选的,当识别出环境音中包括地铁关门警铃声时,确定处于地铁启动阶段,包括:Optionally, when it is recognized that the ambient sound includes the subway closing alarm bell, it is determined that it is in the subway startup stage, including:
对环境音进行音频特征提取,得到音频特征矩阵;Perform audio feature extraction on environmental sounds to obtain an audio feature matrix;
将音频特征矩阵输入声音识别模型,得到声音识别模型输出的警铃声识别结果,警铃声识别结果用于指示环境音中是否包含地铁关门警铃声;Input the audio feature matrix into the voice recognition model to obtain the alarm ringtone recognition result output by the voice recognition model. The alarm ringtone recognition result is used to indicate whether the ambient sound contains the subway closing alarm ringtone;
若警铃声识别结果指示环境音中包含地铁关门警铃声,则确定处于地铁启动阶段。If the alarm bell recognition result indicates that the ambient sound includes a subway closing alarm bell, it is determined that it is in the subway startup stage.
可选的,根据所述重力加速度数据和磁力数据确定转换矩阵,包括:Optionally, determining the conversion matrix according to the gravity acceleration data and the magnetic force data includes:
根据重力加速度数据和磁力数据,确定世界坐标系下各个方向上的单位向量在终端坐标系中对应的目标向量;According to the gravitational acceleration data and the magnetic force data, determine the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system;
根据单位向量和目标向量,确定世界坐标系和终端坐标系之间的转换矩阵。According to the unit vector and the target vector, the conversion matrix between the world coordinate system and the terminal coordinate system is determined.
在一种可能的实施方式中,为了提高根据第二加速度数据确定地铁运行方向的准确性,可以在终端中预先设置运行方向预测模型,将第二加速度数据作为模型输入,从而根据输出的各个候选运行方向的预测概率来判断当前地铁运行方向。In a possible implementation, in order to improve the accuracy of determining the running direction of the subway based on the second acceleration data, a prediction model of the running direction can be preset in the terminal, and the second acceleration data can be used as the model input, so as to output each candidate The predicted probability of the running direction is used to judge the current running direction of the subway.
请参考图4,其示出了本申请另一个示例性实施例示出的地铁运行方向的确定方法的流程图。本实施例以地铁运行方向的确定方法用于终端为例进行说明,该方法包括:Please refer to FIG. 4, which shows a flowchart of a method for determining a subway running direction shown in another exemplary embodiment of the present application. In this embodiment, the method for determining the running direction of the subway is used in a terminal as an example for description, and the method includes:
步骤401,在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据。Step 401: In the subway acceleration phase, first acceleration data collected by the linear acceleration sensor is acquired.
本步骤的实施方式可以参考步骤201,本实施例在此不做赘述。For the implementation of this step, reference may be made to step 201, which is not described in detail in this embodiment.
步骤402,获取重力加速度传感器采集到的重力加速度数据,以及磁力计采集到的磁力数据,重力加速度数据和磁力数据基于终端坐标系。Step 402: Obtain the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer. The gravity acceleration data and the magnetic force data are based on the terminal coordinate system.
其中,终端中设置有重力加速度传感器和磁力计,重力加速度传感器采集到的是终端坐标系下的重力加速度数据,而磁力计采集的是终端坐标系下的磁力数据。Among them, the terminal is provided with a gravity acceleration sensor and a magnetometer. The gravity acceleration sensor collects gravity acceleration data in the terminal coordinate system, and the magnetometer collects magnetic force data in the terminal coordinate system.
在一种可能的实施方式中,重力传感器获取到的在终端坐标系下的重力加速度数据可以表示为
Figure PCTCN2020134578-appb-000007
其中,G x为重力加速度数据在X轴方向的加速度分量,G y为重力加速度数据在Y轴方向的加速度分量,G z为重力加速度数据在Z轴方向的加速度分量;磁力计获取到的在终端坐标系下的磁力数据可以表示为
Figure PCTCN2020134578-appb-000008
其中,M x为磁力数据在X轴方向的磁场分量,M y为磁力数据在Y轴方向的磁场分量,M z为磁力数据在Z轴方向的磁场分量。
In a possible implementation, the gravity acceleration data in the terminal coordinate system acquired by the gravity sensor can be expressed as
Figure PCTCN2020134578-appb-000007
Among them, G x is the acceleration component of the gravitational acceleration data in the X-axis direction, G y is the acceleration component of the gravitational acceleration data in the Y-axis direction, and G z is the acceleration component of the gravitational acceleration data in the Z-axis direction; The magnetic data in the terminal coordinate system can be expressed as
Figure PCTCN2020134578-appb-000008
Wherein, M x is a magnetic data magnetic field component data in the Y-axis direction, M z for the component of the magnetic field data in the Z-axis direction magnetic field component in the X-axis direction, M y.
示意性的,地球的重力和磁力示意图如图5所示,其中,G竖直向下,也就是与图3中的(B)所示的世界坐标系中的Z轴方向相反;由于磁感线的方向由地球南极指向地球北极,因此,磁力的方向如图5中的M所示。Schematically, a schematic diagram of the gravity and magnetic force of the earth is shown in Figure 5, where G is vertically downward, that is, the direction of the Z axis in the world coordinate system shown in (B) in Figure 3 is opposite; due to the magnetic induction The direction of the line is from the south pole of the earth to the north pole of the earth. Therefore, the direction of the magnetic force is shown as M in Figure 5.
需要说明的是,步骤401和步骤402可以同时执行,不存在先后顺序,即当确定地铁处于加速阶段时,终端中的线性加速度传感器、重力加速度传感器以及磁力计同时开始采集数据。It should be noted that step 401 and step 402 can be performed at the same time, and there is no sequence, that is, when it is determined that the subway is in the acceleration phase, the linear acceleration sensor, the gravity acceleration sensor, and the magnetometer in the terminal start to collect data at the same time.
步骤403,根据重力加速度数据和磁力数据确定转换矩阵,转换矩阵用于将终端坐标系下的加速度数据转换为世界坐标系下的加速度数据。Step 403: Determine a conversion matrix according to the gravity acceleration data and the magnetic force data, and the conversion matrix is used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system.
在一种可能的实施方式中,根据重力加速度数据和磁力数据确定转换矩阵的过程可以包括以下步骤:In a possible implementation manner, the process of determining the conversion matrix according to the gravitational acceleration data and the magnetic force data may include the following steps:
一、根据重力加速度数据和磁力数据,确定世界坐标系下各个方向上的单位向量在终端坐标系中对应的目标向量。1. Determine the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system according to the gravitational acceleration data and the magnetic force data.
本申请实施例中,基于单位向量在世界坐标系和终端坐标系中的表示关系,来确定终端采集到第一加速度数据和第二加速度数据之间的转换关系。由于世界坐标系下的单位向量与重力加速度和磁力数据有关,比如,世界坐标系下的Z轴单位向量的方向与重力加速度相反,对应可以采用重力加速度数据来表示世界坐标下的Z轴单位向量,因此,在一种可能的实施方式中,可以根据终端采集到的重力加速度数据和磁力数据,确定世界坐标系下各个方向上的单位向量在终端坐标系中对应的目标向量。In the embodiment of the present application, the conversion relationship between the first acceleration data and the second acceleration data collected by the terminal is determined based on the representation relationship of the unit vector in the world coordinate system and the terminal coordinate system. Since the unit vector in the world coordinate system is related to the gravitational acceleration and magnetic force data, for example, the direction of the Z-axis unit vector in the world coordinate system is opposite to the gravitational acceleration, and the corresponding gravity acceleration data can be used to represent the Z-axis unit vector in the world coordinate system. Therefore, in a possible implementation manner, the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system can be determined according to the gravitational acceleration data and the magnetic force data collected by the terminal.
示意性的,由于重力传感器获取到的重力加速度数据与世界坐标系中的Z轴的单位向量相反,因此,根据
Figure PCTCN2020134578-appb-000009
可以得到世界坐标系Z轴单位向量在终端坐标系中表示为
Figure PCTCN2020134578-appb-000010
Schematically, since the gravitational acceleration data obtained by the gravity sensor is opposite to the unit vector of the Z axis in the world coordinate system, according to
Figure PCTCN2020134578-appb-000009
It can be obtained that the Z-axis unit vector of the world coordinate system is expressed in the terminal coordinate system as
Figure PCTCN2020134578-appb-000010
可选的,由图5和图3中的(B)可以看出,
Figure PCTCN2020134578-appb-000011
Figure PCTCN2020134578-appb-000012
的叉乘可以得到垂直于
Figure PCTCN2020134578-appb-000013
Figure PCTCN2020134578-appb-000014
构成的平面的向量
Figure PCTCN2020134578-appb-000015
且该向量
Figure PCTCN2020134578-appb-000016
的方向在世界坐标系中指向西,与图3中的(B)所示的X轴的单位向量相反,因此,可以得到世界坐标系X轴单位向量在终端坐标系中表示为:
Figure PCTCN2020134578-appb-000017
其中,H x、H y、H z分别为世界坐标系X轴单位向量,在终端坐标系下分别对应的X、Y、Z三个轴方向上的分量。
Optionally, as can be seen from (B) in Figure 5 and Figure 3,
Figure PCTCN2020134578-appb-000011
with
Figure PCTCN2020134578-appb-000012
The cross product of can be obtained perpendicular to
Figure PCTCN2020134578-appb-000013
with
Figure PCTCN2020134578-appb-000014
Vector of the plane composed
Figure PCTCN2020134578-appb-000015
And the vector
Figure PCTCN2020134578-appb-000016
The direction of is pointing to the west in the world coordinate system, which is opposite to the unit vector of the X axis shown in (B) in Figure 3. Therefore, the unit vector of the X axis of the world coordinate system can be expressed in the terminal coordinate system as:
Figure PCTCN2020134578-appb-000017
Among them, H x , H y , and H z are the unit vectors of the X axis of the world coordinate system, respectively, corresponding to the components in the X, Y, and Z directions of the terminal coordinate system.
可选的,已知世界坐标系中的X轴单位向量
Figure PCTCN2020134578-appb-000018
和Z轴单位向量
Figure PCTCN2020134578-appb-000019
由于Y轴垂直于X轴和Z轴构成的平面,因此,根据向量
Figure PCTCN2020134578-appb-000020
和向量
Figure PCTCN2020134578-appb-000021
可以得到Y轴的单位向量
Figure PCTCN2020134578-appb-000022
Optionally, the X-axis unit vector in the known world coordinate system
Figure PCTCN2020134578-appb-000018
And the Z-axis unit vector
Figure PCTCN2020134578-appb-000019
Since the Y axis is perpendicular to the plane formed by the X axis and the Z axis, according to the vector
Figure PCTCN2020134578-appb-000020
And vector
Figure PCTCN2020134578-appb-000021
You can get the unit vector of the Y axis
Figure PCTCN2020134578-appb-000022
在一种可能的实施方式中,获取到世界坐标系三个轴单位向量(单位向量)在终端坐标系中表示(目标向量)为:In a possible implementation, the obtained three-axis unit vectors (unit vectors) of the world coordinate system are expressed in the terminal coordinate system (target vectors) as:
Figure PCTCN2020134578-appb-000023
Figure PCTCN2020134578-appb-000023
Figure PCTCN2020134578-appb-000024
Figure PCTCN2020134578-appb-000024
Figure PCTCN2020134578-appb-000025
Figure PCTCN2020134578-appb-000025
二、根据单位向量和目标向量,确定世界坐标系和终端坐标系之间的转换矩阵。2. Determine the conversion matrix between the world coordinate system and the terminal coordinate system according to the unit vector and the target vector.
由于单位向量为世界坐标系下的向量,而目标向量为同一单位向量在终端坐标系下的表示,也就是说,单位向量和目标向量是相同向量在不同坐标系下的表示,因此,在一种可能的实施方式中,可以根据单位向量和目标向量之间的关系,计算得到世界坐标系和终端坐标系之间的转换关系,也就对应得到同一加速度数据在终端坐标系和世界坐标系中的转换关系。Since the unit vector is a vector in the world coordinate system, and the target vector is the representation of the same unit vector in the terminal coordinate system, that is, the unit vector and the target vector are the representation of the same vector in different coordinate systems. In a possible implementation manner, the conversion relationship between the world coordinate system and the terminal coordinate system can be calculated according to the relationship between the unit vector and the target vector, and the same acceleration data in the terminal coordinate system and the world coordinate system can be correspondingly obtained. The conversion relationship.
示意性的,假设有转换矩阵R以及终端坐标系中的一点
Figure PCTCN2020134578-appb-000026
(即单位向量在终端坐标系中的表示)和世界坐标系中的一点
Figure PCTCN2020134578-appb-000027
(即单位向 量在世界坐标系中的表示),则有:
Schematically, suppose there is a transformation matrix R and a point in the terminal coordinate system
Figure PCTCN2020134578-appb-000026
(I.e. the representation of the unit vector in the terminal coordinate system) and a point in the world coordinate system
Figure PCTCN2020134578-appb-000027
(That is, the representation of the unit vector in the world coordinate system), then:
Figure PCTCN2020134578-appb-000028
Figure PCTCN2020134578-appb-000028
由于
Figure PCTCN2020134578-appb-000029
分别为世界坐标系中的X轴,Y轴以及Z轴的单位向量,因此有:
due to
Figure PCTCN2020134578-appb-000029
They are the unit vectors of the X-axis, Y-axis and Z-axis in the world coordinate system, so there are:
Figure PCTCN2020134578-appb-000030
Figure PCTCN2020134578-appb-000030
Figure PCTCN2020134578-appb-000031
Figure PCTCN2020134578-appb-000031
Figure PCTCN2020134578-appb-000032
Figure PCTCN2020134578-appb-000032
将上述向量分别带入公式(1)可以得到:Put the above vectors into formula (1) respectively to get:
Figure PCTCN2020134578-appb-000033
Figure PCTCN2020134578-appb-000033
Figure PCTCN2020134578-appb-000034
Figure PCTCN2020134578-appb-000034
Figure PCTCN2020134578-appb-000035
Figure PCTCN2020134578-appb-000035
转换为矩阵形式即:
Figure PCTCN2020134578-appb-000036
Converted to matrix form:
Figure PCTCN2020134578-appb-000036
由于
Figure PCTCN2020134578-appb-000037
为单位矩阵E,则公式(2)可以表示为:
due to
Figure PCTCN2020134578-appb-000037
Is the identity matrix E, the formula (2) can be expressed as:
R·D=E  (3)R·D=E (3)
其中,
Figure PCTCN2020134578-appb-000038
由于D为正交矩阵,即D -1=D T,因此:
among them,
Figure PCTCN2020134578-appb-000038
Since D is an orthogonal matrix, that is, D -1 =D T , therefore:
Figure PCTCN2020134578-appb-000039
Figure PCTCN2020134578-appb-000039
其中,R即为转换矩阵,由公式(4)可知,该转换矩阵R与重力加速度数据和磁力数据有关。因此,在一种可能的实施方式中,当终端通过线性加速度传感器采集第一加速度数据的同时,通过重力加速度传感器和磁力计分别获取对应的重力加速度和磁力数据,并按照上述转换矩阵R与重力加速度值以及磁力数据的关系,得到此时第一加速度数据对应的转换矩阵R。Among them, R is the conversion matrix. From the formula (4), it can be known that the conversion matrix R is related to gravitational acceleration data and magnetic force data. Therefore, in a possible implementation manner, when the terminal collects the first acceleration data through the linear acceleration sensor, the corresponding gravitational acceleration and magnetic force data are respectively acquired through the gravity acceleration sensor and the magnetometer, and the corresponding gravitational acceleration and magnetic force data are obtained according to the above conversion matrix R and gravity. According to the relationship between the acceleration value and the magnetic data, the conversion matrix R corresponding to the first acceleration data at this time is obtained.
步骤404,通过转换矩阵,将第一加速度数据转换为第二加速度数据。Step 404: Convert the first acceleration data into second acceleration data through the conversion matrix.
在一种可能的实施方式中,当终端获取到第一加速度数据对应的转换矩阵之后,将第一加速度数据和转换矩阵带入公式(1)中,可以得到第一加速度数据对应的世界坐标系下的第二加速度数据。In a possible implementation manner, after the terminal obtains the conversion matrix corresponding to the first acceleration data, the first acceleration data and the conversion matrix are brought into formula (1), and the world coordinate system corresponding to the first acceleration data can be obtained. Under the second acceleration data.
示意性的,若第一加速度数据记为L_ACC α,该第一加速度数据对应的转换矩阵为R,则根据公式(1),可得,第二加速度数据为L_ACC β=R·L_ACC αIllustratively, if the first acceleration data is denoted as L_ACC α , and the conversion matrix corresponding to the first acceleration data is R, then according to formula (1), it can be obtained that the second acceleration data is L_ACC β =R·L_ACC α .
步骤405,将目标时长内的第二加速度数据输入运行方向预测模型,得到运行方向预测模型输出的运行方向预测结果,运行方向预测结果中包括各个候选运行方向对应的预测概率。Step 405: Input the second acceleration data within the target duration into the running direction prediction model to obtain the running direction prediction result output by the running direction prediction model. The running direction prediction result includes the predicted probability corresponding to each candidate running direction.
在一种可能的实施方式中,运行方向预测模型采用卷积神经网络(Convolutional Neural Network,CNN)结构,该模型的训练过程如下:In a possible implementation manner, the running direction prediction model adopts a convolutional neural network (Convolutional Neural Network, CNN) structure, and the training process of the model is as follows:
一、采集训练样本数据。1. Collect training sample data.
其中,训练样本数据包括样本加速度数据和样本运行方向,样本加速度数据是地铁加速阶段,世界坐标系下各个方向的加速度数据,样本运行方向是地铁的实际运行方向。Among them, the training sample data includes the sample acceleration data and the sample running direction. The sample acceleration data is the acceleration data of the subway in various directions under the world coordinate system, and the sample running direction is the actual running direction of the subway.
在一种可能的实施方式中,开发人员预先采集各个地铁站的地铁加速阶段的加速度数据,由于该加速度数据是终端坐标系下的加速度数据,为了避免终端姿态对加速度方向的影响,将其按照上文所述的步骤转换为世界坐标系下的加速度数据,再根据该站点地铁实际运行方向对该加速度数据进行标记,比如,将地铁的实际运行方向分为东南方向、西南方向、东北方向、西北方向等,并将各个实际运行方向标记为0、1、2、3等,即0代表东南方向、1代表西南方向、2代表东北方向、3代表西北方向等。In a possible implementation manner, the developer collects the acceleration data of the subway acceleration phase of each subway station in advance. Since the acceleration data is the acceleration data in the terminal coordinate system, in order to avoid the influence of the terminal attitude on the acceleration direction, it is The steps described above are converted into acceleration data in the world coordinate system, and then the acceleration data is marked according to the actual running direction of the subway at the station. For example, the actual running direction of the subway is divided into southeast, southwest, northeast, Northwest, etc., and each actual operating direction is marked as 0, 1, 2, 3, etc., that is, 0 represents the southeast direction, 1 represents the southwest direction, 2 represents the northeast direction, and 3 represents the northwest direction.
可选的,该站点地铁的实际运行方向可以根据地图类应用得到。Optionally, the actual running direction of the subway at the station can be obtained according to map applications.
可选的,地铁的实际运行方向还可以包括东、南、西、北等,或者是更细致的划分,比如,北偏东30°,本申请实施例对样本运行方向的表示不构成限定。Optionally, the actual running direction of the subway may also include east, south, west, north, etc., or a more detailed division, for example, 30° from north to east. The embodiment of the present application does not limit the representation of the running direction of the sample.
二、构建CNN模型。2. Construct a CNN model.
在一种可能的实施方式中,CNN模型结构如图6所示,第一卷积层601和第二卷积层602用于提取输入的样本加速度数据的特征,第一全连接层603和第二全连接层604整合卷积层601和602中具有类别区分性的信息,最后接归一化指数函数(Softmax)605,将全连接层整合的信息进行分类,得到运行方向预测结果。In a possible implementation manner, the CNN model structure is shown in FIG. 6, the first convolutional layer 601 and the second convolutional layer 602 are used to extract the characteristics of the input sample acceleration data, and the first fully connected layer 603 and the second convolutional layer The second fully connected layer 604 integrates the category-discriminatory information in the convolutional layers 601 and 602, and finally a normalized exponential function (Softmax) 605 is used to classify the integrated information of the fully connected layer to obtain the running direction prediction result.
可选的,本申请实施例中该CNN模型的损失函数可以采用交叉熵损失函数,也可以采用其他的损失函数,比如焦点损失函数(Focal loss),本申请实施例对预测方向模型采用的损失函数不构成限定。Optionally, the loss function of the CNN model in this embodiment of the application may adopt a cross-entropy loss function, or other loss functions, such as focal loss function (Focal loss), the loss used for the prediction direction model in this embodiment of the application Functions do not constitute limitations.
三、将训练样本导入CNN模型进行训练。3. Import the training samples into the CNN model for training.
在一种可能的实施方式中,可以利用张量流(Tensorflow)系统训练CNN分类模型,并采用交叉熵损失函数和梯度下降算法,直至模型收敛。In a possible implementation manner, a Tensorflow system can be used to train a CNN classification model, and a cross-entropy loss function and a gradient descent algorithm can be used until the model converges.
可选的,运行方向预测模型还可以采用其他的传统机器学习分类器或深度学习分类模型,本实施例对此不做限定。Optionally, the running direction prediction model can also use other traditional machine learning classifiers or deep learning classification models, which are not limited in this embodiment.
在一种可能的实施方式中,将缓存的第二加速度数据输入训练好的方向预测模型中,得到各个运行方向的预测结果,即各个候选运行方向对应的预测概率,其中,各个候选运行方向即模型训练过程中预先标定的地铁实际运行方向。In a possible implementation, the buffered second acceleration data is input into the trained direction prediction model to obtain the prediction results of each running direction, that is, the prediction probability corresponding to each candidate running direction, where each candidate running direction is The actual running direction of the subway pre-calibrated during the model training process.
示意性的,各个运行方向的预测结果可以是:P 0=0.01,P 1=0.005,P 2=0.98,P 3=0.005等,其中,0代表东南方向、1代表西南方向、2代表东北方向、3代表西北方向等,对应的,预测结果包括:第二加速度数据指示地铁运行方向是东南方向的概率为0.01,地铁运行方向是西南方向的概率为0.005,地铁运行方向是东北方向的概率为0.98,地铁运行方向西北方向的概率为0.005。 Illustratively, the prediction results of each running direction can be: P 0 =0.01, P 1 =0.005, P 2 =0.98, P 3 =0.005, etc., where 0 represents the southeast direction, 1 represents the southwest direction, and 2 represents the northeast direction , 3 represents the northwest direction, etc. Correspondingly, the prediction results include: the probability that the second acceleration data indicates that the subway direction is southeast is 0.01, the probability that the subway direction is southwest is 0.005, and the probability that the subway direction is northeast is 0.98, the probability of the subway running direction northwest is 0.005.
步骤406,根据各个候选运行方向的预测概率,确定地铁运行方向。Step 406: Determine the subway running direction according to the predicted probability of each candidate running direction.
在一种可能的实施方式中,根据各个候选运行方向的预测概率,将其中预测概率最高的运行方向,确定为地铁运行方向。In a possible implementation, according to the predicted probability of each candidate running direction, the running direction with the highest predicted probability is determined as the subway running direction.
在一个示例性的例子中,若地铁运行方向的预测结果为:P 0=0.01,P 1=0.005,P 2=0.98,P 3=0.005,其中,0代表东南方向、1代表西南方向、2代表东北方向、3代表西北方向,由于P 2>P 0>P 1=P 3,因此,确定地铁运行方向为东北方向。 In an illustrative example, if the prediction result of the subway running direction is: P 0 =0.01, P 1 =0.005, P 2 =0.98, P 3 =0.005, where 0 represents the southeast direction, 1 represents the southwest direction, and 2 Represents the northeast direction and 3 represents the northwest direction. Since P 2 >P 0 >P 1 =P 3 , the subway running direction is determined to be the northeast direction.
本实施例中,当终端采集第一加速度数据的同时,通过重力传感器和磁力计分别采集重力加速度数据和磁力数据,以便获取此时第一加速度数据对应的转换矩阵;此外,通过在终端中预先设置运行方向预测模型,并将缓存的第二加速度数据输入该运行方向预测模型中, 根据运行方向预测模型的输出结果来确定地铁运行方向,可以提高根据第二加速度数据确定地铁运行方向的准确性;此外,由于输入运行方向预测模型中的第二加速度数据为一段时长内的加速度数据,因此,也可以避免单个加速度方向不稳定导致确定地铁运行方向不准确的问题,进一步提高了确定地铁运行方向的准确性。In this embodiment, when the terminal collects the first acceleration data, the gravity sensor and the magnetometer are used to collect the gravity acceleration data and the magnetic force data respectively, so as to obtain the conversion matrix corresponding to the first acceleration data at this time; in addition, by pre-setting in the terminal Set the running direction prediction model, and input the cached second acceleration data into the running direction prediction model, and determine the subway running direction according to the output result of the running direction prediction model, which can improve the accuracy of determining the subway running direction based on the second acceleration data ; In addition, because the second acceleration data in the input running direction prediction model is acceleration data within a period of time, it can also avoid the problem of inaccurate determination of the subway running direction caused by the instability of a single acceleration direction, and further improve the determination of the subway running direction Accuracy.
由于要连续采集第一加速度数据,而在采集的过程中,终端的姿态可能会发生改变,造成重力加速度数据和磁力数据可能发生改变,而由于转换矩阵与终端实时采集到的重力加速度数据和磁力数据有关,则对应的重力加速度和磁力数据的改变,也会导致转换矩阵发生改变,若对于不同采集时刻均采用相同的转换矩阵,显然由于终端姿态的改变会导致确定出的地铁运行方向上出现误差,因此,为了进一步提高获取到的第二加速度数据的准确性,需要根据重力加速度数据和磁力数据实时确定转换矩阵,使得确定出的转换矩阵符合当前终端的握持姿态。Since the first acceleration data needs to be collected continuously, the attitude of the terminal may change during the collection process, causing the gravity acceleration data and magnetic force data to be changed, and due to the conversion matrix and the gravity acceleration data and magnetic force collected by the terminal in real time If the data is related, the corresponding gravitational acceleration and magnetic data changes will also cause the transformation matrix to change. If the same transformation matrix is used for different collection times, it is obvious that the change of the terminal attitude will cause the determined subway running direction to appear Therefore, in order to further improve the accuracy of the acquired second acceleration data, it is necessary to determine the conversion matrix in real time according to the gravity acceleration data and the magnetic force data, so that the determined conversion matrix conforms to the current holding posture of the terminal.
示意性的,在图4的基础上,如图7所示,步骤402至步骤404可以被替换为步骤407至步骤410。Illustratively, on the basis of FIG. 4, as shown in FIG. 7, steps 402 to 404 may be replaced with steps 407 to 410.
步骤407,获取重力加速度传感器采集到的第n重力加速度数据,以及磁力计采集到的第n磁力数据,n为大于等于2的整数。Step 407: Obtain the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2.
在一种可能的实施方式中,当终端获取目标时长内的第一加速度数据时,终端中的线性加速度传感器、重力加速度传感器和磁力计均按照目标采样频率进行数据采集,以便获取到的第一加速度数据与重力加速度数据、磁力数据均是同一时刻的数据,从而使得获取到的第二加速度数据更具有参考价值。In a possible implementation manner, when the terminal acquires the first acceleration data within the target duration, the linear acceleration sensor, the gravitational acceleration sensor, and the magnetometer in the terminal all perform data collection according to the target sampling frequency, so as to obtain the first acceleration data. The acceleration data, the gravitational acceleration data, and the magnetic force data are all data at the same time, so that the acquired second acceleration data has more reference value.
示意性的,若目标时长为10s,采样频率为20HZ,则在目标时长内获取到的第一加速度数据、重力加速度数据和磁力数据均为200个,且第n重力加速度数据为第n次采集到的重力加速度数据,第n磁力数据为第n次采集到的磁力数据。Illustratively, if the target duration is 10s and the sampling frequency is 20HZ, then the first acceleration data, gravitational acceleration data, and magnetic data acquired within the target duration are all 200, and the nth gravitational acceleration data is the nth acquisition The obtained gravitational acceleration data, the nth magnetic force data is the magnetic force data collected for the nth time.
步骤408,若第n重力加速度数据与第n-1重力加速度数据的相似度大于相似度阈值,且第n磁力数据与第n-1磁力数据的相似度大于相似度阈值,则将第n-1转换矩阵确定为第n转换矩阵,第n-1转换矩阵根据第n-1重力加速度数据和第n-1磁力数据确定得到。Step 408: If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then the n-th 1 The conversion matrix is determined as the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data.
由于每个采集时刻对应的转换矩阵与当前采集时刻采集到的重力加速度数据和磁力数据有关,因此,在一种可能的实施方式中,可以通过比较相邻采集时刻的重力加速度数据或者是磁力数据,来确定终端姿态是否改变,从而确定转换矩阵是否改变。Since the conversion matrix corresponding to each collection time is related to the gravitational acceleration data and magnetic data collected at the current collection time, in a possible implementation manner, the gravitational acceleration data or magnetic data at adjacent collection time can be compared. , To determine whether the terminal posture has changed, and thus whether the conversion matrix has changed.
在一种可能的实施方式中,终端中预先设置有相似度阈值,若终端确定第n重加速数据与第n-1重力加速度数据的相似度大于相似度阈值,且第n磁力数据与第n-1磁力数据的相似度大于相似度阈值,则确定两次采集时刻终端的姿态未发生明显改变,因此,无需重复计算转换矩阵,可以直接将第n-1转换矩阵确定为第n转换矩阵,以便减少终端的计算量,节省功耗。In a possible implementation manner, a similarity threshold is preset in the terminal, and if the terminal determines that the similarity between the nth reacceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the nth magnetic force data and the nth -1 The similarity of the magnetic data is greater than the similarity threshold, it is determined that the posture of the terminal has not changed significantly at the time of the two acquisitions. Therefore, there is no need to recalculate the conversion matrix, and the n-1th conversion matrix can be directly determined as the nth conversion matrix. In order to reduce the amount of calculation of the terminal and save power consumption.
其中,相似度的计算公式可以为:Among them, the similarity calculation formula can be:
Figure PCTCN2020134578-appb-000040
Figure PCTCN2020134578-appb-000040
其中,d为相似度,
Figure PCTCN2020134578-appb-000041
为第n重力加速数据,
Figure PCTCN2020134578-appb-000042
为第n-1重力加速度数据,将d换算为百分比,即获得第n重加速数据与第n-1重力加速度数据的相似度。第n磁力数据与第n-1磁力数据的相似度可以参考上述公式获得。
Among them, d is the similarity,
Figure PCTCN2020134578-appb-000041
Is the nth gravitational acceleration data,
Figure PCTCN2020134578-appb-000042
Is the n-1th gravitational acceleration data, convert d to a percentage, that is, obtain the similarity between the nth re-acceleration data and the n-1th gravitational acceleration data. The similarity between the nth magnetic force data and the n-1th magnetic force data can be obtained by referring to the above formula.
示意性的,相似度阈值可以是98%,即当终端确定第n重力加速度数据与第n-1重力加速度数据的相似度为98.5%,第n磁力数据与第n-1磁力数据的相似度为99%,相似度均大于98%,则确定两次采集时刻终端的姿态未发生明显改变,可继续使用第n-1转换矩阵。Illustratively, the similarity threshold may be 98%, that is, when the terminal determines that the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is 98.5%, the similarity between the nth magnetic force data and the n-1th magnetic force data If it is 99% and the similarity is greater than 98%, it is determined that the posture of the terminal has not changed significantly at the time of the two acquisitions, and the n-1th conversion matrix can be used continuously.
步骤409,若第n重力加速度数据与第n-1重力加速度数据的相似度小于相似度阈值,和/或,第n磁力数据与第n-1磁力数据的相似度小于相似度阈值,则根据第n重力加速度数据 和第n磁力数据确定第n转换矩阵。Step 409: If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic data and the n-1th magnetic data is less than the similarity threshold, then The nth gravitational acceleration data and the nth magnetic force data determine the nth conversion matrix.
在一种可能的实施方式中,若第n重力加速度数据与第n-1重力加速度数据的相似度小于相似度阈值,或,第n磁力数据与第n-1磁力数据的相似度小于相似度阈值,则确定两次采集时刻终端的姿态可能发生明显改变,即第n-1转换矩阵在第n次采集数据过程中不具有参考价值,因此,需要重新根据第n重力加速度数据和第n磁力数据计算第n转换矩阵。In a possible implementation, if the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, or the similarity between the nth magnetic data and the n-1th magnetic data is less than the similarity Threshold, it is determined that the attitude of the terminal may change significantly at the time of the two collections, that is, the n-1th conversion matrix has no reference value during the nth collection of data. Therefore, it is necessary to re-based the nth gravitational acceleration data and the nth magnetic force. The data calculates the nth transformation matrix.
示意性的,相似度阈值可以是98%,若终端计算得到第n重力加速度数据和第n-1重力加速度数据之间的相似度为60%,小于相似度阈值,第n磁力数据与第n-1磁力数据之间的相似度为99%,大于相似度阈值,可见,重力加速度发生明显改变,对应的,确定两次采集时刻终端姿态可能发生明显改变,需要重新根据第n重力加速度数据和第n磁力数据计算第n转换矩阵。Illustratively, the similarity threshold may be 98%. If the terminal calculates that the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is 60%, which is less than the similarity threshold, the nth magnetic data and the nth -1 The similarity between the magnetic data is 99%, which is greater than the similarity threshold. It can be seen that the gravitational acceleration has changed significantly. Correspondingly, it is determined that the terminal attitude may change significantly at the time of the two acquisitions. The nth magnetic force data calculates the nth conversion matrix.
步骤410,通过第n转换矩阵,将第一加速度数据转换为第二加速度数据。Step 410: Convert the first acceleration data into second acceleration data through the nth conversion matrix.
在一种可能实施方式中,通过确定的第n转换矩阵,将第n次采集到的第一加速度数据转换为第n个第二加速度数据。In a possible implementation manner, the first acceleration data collected for the nth time is converted into the nth second acceleration data through the determined nth conversion matrix.
本申请实施例中,通过比较第n重力加速度数据与第n-1重力加速度数据的相似度,以及第n磁力数据与第n-1磁力数据的相似度,在上述相似度均大于相似度阈值时,可以直接根据第n-1转换矩阵将第n个第一加速度数据转换为第n个第二加速度数据,否则,需要重新根据第n重力加速度数据和第n磁力数据计算第n转换矩阵,进行数据转换,可以在减少终端的计算量的同时,保证获取的第二加速度数据的准确性。In the embodiment of the present application, by comparing the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data, and the similarity between the nth magnetic force data and the n-1th magnetic force data, the above similarity is greater than the similarity threshold. , You can directly convert the n-th first acceleration data to the n-th second acceleration data according to the n-1th conversion matrix, otherwise, you need to recalculate the n-th conversion matrix based on the n-th gravitational acceleration data and the n-th magnetic data. Performing data conversion can reduce the calculation amount of the terminal while ensuring the accuracy of the acquired second acceleration data.
由于终端需要在确定地铁处于加速阶段时,进行第一加速度数据的采集,而通常情况下地铁在启动阶段进行加速,因此为了提高采集第一加速度数据时机的准确性,从而确定进行地铁运行方向判断的时机,在一种可能的实施方式中,终端可以通过识别环境音中是否包含地铁关门警铃声来确定地铁是否启动,从而实现进行第一加速度数据采集时机的准确把控。Since the terminal needs to collect the first acceleration data when it is determined that the subway is in the acceleration phase, and usually the subway accelerates during the start-up phase, in order to improve the accuracy of the timing of collecting the first acceleration data, it is determined to determine the direction of the subway. In a possible implementation manner, the terminal can determine whether the subway is activated by identifying whether the ambient sound includes the subway closing alarm bell, so as to achieve accurate control of the timing of the first acceleration data collection.
示意性的,请参考图8,其示出了本申请一个示例性实施例示出的确定地铁处于加速阶段过程的流程图,本实施例以地铁运行方向的确定方法用于终端为例进行说明,该方法包括:Schematically, please refer to FIG. 8, which shows a flowchart of the process of determining that the subway is in the acceleration phase shown in an exemplary embodiment of the present application. This embodiment uses the method for determining the direction of the subway to be used in the terminal as an example for description. The method includes:
步骤801,通过麦克风采集环境音。Step 801: Collect environmental sounds through a microphone.
在一种可能的实施方式中,终端可以实时获取用户位置信息,当根据用户位置信息,确定用户进入地铁时,终端可以开启麦克风实时采集环境音。In a possible implementation manner, the terminal can acquire user location information in real time, and when it is determined that the user enters the subway according to the user location information, the terminal can turn on the microphone to collect ambient sound in real time.
可选的,当用户使用支付类应用程序进行刷卡乘坐地铁时,终端确认用户进入地铁,可以开启麦克风实时采集环境音。Optionally, when the user uses a payment application to swipe his card to take the subway, the terminal confirms that the user enters the subway, and can turn on the microphone to collect ambient sound in real time.
可选的,为了降低终端的功耗,终端可使用低功耗麦克风对环境音进行实时采集。Optionally, in order to reduce the power consumption of the terminal, the terminal may use a low-power microphone to collect ambient sound in real time.
步骤802,当识别出环境音中包括地铁关门警铃声时,确定处于地铁启动阶段。In step 802, when it is recognized that the ambient sound includes the subway door-closing alarm bell, it is determined that it is in the subway startup stage.
在一种可能的实施方式中,终端中预先存储有地铁关门警铃声的音频数据,当终端通过麦克风实时采集到环境音之后,可以将该环境音转换为音频数据,并对音频数据进行数据处理,从而识别处理后的音频数据中是否包含地铁关门警铃声对应的音频数据。若识别出环境音中包含地铁关门警铃声对应的音频数据,则确定地铁启动。In a possible implementation, the terminal pre-stores the audio data of the subway closing alarm bell. After the terminal collects the ambient sound through the microphone in real time, it can convert the ambient sound into audio data and perform data processing on the audio data. , So as to identify whether the processed audio data contains the audio data corresponding to the subway closing alarm bell. If it is recognized that the ambient sound contains audio data corresponding to the subway door-closing alarm bell, it is determined that the subway is activated.
可选的,终端中预先存储的地铁关门警铃声可以是用户在乘坐地铁时,开启麦克风采集地铁关门警铃声并保存;也可以是终端在获取城市的交通工具线路图时,获取地铁对应的地铁关门警铃声,并将其转换为音频数据保存至本地。Optionally, the pre-stored subway closing alarm ringtone in the terminal can be the user turning on the microphone to collect the subway closing alarm ringtone and save it when taking the subway; or the terminal can obtain the subway corresponding to the subway when the terminal obtains the city's transportation route map. The door-closing alarm ringtone is converted into audio data and saved to the local.
由于环境音中可能包含多种杂音,为了提高识别准确率,需要先将环境音对应的音频数据进行预处理,再将处理后的音频数据输入声音识别模型,从而根据声音识别模型输出的警铃声识别结果,判断当前环境音中是否包含地铁关门警铃声。Since the environmental sound may contain a variety of noises, in order to improve the recognition accuracy, it is necessary to preprocess the audio data corresponding to the environmental sound, and then input the processed audio data into the voice recognition model, so as to output the alarm bell according to the voice recognition model According to the recognition result, it is judged whether the current environmental sound includes the subway closing alarm bell.
在一种可能的实施方式中,判断当前环境音中是否包含地铁关门警铃声,来确定地铁是否启动的方法可以包括以下步骤:In a possible implementation manner, the method for determining whether the subway closing alarm ring is included in the current ambient sound to determine whether the subway is activated may include the following steps:
一、对环境音进行音频特征提取,得到音频特征矩阵。1. Perform audio feature extraction on ambient sounds to obtain an audio feature matrix.
由于声音识别模型无法直接对音频数据进行识别,因此需要预先处理音频数据,得到能 够被声音识别模型识别的数字特征。由于终端麦克风实时采集环境音,其音频数据整体上并不是平稳的,但其局部可以看作平稳数据,而声音识别模型只能对平稳数据进行识别,因此终端先将对应的音频数据进行分帧处理,得到不同音频帧对应的音频数据。Since the voice recognition model cannot directly recognize audio data, it is necessary to pre-process the audio data to obtain digital features that can be recognized by the voice recognition model. Since the terminal microphone collects ambient sound in real time, its audio data is not stable as a whole, but its parts can be regarded as stable data, and the sound recognition model can only recognize the stable data, so the terminal first divides the corresponding audio data into frames Processing to obtain audio data corresponding to different audio frames.
在一种可能的实施方式中,音频数据预处理过程可以如图9所示,音频数据首先经过预加重模块901进行预加重处理,预加重过程采用高通滤波器,其只允许高于某一频率的信号分量通过,而抑制低于该频率的信号分量,从而去除音频数据中人的交谈声、脚步声和机械噪音等不必要的低频干扰,使音频信号的频谱变得平坦。高通滤波器的数学表达式为:In a possible implementation manner, the audio data pre-processing process may be as shown in Figure 9. The audio data is first subjected to the pre-emphasis module 901 for pre-emphasis processing. The pre-emphasis process uses a high-pass filter, which is only allowed to be higher than a certain frequency. The signal components pass through, and the signal components below this frequency are suppressed, thereby removing unnecessary low-frequency interference such as human conversation, footsteps, and mechanical noise in the audio data, and flattening the frequency spectrum of the audio signal. The mathematical expression of the high-pass filter is:
H(z)=1-az -1 H(z) = 1-az -1
其中,a是修正系数,一般取值范围为0.95至0.97,z是音频信号。Among them, a is the correction coefficient, which generally ranges from 0.95 to 0.97, and z is the audio signal.
将去除噪音后的音频数据通过分帧加窗模块902进行分帧处理,得到不同音频帧对应的音频数据。The noise-removed audio data is subjected to framing processing by the framing and windowing module 902 to obtain audio data corresponding to different audio frames.
示意性的,本实施例中将包含1024个数据点的音频数据划分为一帧,当音频数据的采样频率选取为16000Hz时,一帧音频数据的时长为64ms。为了避免两帧数据之间的变化过大,同时也为了避免加窗处理后音频帧两端的数据丢失,并不采用背靠背的方式直接将音频数据划分为帧,而是每取完一帧数据后,后滑动32ms再取下一帧数据,即相邻两帧数据重叠32ms。Illustratively, in this embodiment, audio data containing 1024 data points is divided into one frame. When the sampling frequency of the audio data is selected as 16000 Hz, the duration of one frame of audio data is 64 ms. In order to avoid excessive changes between the two frames of data, and to avoid the loss of data at both ends of the audio frame after windowing, the audio data is not directly divided into frames in a back-to-back manner, but after each frame of data is fetched , And then slide 32ms to fetch the next frame of data, that is, the data of two adjacent frames overlap by 32ms.
由于分帧处理后的音频数据在后续特征提取时需要进行离散傅里叶变换,而一帧音频数据没有明显的周期性,即帧左端和帧右端不连续,经过傅里叶变换后与原始数据会产生误差,分帧越多误差越大,因此为了使分帧后的音频数据连续,且每一帧音频数据表现出周期函数的特征,需要通过分帧加窗模块902进行分帧加窗处理。Since the audio data after framing needs to be subjected to discrete Fourier transform in the subsequent feature extraction, a frame of audio data has no obvious periodicity, that is, the left end of the frame and the right end of the frame are not continuous, and after Fourier transform, it will be compared with the original data. Errors will occur. The more frames are divided, the greater the error will be. Therefore, in order to make the framed audio data continuous and each frame of audio data exhibits the characteristics of a periodic function, it is necessary to perform frame and window processing by the frame and window module 902 .
在一种可能的实施方式中,采用汉明窗对音频帧进行加窗处理。将每一帧数据乘以汉明窗函数,得到的音频数据就有了明显的周期性。汉明窗的函数形式为:In a possible implementation manner, a Hamming window is used to perform windowing processing on audio frames. Multiply each frame of data by the Hamming window function, and the resulting audio data has obvious periodicity. The functional form of the Hamming window is:
Figure PCTCN2020134578-appb-000043
Figure PCTCN2020134578-appb-000043
其中n为整数,n的取值范围为0至M,M是傅里叶变换的点数,示意性的,本实施例取1024个数据点作为傅里叶变换点。Where n is an integer, n ranges from 0 to M, and M is the number of Fourier transform points. Illustratively, 1024 data points are taken as Fourier transform points in this embodiment.
在一种可能的实施方式中,音频数据在分帧加窗处理后,需要进行特征提取,得到声音识别模型能够识别的特征矩阵,即提取音频帧的梅尔频率倒谱系数(Mel-Frequency Cepstral Coefficients,MFCC)。In a possible implementation, after the audio data is framed and windowed, it needs to perform feature extraction to obtain a feature matrix that can be recognized by the voice recognition model, that is, extract the Mel-Frequency Cepstral coefficient of the audio frame. Coefficients, MFCC).
由于从音频信号在时域上的变换中很难得到其信号特性,通常需要把时域信号转换为频域上的能量分布来处理,因此终端先将音频帧数据输入傅里叶变换模块903进行傅里叶变换,然后将傅里叶变换后的音频帧数据输入能量谱计算模块904,计算音频帧数据的能量谱。为了将其能量谱转化为符合人耳听觉的梅尔谱,需要将能量谱输入梅尔滤波处理模块905进行滤波处理;滤波处理的数学表达式为:Since it is difficult to obtain the signal characteristics of the audio signal from the transformation in the time domain, it is usually necessary to convert the time domain signal into the energy distribution in the frequency domain for processing. Therefore, the terminal first inputs the audio frame data to the Fourier transform module 903 for processing. Fourier transform, and then input the audio frame data after Fourier transform to the energy spectrum calculation module 904 to calculate the energy spectrum of the audio frame data. In order to convert its energy spectrum into a Mel spectrum that conforms to human hearing, the energy spectrum needs to be input to the Mel filter processing module 905 for filtering processing; the mathematical expression of the filtering processing is:
Figure PCTCN2020134578-appb-000044
Figure PCTCN2020134578-appb-000044
其中,f为傅里叶变换后的频点。Among them, f is the frequency point after Fourier transform.
得到音频帧的梅尔谱之后,终端通过离散余弦变换(Discrete Cosine Transform,DCT)模块906对其取对数,得到的DCT系数即为MFCC特征。After obtaining the Mel spectrum of the audio frame, the terminal uses a discrete cosine transform (Discrete Cosine Transform, DCT) module 906 to log it, and the obtained DCT coefficient is the MFCC feature.
示意性的,本申请实施例选取40维的MFCC特征,终端在实际提取特征时,音频数据的输入窗口长度选为1056ms,而一帧信号的时间长度为64ms,相邻两帧数据之间有32ms的重叠部分,因此每一个1056ms的输入窗口数据对应生成的特征为32*40的矩阵。Illustratively, the embodiment of the present application selects 40-dimensional MFCC features. When the terminal actually extracts the features, the length of the audio data input window is selected to be 1056 ms, and the time length of one frame of signal is 64 ms. There is a gap between two adjacent frames of data. 32ms overlap, so each input window data of 1056ms corresponds to a matrix of 32*40 generated features.
二、将音频特征矩阵输入声音识别模型,得到声音识别模型输出的警铃声识别结果,警铃声识别结果用于指示环境音中是否包含地铁关门警铃声。2. Input the audio feature matrix into the voice recognition model to obtain the alarm bell recognition result output by the voice recognition model. The alarm bell recognition result is used to indicate whether the ambient sound contains the subway closing alarm bell.
在一种可能的实施方式中,终端将音频帧经过特征提取后得到的音频特征矩阵输入声音 识别模型中,模型识别当前音频帧中是否包含地铁关门警铃声,并输出识别结果。In a possible implementation manner, the terminal inputs the audio feature matrix obtained after feature extraction of the audio frame into the voice recognition model, and the model recognizes whether the current audio frame contains the subway closing alarm bell, and outputs the recognition result.
在一种可能的实施方式中,若终端无法自主获取当前所在城市的地铁关门警铃声时,需要用户事先采集地铁关门警铃声,当采集到地铁关门警铃声后,将包含地铁关门警铃声的音频数据也进行上述步骤一中的分帧处理和特征提取过程,并将地铁关门警铃声的音频特征矩阵保存至本地。In a possible implementation, if the terminal cannot obtain the subway closing alarm bell of the current city autonomously, the user needs to collect the subway closing alarm bell in advance. After the subway closing alarm bell is collected, the audio of the subway closing alarm bell will be included. The data is also subjected to the framing processing and feature extraction process in the above step 1, and the audio feature matrix of the subway closing alarm bell is saved locally.
对应的,在识别环境音中是否包含地铁关门警铃声时,可以直接将对环境音进行预处理后的音频特征矩阵,以及地铁关门警铃声对应的音频特征矩阵一起输入声音识别模型中,以便声音识别模型用来比较这两个音频特征矩阵的相似度,从而得到声音识别模型输出的相似度,以便根据该相似度来确定环境音中是否包含地铁关门警铃声。Correspondingly, when identifying whether the ambient sound contains the subway door-closing alarm bell, the audio feature matrix after preprocessing the environmental sound and the audio feature matrix corresponding to the subway door-closing alarm bell can be directly input into the voice recognition model to facilitate the sound The recognition model is used to compare the similarity of the two audio feature matrices to obtain the similarity of the output of the voice recognition model, so as to determine whether the ambient sound contains the subway closing alarm bell according to the similarity.
示意性的,相似度越高,表示两个音频特征矩阵越相似,对应的,环境音中包含地铁关门警铃声的可能性越大,因此,设置有相似度阈值,当声音识别模型输出的相似度大于相似度阈值,确定环境音中包含地铁关门警铃声;反之,若相似度低于相似度阈值,则确定环境音中不包含地铁关门警铃声。Schematically, the higher the similarity, the more similar the two audio feature matrices are. Correspondingly, the more likely the ambient sound contains the subway closing alarm bell. Therefore, a similarity threshold is set. When the output of the voice recognition model is similar If the degree is greater than the similarity threshold, it is determined that the ambient sound includes the subway closing alarm bell; conversely, if the similarity is lower than the similarity threshold, it is determined that the ambient sound does not include the subway closing alarm bell.
可选的,用于判断环境音中是否包含地铁关门警铃声的相似度阈值可以是90%。Optionally, the similarity threshold used to determine whether the ambient sound includes a subway closing alarm bell may be 90%.
可选的,在训练声音识别模型时,可以采用样本音频特征矩阵、标准音频特征矩阵,以及人工标注样本音频特征矩阵和标准音频特征矩阵之间的相似度数值,训练声音识别模型,使得声音识别模型具备可以比较两个音频数据之间相似度的功能;对应的,在实际应用过程中,可以直接将环境音预处理后得到的音频特征矩阵和预先存储的包含地铁关门警铃声的音频矩阵输入声音识别模型中,得到声音识别模型输出的警铃声识别结果,即两个音频特征矩阵的相似度。Optionally, when training the voice recognition model, you can use the sample audio feature matrix, the standard audio feature matrix, and manually label the similarity value between the sample audio feature matrix and the standard audio feature matrix to train the voice recognition model to make the voice recognition The model has the function of comparing the similarity between two audio data; correspondingly, in the actual application process, the audio feature matrix obtained after the environmental sound preprocessing and the pre-stored audio matrix input containing the subway closing alarm bell can be directly input In the voice recognition model, the alarm bell recognition result output by the voice recognition model is obtained, that is, the similarity of the two audio feature matrices.
三、若警铃声识别结果指示环境音中包含地铁关门警铃声,则确定处于地铁启动阶段。3. If the alarm bell recognition result indicates that the ambient sound includes the subway closing alarm bell, it is determined that it is in the subway startup stage.
由于终端在进行识别地铁关门警铃声之前,将音频数据进行了分帧处理,而一帧音频的时间很短,因此当某一音频帧中包含目标警铃声时,无法排除存在其他相似声音或特征提取时的数据处理过程产生错误的情况,不能立即确定环境音中包含地铁关门警铃声。所以,终端设置预定时长,当声音识别模型的输出结果指示预定时长内包含地铁关门警铃声的音频帧的个数达到个数阈值时,确定环境音中包含地铁关门警铃声,即确定地铁启动。Because the terminal processes the audio data into frames before recognizing the subway closing alarm bell, and the time of one frame of audio is very short, when an audio frame contains the target alarm bell, it cannot be ruled out that there are other similar sounds or features When the data processing during the extraction produces an error, it cannot be immediately determined that the ambient sound contains the subway closing alarm bell. Therefore, the terminal sets a predetermined time period, and when the output result of the voice recognition model indicates that the number of audio frames containing the subway door-closing alarm bell within the predetermined time period reaches the number threshold, it is determined that the ambient sound includes the subway door-closing alarm bell, that is, it is determined that the subway is started.
示意性的,终端设置预定时长为5秒,个数阈值为2,当5秒钟的时间内终端识别到2个或多于2个音频帧中包含地铁关门警铃声时,确定当前环境音中包含地铁关门警铃声,即确定地铁启动。Illustratively, the terminal sets the predetermined duration to 5 seconds and the number threshold to 2. When the terminal recognizes that 2 or more audio frames contain the subway closing alarm bell within 5 seconds, it determines that the current ambient sound is Including the subway closing alarm bell, which confirms the subway start.
本申请实施例中,通过麦克风采集环境音,并将环境音经过预处理后,得到音频矩阵,输入声音识别模型中,并根据输出的警铃识别结果来确定环境音中是否包含目标警铃声,以此来确定地铁是否启动,提高了确定地铁启动的准确性,从而实现进行第一加速度数据采集时机的准确把控。In the embodiment of the present application, the environmental sound is collected by a microphone, and the environmental sound is preprocessed to obtain an audio matrix, which is input into the voice recognition model, and the output of the alarm bell recognition result is used to determine whether the environmental sound contains the target alarm bell. In this way, it is determined whether the subway is started, the accuracy of determining the start of the subway is improved, and the timing of the first acceleration data collection is accurately controlled.
在一种可能的应用场景中,当终端根据第二加速度数据确定出地铁运行方向之后,可以与用户期望乘坐地铁的运行方向进行比较,若两者方向匹配,则确定用户乘坐正确,若不匹配,则确定用户乘坐有误,以便及时提醒用户进行换乘,减少乘错地铁带来的时间上的浪费。In a possible application scenario, after the terminal determines the running direction of the subway based on the second acceleration data, it can be compared with the running direction the user expects to take the subway. If the two directions match, it is determined that the user is taking the correct ride. , It is determined that the user has taken the wrong ride, so as to promptly remind the user to transfer, and reduce the time waste caused by taking the wrong subway.
示意性的,如图10所示,其示出了本申请一个示例性实施例示出的确定用户乘坐地铁是否正确的方法的流程图,本实施例以该方法应用于终端为例进行说明,该方法包括:Schematically, as shown in FIG. 10, it shows a flowchart of a method for determining whether a user is taking the subway correctly according to an exemplary embodiment of the present application. In this embodiment, the method is applied to a terminal as an example for description. Methods include:
步骤1001,根据当前站点和目标站点确定终点站点,目标站点位于当前站点与终点站点之间。Step 1001: Determine the end station according to the current station and the target station, and the target station is located between the current station and the end station.
其中,当前站点指示地铁当前停靠的站点,也就是说用户从当前站点开始乘坐地铁;目标站点指示地铁启动后从当前站点出发所驶向的下一个站点。Among them, the current station indicates the station where the subway currently stops, that is, the user starts to take the subway from the current station; the target station indicates the next station to which the subway starts from the current station.
其中,当前站点和目标站点的确定方式可以是,当用户携带终端乘坐地铁时,终端通过采集地铁的启动或到站时的提示音,该提示音中包含当前站点的名称以及下一站的站点名称。Among them, the method for determining the current station and the target station may be that when the user takes the terminal to take the subway, the terminal collects the prompt sound when the subway starts or arrives, and the prompt sound contains the name of the current station and the station of the next station. name.
对于同一地铁线路,不同地铁运行方向下,即地铁的始发站点和终点站相反,同一当前 站点对应的下一站点并不相同,因此,在一种可能的实施方式中,当用户携带终端乘坐地铁时,终端通过获取当前站点和目标站点(下一站点)的名称,来确定该地铁运行实际到达的终点站。For the same subway line, under different subway operating directions, that is, the starting station and the terminal station of the subway are opposite, the next station corresponding to the same current station is not the same. Therefore, in a possible implementation manner, when the user carries the terminal and rides In the subway, the terminal determines the actual terminal station of the subway operation by obtaining the names of the current station and the target station (next station).
可选的,终端也可以通过地图类应用,实时获取用户位置信息,根据用户的位置信息和地铁线路图,来确定用户当前所处的站点和目标站点,从而确定终点站,本申请实施例对此不构成限定。Optionally, the terminal can also obtain the user's location information in real time through map applications, and determine the user's current site and target site based on the user's location information and subway route map, thereby determining the terminal station. This does not constitute a limitation.
步骤1002,根据当前站点和终点站点,从数据库中查找目标地铁运行方向,目标地铁运行方向是地铁由当前站点运行至终点站点时的运行方向。In step 1002, according to the current station and the terminal station, the target subway running direction is searched from the database. The target subway running direction is the running direction when the subway runs from the current station to the terminal station.
其中,数据库中存储有全国各大城市地铁信息,该数据库中可能包括城市、地铁线路标识、各个站点名称、实际运行方向以及终点站方向等的对应关系。Among them, the database stores subway information of major cities across the country, and the database may include correspondences between cities, subway line identifiers, station names, actual operating directions, and terminal directions.
示意性的,数据库可以如表一所示。Schematically, the database may be as shown in Table 1.
表一Table I
城市city 线路标识Line identification 站点名称Site name 实际运行方向Actual running direction 终点站Terminal
城市1City 1 1212 站点ASite A 东北northeast 站点BSite B
 To  To  To 西南southwest 站点CSite C
城市2City 2 11 站点DSite D 东南southeast 站点ESite E
 To  To  To 西北northwest 站点FSite F
在一种可能的实施方式中,当终端确定出当前站点为站点A,终点站为站点B时,则根据当前站点和终点站点,从数据库(表一)中进行查找可知,目标地铁运行方向为东北方向。In a possible implementation, when the terminal determines that the current station is station A and the terminal station is station B, then according to the current station and the terminal station, searching from the database (Table 1) shows that the target subway running direction is To the northeast.
步骤1003,若确定出的地铁运行方向与目标地铁运行方向不匹配,则进行换乘提示。In step 1003, if the determined subway running direction does not match the target subway running direction, a transfer prompt is performed.
在一种可能的实施方式中,若根据步骤1002确定出的地铁运行方向与目标地铁运行方向不匹配,则确定用户存在地铁乘坐方向不正确的可能,即进行换乘提示,以便用户及时下车,避免乘坐错误地铁所导致的时间浪费。In a possible implementation, if the subway running direction determined in step 1002 does not match the target subway running direction, it is determined that the user may have an incorrect subway riding direction, that is, a transfer prompt is performed so that the user can get off the train in time , To avoid wasting time caused by taking the wrong subway.
其中,换乘提示可以是语音提醒、震动提醒等方式,本申请实施例对换乘提示的方式不构成限定。Wherein, the transfer prompt may be a voice reminder, a vibration reminder, etc., and the embodiment of the present application does not limit the manner of the transfer prompt.
可选的,若确定出的地铁运行方向和目标地铁运行方向匹配,则确定用户乘坐地铁正确,也可以进行确认提醒,以便用户确定当前乘坐的地铁正确,无需更换。Optionally, if the determined subway running direction matches the target subway running direction, it is determined that the user is taking the subway correctly, and a confirmation reminder may also be issued, so that the user can determine that the current subway is taking the correct subway without changing.
需要说明的是,本实施例可以在图4所示的步骤406或图2所示的步骤203之后执行。It should be noted that this embodiment may be executed after step 406 shown in FIG. 4 or step 203 shown in FIG. 2.
本实施例中,通过终端中预设数据库,可以根据确定的地铁运行方向与数据库中查找的地铁实际运行方向进行比较,以便在用户乘坐错误的时候及时提醒用户进行换乘,避免了乘坐错误地铁所导致的时间浪费。In this embodiment, through the preset database in the terminal, the determined subway operation direction can be compared with the actual subway operation direction searched in the database, so as to promptly remind the user to transfer when the user takes the wrong subway, and avoid taking the wrong subway. The resulting wasted time.
在另一种可能的应用场景中,可以根据确定出的地铁运行方向,以及当前站点名称,确定地铁实际运行的终点站,以便将根据当前站点和终点站,确定用户当前实际乘坐的地铁线路,从而向用户反馈,以便用户确认该地铁线路与用户期望乘坐的地铁线路是否一致。In another possible application scenario, the terminal station of the actual subway operation can be determined according to the determined direction of subway operation and the name of the current station, so as to determine the actual subway line the user is currently taking according to the current station and terminal station. Thereby feedback to the user, so that the user can confirm whether the subway line is consistent with the subway line the user expects to take.
在一种可能的实施方式中,根据地铁运行方向确定用户乘坐的地铁线路的过程可以包括以下步骤:In a possible implementation manner, the process of determining the subway line the user rides on according to the subway running direction may include the following steps:
一、获取当前站点。1. Get the current site.
其中,当前站点为用户搭乘的地铁当前停靠的站点。Among them, the current station is the station where the subway that the user rides currently stops at.
在一种可能的实施方式中,可以通过终端采集地铁开启提示音或地铁到站提示音,获取用户所处的当前站点。In a possible implementation manner, the terminal may collect the subway opening prompt sound or the subway arrival prompt sound to obtain the current station where the user is located.
可选的,也可以通过获取用户的位置信息和地铁线路图,确定用户所处的当前站点。Optionally, the current station where the user is located can also be determined by obtaining the user's location information and subway route map.
二、根据当前站点和地铁运行方向,确定地铁由当前站点运行所至的目标站点。2. According to the current station and the direction of subway operation, determine the target station to which the subway runs from the current station.
其中,目标站点可以是用户当前搭乘的地铁运行的终点站,或用户搭乘的地铁运行达到的下一个站点,或在当前地铁运行线路中,当前站点和终点站点之间的任意站点。其中,终端中建立有全国各大城市的地铁信息数据库,可以在数据库中根据当前站点和地铁运行方向, 确定地铁在当前站点即将前往的终点站或下一站点。数据库可以参考上文实施例,本实施例在此不做赘述。Among them, the target station may be the terminal station of the subway operation currently taken by the user, or the next station reached by the subway operation taken by the user, or any station between the current station and the terminal station in the current subway operation route. Among them, the subway information database of major cities across the country is established in the terminal, and the terminal station or the next station that the subway is going to at the current station can be determined in the database according to the current station and the running direction of the subway. The database can refer to the above embodiment, and this embodiment will not be repeated here.
虽然上文实施例中根据第二加速度数据确定出的地铁运行方向可能与地铁实际运行方向还存在一定差异,但是因为对于地铁始发点和终点站相反的同一地铁线路,其对应的地铁运行方向是相反的,比如,地铁线路为站点A至站点B,当地铁从站点A运行至站点B时,其对应的地铁运行方向为东北方向,当地铁从站点B运行至站点A时,其对应的地铁运行方向为西南方向,因此,在一种可能的实施方式中,可以根据确定出的地铁运行方向和当前站点,从数据库中查找到对应的运行终点站。Although the running direction of the subway determined according to the second acceleration data in the above embodiment may be different from the actual running direction of the subway, it is because for the same subway line where the starting point and the end station of the subway are opposite, the corresponding subway running direction The opposite is true. For example, the subway line runs from station A to station B. When the subway runs from station A to station B, the corresponding subway direction is northeast. When the subway runs from station B to station A, the corresponding The running direction of the subway is the southwest direction. Therefore, in a possible implementation manner, the corresponding running terminal can be found from the database according to the determined running direction of the subway and the current station.
在一个示例性的例子中,若地铁运行方向为东南方向,当前站点为站点D,从表一可知,用户当前搭乘的地铁运行至的目标站点为站点E。In an illustrative example, if the subway running direction is southeast and the current station is station D, it can be seen from Table 1 that the target station to which the user currently takes the subway is station E.
三、根据当前站点和目标站点,确定地铁运行的目标地铁运行路线。3. Determine the target subway route for subway operation based on the current station and target station.
在一种可能的实施方式中,当确定出目标站点后,可以根据当前站点和目标站点,确定出用户当前搭乘的地铁所对应的完整地铁路线,并将该地铁路线反馈给用户,以便用户确定当前乘坐地铁是否为自己期望乘坐的地铁,若不符合,用户可以及时进行地铁换乘,避免用户由于搭乘地铁有误对增加用户出行上的交通成本。In a possible implementation manner, after the target site is determined, the complete subway route corresponding to the subway the user is currently riding on can be determined according to the current site and the target site, and the subway route is fed back to the user for the user to determine Whether the current subway ride is the subway that they expect to ride, if not, the user can transfer the subway in time to avoid the user from increasing the transportation cost of the user's travel due to the mistake of taking the subway.
本实施例中,可以根据上文实施例中预测到的地铁运行方向,预估用户当前搭乘的地铁所运行至的目标站点,以便向用户反馈当前地铁的运行方向,也即是地铁运行的终点站,从而使得用户可以根据该地铁运行站点,确定是否与用户期望乘坐的地铁站相符合,以便及时发现地铁是否乘坐有误,避免了乘坐错误地铁所导致的时间浪费。In this embodiment, it is possible to estimate the target station to which the subway currently traveled by the user is based on the predicted subway running direction in the above embodiment, so as to feedback the current subway running direction to the user, that is, the end of the subway running. This allows the user to determine whether the subway station is consistent with the subway station the user expects to take according to the subway operating station, so as to find out whether the subway is taken incorrectly in time, and avoid the waste of time caused by taking the wrong subway.
请参考图11,其示出了本申请一个示例性实施例提供的地铁运行方向的确定装置的结构框图。该装置可以通过软件、硬件或者两者的结合实现成为终端的全部或一部分。该装置包括:Please refer to FIG. 11, which shows a structural block diagram of an apparatus for determining a subway running direction provided by an exemplary embodiment of the present application. The device can be implemented as all or a part of the terminal through software, hardware or a combination of the two. The device includes:
获取模块1101,用于在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,所述第一加速度数据中包括终端坐标系下各个方向的加速度数据;The acquiring module 1101 is configured to acquire the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
数据转换模块1102,用于将所述第一加速度数据转换为第二加速度数据,所述第二加速度数据中包括世界坐标系下各个方向的加速度数据;The data conversion module 1102 is configured to convert the first acceleration data into second acceleration data, and the second acceleration data includes acceleration data in various directions in the world coordinate system;
第一确定模块1103,用于根据目标时长内的所述第二加速度数据,确定地铁运行方向。The first determining module 1103 is configured to determine the running direction of the subway according to the second acceleration data within the target duration.
可选的,所述终端中设置有重力加速度传感器和磁力计;Optionally, a gravity acceleration sensor and a magnetometer are provided in the terminal;
可选的,所述数据转换模块1102,包括:Optionally, the data conversion module 1102 includes:
获取单元,用于获取所述重力加速度传感器采集到的重力加速度数据,以及所述磁力计采集到的磁力数据,所述重力加速度数据和所述磁力数据基于所述终端坐标系;An acquiring unit, configured to acquire the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer, the gravity acceleration data and the magnetic force data being based on the terminal coordinate system;
第一确定单元,用于根据所述重力加速度数据和所述磁力数据确定转换矩阵,所述转换矩阵用于将所述终端坐标系下的加速度数据转换为所述世界坐标系下的加速度数据;A first determining unit, configured to determine a conversion matrix according to the gravity acceleration data and the magnetic force data, the conversion matrix being used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system;
数据转换单元,用于通过所述转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。The data conversion unit is configured to convert the first acceleration data into the second acceleration data through the conversion matrix.
可选的,所述线性加速度传感器、所述重力加速度传感器和所述磁力计按照目标采样频率进行数据采集;Optionally, the linear acceleration sensor, the gravity acceleration sensor, and the magnetometer perform data collection according to a target sampling frequency;
可选的,所述获取单元,还用于:Optionally, the obtaining unit is further used for:
获取所述重力加速度传感器采集到的第n重力加速度数据,以及所述磁力计采集到的第n磁力数据,n为大于等于2的整数;Acquiring the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2;
可选的,所述第一确定单元,还用于:Optionally, the first determining unit is further configured to:
若所述第n重力加速度数据与第n-1重力加速度数据的相似度大于相似度阈值,且所述第n磁力数据与第n-1磁力数据的相似度大于所述相似度阈值,则将第n-1转换矩阵确定为第n转换矩阵,所述第n-1转换矩阵根据所述第n-1重力加速度数据和所述第n-1磁力数据确定得到;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then The n-1th conversion matrix is determined to be the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
若所述第n重力加速度数据与所述第n-1重力加速度数据的相似度小于所述相似度阈值,和/或,所述第n磁力数据与所述第n-1磁力数据的相似度小于所述相似度阈值,则根据所述第n重力加速度数据和所述第n磁力数据确定所述第n转换矩阵;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic force data and the n-1th magnetic force data Less than the similarity threshold, determine the nth conversion matrix according to the nth gravitational acceleration data and the nth magnetic force data;
可选的,所述数据转换单元,还用于:Optionally, the data conversion unit is further used for:
通过所述第n转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。The first acceleration data is converted into the second acceleration data through the nth conversion matrix.
可选的,所述第一确定模块1103,包括:Optionally, the first determining module 1103 includes:
第一输出单元,用于将所述目标时长内的所述第二加速度数据输入运行方向预测模型,得到所述运行方向预测模型输出的运行方向预测结果,所述运行方向预测结果中包括各个候选运行方向对应的预测概率;The first output unit is configured to input the second acceleration data within the target duration into a running direction prediction model to obtain a running direction prediction result output by the running direction prediction model. The running direction prediction result includes each candidate The predicted probability corresponding to the running direction;
第二确定单元,用于根据各个所述候选运行方向的预测概率,确定所述地铁运行方向。The second determining unit is configured to determine the running direction of the subway according to the predicted probability of each candidate running direction.
可选的,所述运行方向预测模型采用CNN结构,所述运行方向预测模型根据样本加速度数据和样本运行方向训练得到;Optionally, the running direction prediction model adopts a CNN structure, and the running direction prediction model is obtained by training based on sample acceleration data and sample running direction;
所述样本加速度数据是所述地铁加速阶段,所述世界坐标系下各个方向的加速度数据,所述样本运行方向是地铁的实际运行方向。The sample acceleration data is the acceleration data of each direction in the world coordinate system during the acceleration phase of the subway, and the sample running direction is the actual running direction of the subway.
可选的,所述装置还包括:Optionally, the device further includes:
第二确定模块,用于根据当前站点和目标站点确定终点站点,所述目标站点位于所述当前站点与所述终点站点之间;A second determining module, configured to determine an end station based on a current station and a target station, where the target station is located between the current station and the end station;
查找模块,用于根据所述当前站点和所述终点站点,从数据库中查找目标地铁运行方向,所述目标地铁运行方向是地铁由所述当前站点运行至所述终点站点时的运行方向;The searching module is configured to search for a target subway running direction from a database according to the current station and the terminal station, where the target subway running direction is the running direction of the subway when the subway runs from the current station to the terminal station;
提示模块,用于若确定出的所述地铁运行方向与所述目标地铁运行方向不匹配,则进行换乘提示。The prompting module is used to perform transfer prompts if the determined running direction of the subway does not match the target running direction of the subway.
可选的,所述地铁加速阶段包括地铁启动阶段;Optionally, the subway acceleration phase includes a subway startup phase;
可选的,所述装置还包括:Optionally, the device further includes:
采集模块,用于通过麦克风采集环境音;Collection module, used to collect ambient sound through a microphone;
第三确定模块,用于当识别出所述环境音中包括地铁关门警铃声时,确定处于所述地铁启动阶段。The third determining module is configured to determine that the subway is in the start-up phase when it is recognized that the ambient sound includes the subway door-closing alarm bell.
可选的,所述第三确定模块,包括:Optionally, the third determining module includes:
特征提取单元,用于对所述环境音进行音频特征提取,得到音频特征矩阵;A feature extraction unit, configured to perform audio feature extraction on the environmental sound to obtain an audio feature matrix;
第二输出单元,用于将所述音频特征矩阵输入声音识别模型,得到所述声音识别模型输出的警铃声识别结果,所述警铃声识别结果用于指示所述环境音中是否包含所述地铁关门警铃声;The second output unit is configured to input the audio feature matrix into a voice recognition model to obtain a warning bell recognition result output by the voice recognition model, and the warning bell recognition result is used to indicate whether the ambient sound contains the subway Door-closing alarm bell;
第三确定单元,用于若所述警铃声识别结果指示所述环境音中包含所述地铁关门警铃声,则确定处于所述地铁启动阶段。The third determining unit is configured to determine that it is in the start-up phase of the subway if the alarm bell recognition result indicates that the environmental sound includes the subway door-closing alarm bell.
可选的,所述第一确定单元,还用于:Optionally, the first determining unit is further configured to:
根据所述重力加速度数据和所述磁力数据,确定所述世界坐标系下各个方向上的单位向量在所述终端坐标系中对应的目标向量;Determine, according to the gravitational acceleration data and the magnetic force data, the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system;
根据所述单位向量和所述目标向量,确定所述世界坐标系和所述终端坐标系之间的所述转换矩阵。Determine the conversion matrix between the world coordinate system and the terminal coordinate system according to the unit vector and the target vector.
本申请实施例中,当地铁处于加速阶段时,终端通过线性加速度传感器采集终端坐标系下各个方向的加速度数据(第一加速度数据),并对该第一加速度数据进行转换,得到世界坐标系下各个方向的加速度数据(第二加速度数据),从而根据目标时长内的第二加速度数据,确定地铁运行方向。通过将终端采集到的第一加速度数据转换为第二加速度数据,由于世界坐标系的唯一性,避免了终端姿态对获取到的加速度方向的影响,从而提高了确定地铁运行方向的准确性,此外,通过对目标时长内的第二加速度数据进行综合分析,来确定地铁运行方向,可以避免单个加速度方向不稳定导致确定地铁运行方向不准确的问题。In the embodiment of the present application, when the subway is in the acceleration phase, the terminal collects acceleration data (first acceleration data) in various directions in the terminal coordinate system through the linear acceleration sensor, and transforms the first acceleration data to obtain the world coordinate system Acceleration data (second acceleration data) in each direction, so as to determine the subway running direction according to the second acceleration data within the target duration. By converting the first acceleration data collected by the terminal into the second acceleration data, due to the uniqueness of the world coordinate system, the influence of the terminal attitude on the acquired acceleration direction is avoided, thereby improving the accuracy of determining the direction of subway operation. In addition, , Through the comprehensive analysis of the second acceleration data within the target duration to determine the direction of the subway, the problem of inaccurate determination of the direction of the subway due to the instability of a single acceleration direction can be avoided.
请参考图12,其示出了本申请一个示例性实施例提供的终端1200的结构方框图。该终端1200可以是智能手机、平板电脑、电子书、便携式个人计算机等安装并运行有应用程序的电子设备。本申请中的终端1200可以包括一个或多个如下部件:处理器1210、存储器1220、屏幕1230和传感器1240。Please refer to FIG. 12, which shows a structural block diagram of a terminal 1200 according to an exemplary embodiment of the present application. The terminal 1200 may be an electronic device with an application installed and running, such as a smart phone, a tablet computer, an e-book, or a portable personal computer. The terminal 1200 in this application may include one or more of the following components: a processor 1210, a memory 1220, a screen 1230, and a sensor 1240.
处理器1210可以包括一个或者多个处理核心。处理器1210利用各种接口和线路连接整个终端1200内的各个部分,通过运行或执行存储在存储器1220内的指令、程序、代码集或指令集,以及调用存储在存储器1220内的数据,执行终端1200的各种功能和处理数据。可选地,处理器1210可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器1210可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责屏幕1230所需要显示的内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器1210中,单独通过一块通信芯片进行实现。The processor 1210 may include one or more processing cores. The processor 1210 uses various interfaces and lines to connect various parts of the entire terminal 1200, and executes the terminal by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1220, and calling data stored in the memory 1220. The various functions and processing data of the 1200. Optionally, the processor 1210 may adopt at least one of digital signal processing (Digital Signal Processing, DSP), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA), and Programmable Logic Array (Programmable Logic Array, PLA). A kind of hardware form to realize. The processor 1210 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), a modem, and the like. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is used for rendering and drawing the content that needs to be displayed on the screen 1230; the modem is used for processing wireless communication. It is understandable that the above-mentioned modem may not be integrated into the processor 1210, but may be implemented by a communication chip alone.
存储器1220可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory,ROM)。可选地,该存储器1220包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器1220可用于存储指令、程序、代码、代码集或指令集。存储器1220可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于实现至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现上述各个方法实施例的指令等,该操作系统可以是安卓(Android)系统(包括基于Android系统深度开发的系统)、苹果公司开发的IOS系统(包括基于IOS系统深度开发的系统)或其它系统。存储数据区还可以存储终端1200在使用中所创建的数据(比如电话本、音视频数据、聊天记录数据)等。The memory 1220 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 1220 includes a non-transitory computer-readable storage medium. The memory 1220 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 1220 may include a program storage area and a data storage area, where the program storage area may store instructions for implementing the operating system and instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.) , The instructions used to implement the foregoing various method embodiments, etc., the operating system may be the Android system (including the system based on the in-depth development of the Android system), the IOS system developed by Apple (including the system based on the in-depth development of the IOS system) Or other systems. The data storage area can also store data created during use of the terminal 1200 (such as phone book, audio and video data, chat record data) and the like.
屏幕1230可以为电容式触摸显示屏,该电容式触摸显示屏用于接收用户使用手指、触摸笔等任何适合的物体在其上或附近的触摸操作,以及显示各个应用程序的用户界面。触摸显示屏通常设置在终端1200的前面板。触摸显示屏可被设计成为全面屏、曲面屏或异型屏。触摸显示屏还可被设计成为全面屏与曲面屏的结合,异型屏与曲面屏的结合,本申请实施例对此不加以限定。The screen 1230 may be a capacitive touch display screen, which is used to receive a user's touch operation on or near any suitable object such as a finger, a touch pen, etc., and display the user interface of each application program. The touch screen is usually set on the front panel of the terminal 1200. The touch screen can be designed as a full screen, curved screen or special-shaped screen. The touch display screen can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in the embodiments of the present application.
传感器1240用于采集传感器数据,本申请实施例中,传感器1240可以包括线性加速度传感器、重力加速度传感器以及磁力计,其中,线性加速度传感器用来采集第一加速度数据,重力加速度传感器用来获取重力加速度数据,磁力计用来获取磁力数据。可选的,终端1200中还可以包括温度传感器、湿度传感器、压力传感器、接近传感器等,本申请实施例对此不构成限定。The sensor 1240 is used to collect sensor data. In the embodiment of the present application, the sensor 1240 may include a linear acceleration sensor, a gravity acceleration sensor, and a magnetometer. The linear acceleration sensor is used to collect first acceleration data, and the gravity acceleration sensor is used to obtain gravity acceleration. Data, a magnetometer is used to obtain magnetic data. Optionally, the terminal 1200 may further include a temperature sensor, a humidity sensor, a pressure sensor, a proximity sensor, etc., which are not limited in the embodiment of the present application.
除此之外,本领域技术人员可以理解,上述附图所示出的终端1200的结构并不构成对终端1200的限定,终端可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。比如,终端1200中还包括射频电路、拍摄组件、除上述传感器之外的传感器、音频电路、无线保真(Wireless Fidelity,WiFi)组件、电源、蓝牙组件等部件,在此不再赘述。In addition, those skilled in the art can understand that the structure of the terminal 1200 shown in the above drawings does not constitute a limitation on the terminal 1200, and the terminal may include more or less components than those shown in the figure, or a combination of certain components. Components, or different component arrangements. For example, the terminal 1200 also includes radio frequency circuits, photographing components, sensors other than the above-mentioned sensors, audio circuits, wireless fidelity (WiFi) components, power supplies, Bluetooth components and other components, which will not be repeated here.
本申请实施例还提供了一种计算机可读介质,该计算机可读介质存储有至少一条指令,所述至少一条指令由所述处理器加载并执行以实现如上各个实施例所述的地铁运行方向的确定方法。The embodiments of the present application also provide a computer-readable medium that stores at least one instruction, and the at least one instruction is loaded and executed by the processor to realize the subway running direction as described in each of the above embodiments. The method of determining.
根据本申请的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。终端的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该终端执行上述方面的各种可选实现方式中提供的地铁运行方向的确定方法。According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the terminal reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the terminal executes the method for determining the subway running direction provided in the various optional implementations of the foregoing aspects.
本领域技术人员应该可以意识到,在上述一个或多个示例中,本申请实施例所描述的功 能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。Those skilled in the art should be aware that, in one or more of the foregoing examples, the functions described in the embodiments of the present application can be implemented by hardware, software, firmware, or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on the computer-readable medium. The computer-readable medium includes a computer storage medium and a communication medium, where the communication medium includes any medium that facilitates the transfer of a computer program from one place to another. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only optional embodiments of this application and are not intended to limit this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection of this application. Within range.

Claims (20)

  1. 一种地铁运行方向的确定方法,所述方法用于终端,所述方法包括:A method for determining the running direction of a subway, the method is used in a terminal, and the method includes:
    在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,所述第一加速度数据中包括终端坐标系下各个方向的加速度数据;During the subway acceleration phase, acquiring first acceleration data collected by the linear acceleration sensor, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
    将所述第一加速度数据转换为第二加速度数据,所述第二加速度数据中包括世界坐标系下各个方向的加速度数据;Converting the first acceleration data into second acceleration data, where the second acceleration data includes acceleration data in various directions in the world coordinate system;
    根据目标时长内的所述第二加速度数据,确定地铁运行方向。Determine the running direction of the subway according to the second acceleration data within the target duration.
  2. 根据权利要求1所述的方法,其中,所述终端中设置有重力加速度传感器和磁力计;The method according to claim 1, wherein a gravity acceleration sensor and a magnetometer are provided in the terminal;
    所述将所述第一加速度数据转换为第二加速度数据,包括:The converting the first acceleration data into second acceleration data includes:
    获取所述重力加速度传感器采集到的重力加速度数据,以及所述磁力计采集到的磁力数据,所述重力加速度数据和所述磁力数据基于所述终端坐标系;Acquiring gravity acceleration data collected by the gravity acceleration sensor and magnetic force data collected by the magnetometer, where the gravity acceleration data and the magnetic force data are based on the terminal coordinate system;
    根据所述重力加速度数据和所述磁力数据确定转换矩阵,所述转换矩阵用于将所述终端坐标系下的加速度数据转换为所述世界坐标系下的加速度数据;Determining a conversion matrix according to the gravitational acceleration data and the magnetic force data, the conversion matrix being used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system;
    通过所述转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。Through the conversion matrix, the first acceleration data is converted into the second acceleration data.
  3. 根据权利要求2所述的方法,其中,所述线性加速度传感器、所述重力加速度传感器和所述磁力计按照目标采样频率进行数据采集;The method according to claim 2, wherein the linear acceleration sensor, the gravitational acceleration sensor, and the magnetometer perform data collection according to a target sampling frequency;
    所述获取所述重力加速度传感器采集到的重力加速度数据,以及所述磁力计采集到的磁力数据,包括:The acquiring the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer includes:
    获取所述重力加速度传感器采集到的第n重力加速度数据,以及所述磁力计采集到的第n磁力数据,n为大于等于2的整数;Acquiring the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2;
    所述根据所述重力加速度数据和所述磁力数据确定转换矩阵,包括:The determining a conversion matrix according to the gravitational acceleration data and the magnetic force data includes:
    若所述第n重力加速度数据与第n-1重力加速度数据的相似度大于相似度阈值,且所述第n磁力数据与第n-1磁力数据的相似度大于所述相似度阈值,则将第n-1转换矩阵确定为第n转换矩阵,所述第n-1转换矩阵根据所述第n-1重力加速度数据和所述第n-1磁力数据确定得到;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then The n-1th conversion matrix is determined to be the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
    若所述第n重力加速度数据与所述第n-1重力加速度数据的相似度小于所述相似度阈值,和/或,所述第n磁力数据与所述第n-1磁力数据的相似度小于所述相似度阈值,则根据所述第n重力加速度数据和所述第n磁力数据确定所述第n转换矩阵;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic force data and the n-1th magnetic force data Less than the similarity threshold, determine the nth conversion matrix according to the nth gravitational acceleration data and the nth magnetic force data;
    所述通过所述转换矩阵,将所述第一加速度数据转换为所述第二加速度数据,包括:The converting the first acceleration data into the second acceleration data through the conversion matrix includes:
    通过所述第n转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。The first acceleration data is converted into the second acceleration data through the nth conversion matrix.
  4. 根据权利要求1至3任一所述的方法,其中,所述根据目标时长内的所述第二加速度数据,确定地铁运行方向,包括:The method according to any one of claims 1 to 3, wherein the determining the subway running direction according to the second acceleration data within the target duration includes:
    将所述目标时长内的所述第二加速度数据输入运行方向预测模型,得到所述运行方向预测模型输出的运行方向预测结果,所述运行方向预测结果中包括各个候选运行方向对应的预测概率;Inputting the second acceleration data within the target duration into a running direction prediction model to obtain a running direction prediction result output by the running direction prediction model, and the running direction prediction result includes the prediction probability corresponding to each candidate running direction;
    根据各个所述候选运行方向的预测概率,确定所述地铁运行方向。The subway running direction is determined according to the predicted probability of each candidate running direction.
  5. 根据权利要求4所述的方法,其中,所述运行方向预测模型采用卷积神经网络CNN结构,所述运行方向预测模型根据样本加速度数据和样本运行方向训练得到;The method according to claim 4, wherein the running direction prediction model adopts a convolutional neural network CNN structure, and the running direction prediction model is obtained by training according to sample acceleration data and sample running direction;
    所述样本加速度数据是所述地铁加速阶段,所述世界坐标系下各个方向的加速度数据,所述样本运行方向是地铁的实际运行方向。The sample acceleration data is the acceleration data of the subway in various directions under the world coordinate system, and the sample running direction is the actual running direction of the subway.
  6. 根据权利要求1至3任一所述的方法,其中,所述根据目标时长内的所述第二加速度数据,确定地铁运行方向之后,所述方法还包括:The method according to any one of claims 1 to 3, wherein after the determining the subway running direction according to the second acceleration data within the target duration, the method further comprises:
    根据当前站点和目标站点确定终点站点,所述目标站点位于所述当前站点与所述终点站点之间;Determining an end station according to a current station and a target station, where the target station is located between the current station and the end station;
    根据所述当前站点和所述终点站点,从数据库中查找目标地铁运行方向,所述目标地铁运行方向是地铁由所述当前站点运行至所述终点站点时的运行方向;Searching for a target subway running direction from a database according to the current station and the terminal station, where the target subway running direction is the running direction of the subway when the subway runs from the current station to the terminal station;
    若确定出的所述地铁运行方向与所述目标地铁运行方向不匹配,则进行换乘提示。If the determined running direction of the subway does not match the target running direction of the subway, a transfer prompt is performed.
  7. 根据权利要求1至3任一所述的方法,其中,所述地铁加速阶段包括地铁启动阶段;The method according to any one of claims 1 to 3, wherein the subway acceleration phase includes a subway startup phase;
    所述在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据之前,所述方法还包括:Before acquiring the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, the method further includes:
    通过麦克风采集环境音;Collect ambient sound through a microphone;
    当识别出所述环境音中包括地铁关门警铃声时,确定处于所述地铁启动阶段。When it is recognized that the environmental sound includes a subway door-closing alarm bell, it is determined that the subway is in the starting phase.
  8. 根据权利要求7所述的方法,其中,所述当识别出所述环境音中包括地铁关门警铃声时,确定处于所述地铁启动阶段,包括:The method according to claim 7, wherein the determining that the subway is in the start-up phase when it is recognized that the ambient sound includes a subway door-closing alarm bell includes:
    对所述环境音进行音频特征提取,得到音频特征矩阵;Performing audio feature extraction on the ambient sound to obtain an audio feature matrix;
    将所述音频特征矩阵输入声音识别模型,得到所述声音识别模型输出的警铃声识别结果,所述警铃声识别结果用于指示所述环境音中是否包含所述地铁关门警铃声;Inputting the audio feature matrix into a voice recognition model to obtain a warning bell recognition result output by the voice recognition model, the warning bell recognition result being used to indicate whether the ambient sound includes the subway closing warning bell;
    若所述警铃声识别结果指示所述环境音中包含所述地铁关门警铃声,则确定处于所述地铁启动阶段。If the alarm bell recognition result indicates that the ambient sound includes the subway closing alarm bell, it is determined that it is in the subway startup stage.
  9. 根据权利要求2所述的方法,其中,所述根据所述重力加速度数据和所述磁力数据确定转换矩阵,包括:The method according to claim 2, wherein said determining a conversion matrix according to said gravitational acceleration data and said magnetic force data comprises:
    根据所述重力加速度数据和所述磁力数据,确定所述世界坐标系下各个方向上的单位向量在所述终端坐标系中对应的目标向量;Determine, according to the gravitational acceleration data and the magnetic force data, the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system;
    根据所述单位向量和所述目标向量,确定所述世界坐标系和所述终端坐标系之间的所述转换矩阵。Determine the conversion matrix between the world coordinate system and the terminal coordinate system according to the unit vector and the target vector.
  10. 一种地铁运行方向的确定装置,所述装置用于终端,所述装置包括:A device for determining the running direction of a subway, the device is used in a terminal, and the device includes:
    获取模块,用于在地铁加速阶段,获取线性加速度传感器采集到的第一加速度数据,所述第一加速度数据中包括终端坐标系下各个方向的加速度数据;The acquiring module is configured to acquire the first acceleration data collected by the linear acceleration sensor during the subway acceleration phase, where the first acceleration data includes acceleration data in various directions in the terminal coordinate system;
    数据转换模块,用于将所述第一加速度数据转换为第二加速度数据,所述第二加速度数据中包括世界坐标系下各个方向的加速度数据;A data conversion module, configured to convert the first acceleration data into second acceleration data, the second acceleration data including acceleration data in various directions in the world coordinate system;
    第一确定模块,用于根据目标时长内的所述第二加速度数据,确定地铁运行方向。The first determining module is configured to determine the running direction of the subway according to the second acceleration data within the target duration.
  11. 根据权利要求10所述的装置,其中,所述终端中设置有重力加速度传感器和磁力计;The device according to claim 10, wherein a gravity acceleration sensor and a magnetometer are provided in the terminal;
    所述数据转换模块,包括:The data conversion module includes:
    获取单元,用于获取所述重力加速度传感器采集到的重力加速度数据,以及所述磁力计采集到的磁力数据,所述重力加速度数据和所述磁力数据基于所述终端坐标系;An acquiring unit, configured to acquire the gravity acceleration data collected by the gravity acceleration sensor and the magnetic force data collected by the magnetometer, the gravity acceleration data and the magnetic force data being based on the terminal coordinate system;
    第一确定单元,用于根据所述重力加速度数据和所述磁力数据确定转换矩阵,所述转换矩阵用于将所述终端坐标系下的加速度数据转换为所述世界坐标系下的加速度数据;A first determining unit, configured to determine a conversion matrix according to the gravity acceleration data and the magnetic force data, the conversion matrix being used to convert acceleration data in the terminal coordinate system into acceleration data in the world coordinate system;
    数据转换单元,用于通过所述转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。The data conversion unit is configured to convert the first acceleration data into the second acceleration data through the conversion matrix.
  12. 根据权利要求11所述的装置,其中,所述线性加速度传感器、所述重力加速度传感器和所述磁力计按照目标采样频率进行数据采集;The device according to claim 11, wherein the linear acceleration sensor, the gravitational acceleration sensor, and the magnetometer perform data collection according to a target sampling frequency;
    所述获取单元,还用于:The acquiring unit is also used for:
    获取所述重力加速度传感器采集到的第n重力加速度数据,以及所述磁力计采集到的第n磁力数据,n为大于等于2的整数;Acquiring the nth gravitational acceleration data collected by the gravitational acceleration sensor and the nth magnetic force data collected by the magnetometer, where n is an integer greater than or equal to 2;
    所述第一确定单元,还用于:The first determining unit is further configured to:
    若所述第n重力加速度数据与第n-1重力加速度数据的相似度大于相似度阈值,且所述第n磁力数据与第n-1磁力数据的相似度大于所述相似度阈值,则将第n-1转换矩阵确定为第n转换矩阵,所述第n-1转换矩阵根据所述第n-1重力加速度数据和所述第n-1磁力数据确定得到;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is greater than the similarity threshold, and the similarity between the nth magnetic data and the n-1th magnetic data is greater than the similarity threshold, then The n-1th conversion matrix is determined to be the nth conversion matrix, and the n-1th conversion matrix is determined according to the n-1th gravitational acceleration data and the n-1th magnetic force data;
    若所述第n重力加速度数据与所述第n-1重力加速度数据的相似度小于所述相似度阈值,和/或,所述第n磁力数据与所述第n-1磁力数据的相似度小于所述相似度阈值,则根据所述第n重力加速度数据和所述第n磁力数据确定所述第n转换矩阵;If the similarity between the nth gravitational acceleration data and the n-1th gravitational acceleration data is less than the similarity threshold, and/or the similarity between the nth magnetic force data and the n-1th magnetic force data Less than the similarity threshold, determine the nth conversion matrix according to the nth gravitational acceleration data and the nth magnetic force data;
    所述数据转换单元,还用于:The data conversion unit is also used for:
    通过所述第n转换矩阵,将所述第一加速度数据转换为所述第二加速度数据。The first acceleration data is converted into the second acceleration data through the nth conversion matrix.
  13. 根据权利要求10至12任一所述的装置,其中,所述第一确定模块,包括:The device according to any one of claims 10 to 12, wherein the first determining module comprises:
    第一输出单元,用于将所述目标时长内的所述第二加速度数据输入运行方向预测模型,得到所述运行方向预测模型输出的运行方向预测结果,所述运行方向预测结果中包括各个候选运行方向对应的预测概率;The first output unit is configured to input the second acceleration data within the target duration into a running direction prediction model to obtain a running direction prediction result output by the running direction prediction model. The running direction prediction result includes each candidate The predicted probability corresponding to the running direction;
    第二确定单元,用于根据各个所述候选运行方向的预测概率,确定所述地铁运行方向。The second determining unit is configured to determine the running direction of the subway according to the predicted probability of each candidate running direction.
  14. 根据权利要求13所述的装置,其中,所述运行方向预测模型采用CNN结构,所述运行方向预测模型根据样本加速度数据和样本运行方向训练得到;The device according to claim 13, wherein the running direction prediction model adopts a CNN structure, and the running direction prediction model is obtained by training based on sample acceleration data and sample running direction;
    所述样本加速度数据是所述地铁加速阶段,所述世界坐标系下各个方向的加速度数据,所述样本运行方向是地铁的实际运行方向。The sample acceleration data is the acceleration data of the subway in various directions under the world coordinate system, and the sample running direction is the actual running direction of the subway.
  15. 根据权利要求10至12任一所述的装置,其中,所述装置还包括:The device according to any one of claims 10 to 12, wherein the device further comprises:
    第二确定模块,用于根据当前站点和目标站点确定终点站点,所述目标站点位于所述当前站点与所述终点站点之间;A second determining module, configured to determine an end station according to a current station and a target station, the target station being located between the current station and the end station;
    查找模块,用于根据所述当前站点和所述终点站点,从数据库中查找目标地铁运行方向,所述目标地铁运行方向是地铁由所述当前站点运行至所述终点站点时的运行方向;The searching module is configured to search a target subway running direction from a database according to the current station and the terminal station, where the target subway running direction is the running direction of the subway when the subway runs from the current station to the terminal station;
    提示模块,用于若确定出的所述地铁运行方向与所述目标地铁运行方向不匹配,则进行换乘提示。A prompting module is used to perform transfer prompts if the determined running direction of the subway does not match the target running direction of the subway.
  16. 根据权利要求10至12任一所述的装置,其中,所述地铁加速阶段包括地铁启动阶段;The device according to any one of claims 10 to 12, wherein the subway acceleration phase includes a subway startup phase;
    所述装置还包括:The device also includes:
    采集模块,用于通过麦克风采集环境音;Collection module, used to collect ambient sound through a microphone;
    第三确定模块,用于当识别出所述环境音中包括地铁关门警铃声时,确定处于所述地铁启动阶段。The third determining module is configured to determine that the subway is in the start-up phase when it is recognized that the ambient sound includes the subway door-closing alarm bell.
  17. 根据权利要求16所述的装置,其中,所述第三确定模块,包括:The device according to claim 16, wherein the third determining module comprises:
    特征提取单元,用于对所述环境音进行音频特征提取,得到音频特征矩阵;A feature extraction unit, configured to perform audio feature extraction on the environmental sound to obtain an audio feature matrix;
    第二输出单元,用于将所述音频特征矩阵输入声音识别模型,得到所述声音识别模型输出的警铃声识别结果,所述警铃声识别结果用于指示所述环境音中是否包含所述地铁关门警铃声;The second output unit is configured to input the audio feature matrix into a voice recognition model to obtain a warning bell recognition result output by the voice recognition model, and the warning bell recognition result is used to indicate whether the ambient sound contains the subway Door-closing alarm bell;
    第三确定单元,用于若所述警铃声识别结果指示所述环境音中包含所述地铁关门警铃声,则确定处于所述地铁启动阶段。The third determining unit is configured to determine that it is in the start-up phase of the subway if the alarm bell recognition result indicates that the ambient sound includes the subway door-closing alarm bell.
  18. 根据权利要求12所述的装置,其中,所述第一确定单元,还用于:The device according to claim 12, wherein the first determining unit is further configured to:
    根据所述重力加速度数据和所述磁力数据,确定所述世界坐标系下各个方向上的单位向量在所述终端坐标系中对应的目标向量;Determine, according to the gravitational acceleration data and the magnetic force data, the target vector corresponding to the unit vector in each direction in the world coordinate system in the terminal coordinate system;
    根据所述单位向量和所述目标向量,确定所述世界坐标系和所述终端坐标系之间的所述转换矩阵。Determine the conversion matrix between the world coordinate system and the terminal coordinate system according to the unit vector and the target vector.
  19. 一种终端,所述终端包括处理器和存储器;所述存储器存储有至少一条指令,所述至少一条指令用于被所述处理器执行以实现如权利要求1至9任一所述的地铁运行方向的确定方法。A terminal comprising a processor and a memory; the memory stores at least one instruction, and the at least one instruction is used to be executed by the processor to realize the subway operation according to any one of claims 1 to 9 How to determine the direction.
  20. 一种计算机可读存储介质,所述存储介质存储有至少一条指令,所述至少一条指令用于被处理器执行以实现如权利要求1至9任一所述的地铁运行方向的确定方法。A computer-readable storage medium, the storage medium stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the method for determining a subway running direction according to any one of claims 1 to 9.
PCT/CN2020/134578 2019-12-10 2020-12-08 Method and apparatus for determining running direction of metro train, and terminal and storage medium WO2021115268A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911259924.2 2019-12-10
CN201911259924.2A CN110972112B (en) 2019-12-10 2019-12-10 Subway running direction determining method, device, terminal and storage medium

Publications (1)

Publication Number Publication Date
WO2021115268A1 true WO2021115268A1 (en) 2021-06-17

Family

ID=70033796

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/134578 WO2021115268A1 (en) 2019-12-10 2020-12-08 Method and apparatus for determining running direction of metro train, and terminal and storage medium

Country Status (2)

Country Link
CN (1) CN110972112B (en)
WO (1) WO2021115268A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110972112B (en) * 2019-12-10 2022-04-05 Oppo广东移动通信有限公司 Subway running direction determining method, device, terminal and storage medium
CN111366150B (en) * 2020-04-20 2022-03-18 Oppo广东移动通信有限公司 Running direction detection method and device, electronic equipment and storage medium
CN112188037B (en) * 2020-09-24 2023-03-24 影石创新科技股份有限公司 Method for generating gyroscope rotation direction and computer equipment
CN113091769A (en) * 2021-03-30 2021-07-09 Oppo广东移动通信有限公司 Attitude calibration method and device, storage medium and electronic equipment
CN115112124A (en) * 2022-06-29 2022-09-27 维沃移动通信(深圳)有限公司 Motion state determination method and device, electronic equipment and readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105142112A (en) * 2015-09-24 2015-12-09 广东欧珀移动通信有限公司 Method and device for automatically detecting subway environment and automatically announcing stops with mobile terminal
WO2019000417A1 (en) * 2017-06-30 2019-01-03 SZ DJI Technology Co., Ltd. Map generation systems and methods
CN110006438A (en) * 2019-02-15 2019-07-12 腾讯大地通途(北京)科技有限公司 Navigation control method, device and computer equipment
CN110068322A (en) * 2019-04-18 2019-07-30 中国电子科技集团公司电子科学研究院 A kind of pedestrian's localization method and pedestrian's positioning device based on terminal
CN110972112A (en) * 2019-12-10 2020-04-07 Oppo广东移动通信有限公司 Subway running direction determining method, device, terminal and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101514900B (en) * 2009-04-08 2011-01-26 哈尔滨工程大学 Method for initial alignment of a single-axis rotation strap-down inertial navigation system (SINS)
CN107449418B (en) * 2016-12-26 2021-10-01 浙江斑智科技有限公司 User walking direction calculation method based on accelerometer and magnetometer
JP2018190310A (en) * 2017-05-11 2018-11-29 学校法人同志社 Device and method for estimating attention decrease of driver
CN108846663B (en) * 2018-06-21 2020-10-30 维沃移动通信有限公司 Two-dimensional code adjusting method and device and mobile terminal
CN110118560B (en) * 2019-05-28 2023-03-10 东北大学 Indoor positioning method based on LSTM and multi-sensor fusion

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105142112A (en) * 2015-09-24 2015-12-09 广东欧珀移动通信有限公司 Method and device for automatically detecting subway environment and automatically announcing stops with mobile terminal
WO2019000417A1 (en) * 2017-06-30 2019-01-03 SZ DJI Technology Co., Ltd. Map generation systems and methods
CN110006438A (en) * 2019-02-15 2019-07-12 腾讯大地通途(北京)科技有限公司 Navigation control method, device and computer equipment
CN110068322A (en) * 2019-04-18 2019-07-30 中国电子科技集团公司电子科学研究院 A kind of pedestrian's localization method and pedestrian's positioning device based on terminal
CN110972112A (en) * 2019-12-10 2020-04-07 Oppo广东移动通信有限公司 Subway running direction determining method, device, terminal and storage medium

Also Published As

Publication number Publication date
CN110972112B (en) 2022-04-05
CN110972112A (en) 2020-04-07

Similar Documents

Publication Publication Date Title
WO2021115268A1 (en) Method and apparatus for determining running direction of metro train, and terminal and storage medium
CN111179975B (en) Voice endpoint detection method for emotion recognition, electronic device and storage medium
WO2016150001A1 (en) Speech recognition method, device and computer storage medium
CN107240398B (en) Intelligent voice interaction method and device
US20200294488A1 (en) Method, device and storage medium for speech recognition
US8918320B2 (en) Methods, apparatuses and computer program products for joint use of speech and text-based features for sentiment detection
US8930187B2 (en) Methods, apparatuses and computer program products for implementing automatic speech recognition and sentiment detection on a device
CN109473123A (en) Voice activity detection method and device
CN108573701A (en) Inquiry based on lip detecting is endpoint formatting
WO2021169742A1 (en) Method and device for predicting operating state of transportation means, and terminal and storage medium
CN113129867B (en) Training method of voice recognition model, voice recognition method, device and equipment
WO2021115232A1 (en) Arrival reminding method and device, terminal, and storage medium
CN110223687B (en) Instruction execution method and device, storage medium and electronic equipment
CN107274903A (en) Text handling method and device, the device for text-processing
TW201911290A (en) System and method for language based service calls
US11830501B2 (en) Electronic device and operation method for performing speech recognition
CN113984078B (en) Arrival reminding method, device, terminal and storage medium
CN111128131B (en) Voice recognition method and device, electronic equipment and computer readable storage medium
CN112016387A (en) Contraband identification method and device suitable for millimeter wave security check instrument
CN111312223A (en) Training method and device of voice segmentation model and electronic equipment
CN111312224A (en) Training method and device of voice segmentation model and electronic equipment
CN111627422B (en) Voice acceleration detection method, device and equipment and readable storage medium
WO2021169757A1 (en) Method and apparatus for giving reminder of arrival at station, storage medium and electronic device
CN113948089A (en) Voiceprint model training and voiceprint recognition method, device, equipment and medium
CN111899718A (en) Method, apparatus, device and medium for recognizing synthesized speech

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20899106

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20899106

Country of ref document: EP

Kind code of ref document: A1