A dangerous driving behavior identification method of a mobile terminal of a network car
By deploying a lightweight CNN-LSTM hybrid model on ride-hailing mobile terminals and combining asynchronous data acquisition and dynamic resource configuration, the problems of high resource consumption and long recognition latency in existing technologies are solved. This enables low-power, high-precision, and real-time recognition of dangerous driving behaviors on iOS systems, ensuring data security and stability.
Patent Information
- Application Number
- CN202611091992.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies in ride-hailing services suffer from problems such as excessively large models, high resource consumption, and long recognition delays, making it difficult to achieve real-time and efficient recognition of dangerous driving behaviors. In particular, they exhibit poor stability when running in the background on iOS systems.
A lightweight CNN-LSTM hybrid model is deployed locally on the mobile terminal. By combining asynchronous data acquisition and dynamic resource configuration with GPU acceleration and background task management, efficient recognition of multi-dimensional sensor data can be achieved.
It achieves real-time identification of dangerous driving behaviors with low power consumption and high stability, reduces model size and resource consumption, ensures real-time early warning capability under any network conditions, and guarantees data security and integrity through encrypted caching.
Smart Images

Figure CN123158496A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence and mobile computing technology, specifically to a method for identifying dangerous driving behaviors in ride-hailing mobile terminals. Background Technology
[0002] With the rapid development of the ride-hailing industry, real-time monitoring and safety management of driver behavior has become a crucial aspect of ensuring passenger safety and improving platform service quality. Utilizing smartphone built-in sensors combined with artificial intelligence technology to identify dangerous driving behaviors is currently the mainstream technological approach.
[0003] Currently, dangerous driving behavior identification solutions are mainly divided into two types: cloud-based identification and local identification. Cloud-based identification solutions upload sensor data collected by mobile terminals to servers, where large-scale models in the cloud analyze the data. While this approach utilizes powerful models, it heavily relies on network connectivity and cannot provide real-time warnings in scenarios with poor signal or offline conditions. Furthermore, continuous data uploads significantly increase the mobile terminal's data and battery consumption.
[0004] To overcome the drawbacks of cloud-based solutions, local recognition solutions that deploy AI (artificial intelligence) models on mobile terminals have emerged.
[0005] An existing local recognition solution for ride-hailing services attempts to analyze dangerous driving behavior on the device side. This solution uses an unoptimized traditional convolutional neural network (CNN) model, which is large and resource-intensive. Its data acquisition method is synchronous, and it only uses data from a single accelerometer, limiting the recognition dimensions. Model inference relies entirely on the central processing unit (CPU) without utilizing graphics processing unit (GPU) acceleration, resulting in long inference latency.
[0006] In summary, existing technologies for local dangerous driving behavior recognition generally suffer from many drawbacks, such as excessively large models, high resource consumption, and long recognition latency, making it difficult to meet the needs of ride-hailing scenarios. Summary of the Invention
[0007] To address the aforementioned problems in the existing technology, this invention provides a method for identifying dangerous driving behaviors in ride-hailing mobile terminals, aiming to achieve real-time and efficient identification of dangerous driving behaviors with limited resources on the mobile terminal.
[0008] The present invention provides a method for identifying dangerous driving behavior in a ride-hailing mobile terminal, comprising: performing a data acquisition operation, and asynchronously acquiring multi-dimensional sensor data during the driving process through multiple sensors of the mobile terminal; The multi-dimensional sensing data is preprocessed to obtain feature data for model inference. For the lightweight CNN-LSTM hybrid model deployed locally on the mobile terminal, the resource configuration of the data acquisition operation and the model inference is dynamically adjusted according to the real-time status and driving status of the mobile terminal. The CNN-LSTM hybrid model is used to perform model inference on the feature data to identify dangerous driving behaviors; Based on the identified dangerous driving behavior, a preset operation is triggered on the mobile terminal.
[0009] Furthermore, the lightweight processing includes at least one of knowledge distillation, model quantization, and channel pruning. This combination of techniques enables a significant reduction in model parameters and size, as well as storage and memory usage, while maintaining recognition accuracy.
[0010] Furthermore, the method also includes optimizations tailored to the operating system characteristics of the mobile terminal. For example, it utilizes a graphics processing interface framework to allocate model inference to the graphics processing unit (GPU) for execution to accelerate the process and reduce CPU load; and it requests background running permissions through a background task scheduling framework to ensure that the method can run continuously and stably when the application is in the background.
[0011] Furthermore, the dynamic adjustment of resource configuration includes: adjusting the collection frequency of the multi-dimensional sensor data according to the battery status of the mobile terminal; adjusting the inference accuracy of the model according to the hardware configuration of the mobile terminal; and adjusting the inference frequency of the model according to the driving state.
[0012] Furthermore, if the dynamic resource allocation adjustment includes adjustment based on the battery status, then the sampling frequency is reduced when the mobile terminal's battery level is below a preset battery threshold; if the dynamic resource allocation adjustment includes adjustment based on the hardware configuration, then a high-precision model is used when the mobile terminal's processor computing power is above a preset performance threshold; if the dynamic resource allocation adjustment includes adjustment based on the driving state, then the inference frequency is reduced during smooth driving and increased during complex driving. Through this refined on-demand allocation strategy, an intelligent balance between computing power and power consumption is achieved.
[0013] Furthermore, the multi-dimensional sensing data includes at least one of accelerometer data, gyroscope data, and magnetometer data acquired through the motion sensor data acquisition interface, as well as speed data acquired through the position positioning interface, providing a rich data foundation for recognizing complex driving behaviors.
[0014] Furthermore, the asynchronous acquisition includes acquiring the multi-dimensional sensor data in the data acquisition thread and storing it in the data queue, and retrieving the data from the data queue for inference in the model inference thread, thereby avoiding mutual blocking between data acquisition and model inference.
[0015] Furthermore, the preprocessing includes segmenting the multi-dimensional sensing data using a sliding window and extracting statistical features to reduce the dimensionality of the high-dimensional raw data into low-dimensional feature data, thereby reducing the computational complexity of subsequent model inference.
[0016] Furthermore, the preset operations include triggering voice alarms and interface pop-up alarms to effectively alert the driver in a multimodal manner.
[0017] Furthermore, the method also includes: encrypting and locally caching data related to the dangerous driving behavior when the mobile terminal is offline; and uploading the encrypted and cached data to the server after the mobile terminal restores its network connection, thereby ensuring the integrity and security of the critical data.
[0018] Compared with the prior art, the present invention has the following beneficial effects: 1. Lightweight and low-consumption model: Through comprehensive lightweighting, the model size and runtime memory usage are reduced to a low level, significantly reducing the consumption of mobile terminal storage and computing resources.
[0019] 2. Excellent and stable performance: Combined with the GPU acceleration of the Metal framework, it achieves millisecond-level low-latency inference; the BackgroundTasks framework ensures that the application can run stably in the background for a long time, solving the pain point of background restrictions in the iOS system.
[0020] 3. Intelligent power consumption management: By dynamically adjusting resource configuration, an intelligent balance between performance and power consumption is achieved, effectively extending the device's battery life.
[0021] 4. High precision and high compatibility: The use of a CNN-LSTM hybrid model and the fusion of multi-dimensional sensor data ensures high-precision identification of various dangerous driving behaviors; at the same time, the dynamic resource allocation strategy enables it to be widely compatible with various mobile terminals from low-end to high-end.
[0022] 5. All identification processes are completed locally on the mobile terminal, eliminating dependence on the network, ensuring real-time early warning capabilities under any network conditions, and guaranteeing data security and integrity through local encrypted caching and breakpoint resume mechanisms. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating the overall process of the dangerous driving behavior recognition method of the present invention.
[0024] Figure 2 This is a diagram of the core module architecture of the system of this invention.
[0025] Figure 3 This is a flowchart of the construction and optimization process of the CNN-LSTM hybrid model of this invention.
[0026] Figure 4 This is a flowchart of the asynchronous acquisition and preprocessing of multi-dimensional sensor data in this invention.
[0027] Figure 5 This is a flowchart of the local reasoning, recognition, and feedback process of the present invention. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0029] Current ride-hailing safety management faces numerous challenges in identifying dangerous driving behaviors. Solutions relying on cloud servers for analysis are limited by network connection stability, failing to guarantee real-time performance in weak network or offline environments. Furthermore, continuous data uploads significantly increase the power consumption and data usage of mobile devices. Existing local identification solutions, especially on iOS systems, often suffer from excessively large file sizes and high resource consumption due to insufficient model optimization. Additionally, iOS's strict background management and resource limitations make it easy for applications to be terminated in the background, hindering continuous and stable monitoring. These issues collectively make it difficult for existing technologies to achieve real-time, high-precision identification of dangerous driving behaviors while maintaining low power consumption and high stability.
[0030] This invention aims to overcome the shortcomings of the existing technologies. Its core idea lies in deploying a deeply lightweight and system-adapted CNN-LSTM hybrid model locally on a mobile terminal, combined with a dynamically adjusted resource allocation strategy. This enables real-time, low-power, high-precision, and highly stable identification of dangerous driving behaviors without relying on real-time network connections. Furthermore, this method is specifically optimized for the characteristics of the iOS system, ensuring consistently excellent performance on mobile terminals with different hardware configurations and system versions, effectively solving the compatibility problem of local AI solutions on the iOS platform.
[0031] To facilitate understanding, the core terms used in this invention are first defined. "Mobile terminal" refers to a portable electronic device with data collection and processing capabilities. In a preferred embodiment, it can be a portable electronic device running the iOS operating system, such as an iPhone, which has built-in various sensors and computing units required to execute the methods of this invention. "CNN-LSTM hybrid model" refers to a deep learning model that combines a convolutional neural network (CNN) to extract spatial features from driving data with a long short-term memory network (LSTM) to capture the sequential relationships of these features over time. "Lightweight processing" is a set of techniques aimed at reducing model size and computational complexity, which in this invention may specifically include knowledge distillation, model quantization, and channel pruning.
[0032] Furthermore, "asynchronous acquisition" refers to allocating data acquisition tasks and model inference tasks to different system threads for parallel execution to avoid mutual blocking and ensure smooth system response. "Multi-dimensional sensor data" refers to various types of data reflecting driving behavior, such as acceleration, angular velocity, and geographic location information, collected by multiple sensors built into the mobile terminal. "Feature data" is low-dimensional data extracted from the multi-dimensional sensor data after preprocessing steps (such as standardization and feature extraction), making it more suitable for input into the CNN-LSTM hybrid model for inference. "Preset actions" are feedback actions automatically executed by the mobile terminal after successfully identifying dangerous driving behavior, such as voice alerts or interface prompts. "Dynamically adjusting resource configuration" is an intelligent strategy that flexibly adjusts the data acquisition frequency or model inference strategy based on the real-time status of the mobile terminal (such as battery level and hardware performance) or the current driving state (such as smooth or complex), to maximize system resource conservation while ensuring recognition effectiveness.
[0033] In one aspect of the present invention, a method for identifying dangerous driving behaviors in ride-hailing mobile terminals is provided. For example... Figure 1 As shown, this method forms a complete closed loop from data acquisition to result feedback. The entire process begins with the construction and optimization of a locally lightweight CNN-LSTM hybrid model (S100), followed by asynchronous local acquisition of multi-dimensional data on the mobile terminal (S200). The acquired raw data undergoes data integrity verification and preprocessing (S300) to generate feature data for inference. During this process, the system dynamically adjusts resource configuration based on real-time status (S350) to balance performance and power consumption. Next, the locally deployed CNN-LSTM hybrid model is invoked for inference and recognition (S400), and finally, local feedback and abnormal data reporting are executed based on the recognition results (S500).
[0034] like Figure 2As shown, the system architecture of this invention consists of multiple collaborative modules. The data acquisition module 201 is responsible for acquiring raw data from the sensors of the mobile terminal. The data preprocessing module 202 cleans, standardizes, and reduces the dimensionality of the raw data. The model inference module 203 runs a lightweight CNN-LSTM hybrid model to perform the core recognition task. The result feedback module 204 triggers preset operations when dangerous driving behavior is detected. The data management module 205 is responsible for data encryption, caching, and uploading. The dynamic strategy control module 206 is the "brain" of the entire system; it dynamically adjusts the operating parameters of other modules based on external conditions and internal states, which is key to achieving self-adaptation and low power consumption. Through this modular design, functional decoupling and efficient collaboration are achieved.
[0035] Furthermore, to enable the CNN-LSTM hybrid model to run efficiently on resource-constrained mobile devices, this invention employs a series of lightweight processing techniques. For example... Figure 3 As shown, in the local lightweight AI model construction and optimization process, a CNN-LSTM hybrid model S110 is first selected, and then subjected to a triple lightweighting process S120. This process includes: knowledge distillation S121, transferring knowledge from a large, high-precision teacher model to a small student model, significantly compressing model parameters while maintaining core recognition capabilities; model quantization S122, converting model parameters from 32-bit floating-point numbers to 8-bit integers, significantly reducing model file size and improving inference speed; and channel pruning S123, removing redundant convolutional channels that do not contribute much to the final recognition result. This series of operations works synergistically to compress the model size from over 100MB to less than 10MB, greatly reducing the storage space occupied on mobile terminals.
[0036] As a preferred implementation, this invention also specifically adapts and optimizes for the characteristics of the iOS system (S130). Because the iOS system has strict restrictions on background tasks, regular applications are easily suspended or terminated by the system after entering the background. Therefore, this invention requests long-term background running permissions from the system through the BackgroundTasks framework, ensuring that the dangerous driving behavior recognition function can continue to run stably even when the application is not in the foreground. Furthermore, to fully utilize the hardware capabilities of iOS devices, this invention uses the Metal framework to distribute computationally intensive model inference tasks from the CPU to the graphics processing unit (GPU). The advantages of GPU parallel computing significantly shorten inference latency and reduce CPU utilization, thereby avoiding device lag and overheating caused by AI computation. Finally, the trained and optimized model is exported (S140) for deployment. The dynamic resource allocation adjustment strategy in this invention is key to achieving a balance between performance and power consumption. This strategy includes at least three aspects: First, adjusting the data acquisition frequency according to the mobile terminal's battery status. For example, when the mobile terminal's battery level is detected to be below a preset threshold (e.g., 20%), the system automatically reduces the sensor's sampling frequency, thereby directly reducing the amount of data processing and extending the device's battery life under low power conditions. Secondly, the inference accuracy of the model is adjusted according to the hardware configuration of the mobile terminal. For mobile terminals equipped with high-performance processors (such as A12 chips and above), the system will call a full-precision model to pursue recognition accuracy; while for older mobile terminals with lower configurations, it will switch to a quantized model with less computation to ensure smooth inference.
[0037] Finally, the dynamic adjustment strategy also includes adjusting the model's inference frequency based on driving conditions. The system analyzes continuous driving data to determine the current driving state. When the vehicle is driving smoothly (such as cruising on a highway), the probability of dangerous driving behavior is low, and the system will appropriately reduce the model's inference frequency, for example, from once every 500 milliseconds to once every 2 seconds, thereby reducing unnecessary computational overhead. However, once a sharp fluctuation in driving data is detected, indicating that a complex driving environment may have been entered (such as a congested urban area), the system will immediately resume the high-frequency inference mode to ensure the most timely response to any sudden dangerous driving behavior. This adaptive adjustment mechanism enables this method to intelligently allocate computational resources in different scenarios.
[0038] Regarding data sources, this invention utilizes multiple sensors built into the mobile terminal to collect multi-dimensional sensor data. Specifically, through the CoreMotion framework of the iOS system, data from the accelerometer, gyroscope, and magnetometer can be acquired simultaneously. These data reflect the vehicle's translation, rotation, and orientation changes in three-dimensional space, serving as the core basis for identifying behaviors such as rapid acceleration, sudden braking, and sharp turns. Simultaneously, GPS data is acquired through the CoreLocation framework to obtain the vehicle's real-time speed and location information, which is crucial for judging speeding behavior and for contextual analysis based on geographic location information. By comprehensively utilizing these data sources, a comprehensive driving behavior observation system is constructed.
[0039] To ensure the efficiency of data acquisition and model inference, this invention employs an asynchronous acquisition approach. Specifically, the system creates at least two independent threads or operation queues: one data acquisition thread is dedicated to interacting with the CoreMotion and CoreLocation frameworks, continuously acquiring multi-dimensional sensor data and placing the acquired data into a shared data queue; the other model inference thread retrieves data from this data queue for subsequent preprocessing and model inference. Through this producer-consumer model, data acquisition and model inference can be performed in parallel, avoiding data acquisition being blocked due to long model inference times, or the continuity of inference being affected by I / O wait times in data acquisition, thus ensuring a smooth user interface and efficient operation of the entire system.
[0040] In preprocessing the acquired multi-dimensional sensor data, this invention employs a highly efficient and lightweight feature extraction method. This method first uses a sliding window technique to divide the continuous data stream into a series of fixed-length data segments; for example, each 5 seconds of data forms a window, which slides once every 1 second. Then, within each data window, instead of directly inputting all the original data (e.g., 12-dimensional data including acceleration, angular velocity, magnetic field, velocity, heading angle, and timestamps), the model is modified by calculating statistical features or using algorithms such as simplified wavelet transform to extract the key features that most effectively characterize driving behavior within that time period. For example, the maximum value of the acceleration vector magnitude and the standard deviation of each angular velocity axis can be calculated, ultimately reducing the 12-dimensional original data to 4-dimensional feature data. This step significantly reduces the computational complexity of subsequent model inference and is a crucial step in achieving low-latency, low-power recognition.
[0041] Once the CNN-LSTM hybrid model identifies dangerous driving behavior based on the input feature data, the system immediately triggers a preset operation on the mobile terminal to provide timely warnings to the driver. To achieve the desired alert effect, this invention preferably employs a dual feedback mechanism combining voice alerts and interface pop-up alerts. For example, a clear voice prompt, such as "Sudden braking detected, please be careful," is synthesized and broadcast using the iOS AVFoundation framework, while a prominent warning window pops up on the application interface, displaying the type of dangerous behavior and the time of occurrence. This combined audiovisual alert method, compared to a single pop-up or sound, is more likely to attract the driver's attention, thereby effectively intervening in dangerous driving behaviors.
[0042] Considering that ride-hailing vehicles may enter areas with poor network signal coverage, such as tunnels and underground parking garages, this invention also incorporates a robust offline processing and data security mechanism. When the method runs on a mobile terminal, if the mobile terminal is detected to be offline, all identified dangerous driving behaviors and their associated raw sensor data are not discarded. Instead, they are first encrypted (e.g., using the AES algorithm) and then securely cached in a local sandbox directory. The encryption key is stored in a more secure Keychain to prevent easy theft. Once the mobile terminal regains network connectivity, the system automatically detects the change in network status and initiates a background resume download task, uploading the previously encrypted and cached data in fragments and in an orderly manner to the server. This mechanism ensures that data integrity and security are effectively guaranteed even during prolonged offline periods.
[0043] To more clearly illustrate the technical solution of this invention, a specific implementation scenario is described below. Assume a ride-hailing vehicle equipped with the application of this invention is driving on a city road. At this time, a service running in the background of the mobile terminal will asynchronously collect data such as acceleration and speed through its built-in sensors. The collected data stream will undergo a simple normalization preprocessing step to generate feature data usable by the model. In this basic embodiment, the system operates according to a preset default resource configuration (e.g., medium power consumption mode), and the function of dynamically adjusting the resource configuration is in a baseline state.
[0044] Next, the system calls a CNN-LSTM hybrid model pre-installed on the mobile terminal and processed using a general lightweight method. This model receives pre-processed feature data as input and performs inference calculations. If the model's output determines the current driving behavior as "rapid acceleration," the system triggers a pre-defined general prompt on the mobile terminal, such as printing a record in the system log indicating that a dangerous driving behavior has been identified. This basic embodiment demonstrates the core process of the invention from data acquisition, preprocessing, local inference to triggering operations, forming the minimum closed loop for dangerous driving behavior identification. More specific technical details such as knowledge distillation, Metal acceleration, power-based dynamic adjustment, specific dimensionality reduction from 12 to 4 dimensions, and encrypted caching are intentionally omitted in this embodiment to highlight the basic technical solution defined in claim 1.
[0045] In one specific implementation, the construction and optimization process of the CNN-LSTM hybrid model is defined in detail, such as... Figure 3 As shown. First, in the model selection S110 stage, a hybrid model structure was determined to be adopted, combining a CNN module containing 3 convolutional layers and 2 pooling layers with an LSTM module containing 2 hidden layers. The CNN module is responsible for extracting spatial features from multi-sensor data, such as the peak value of acceleration and the rate of change of angular velocity; while the LSTM module is used to capture the sequential dependencies of these features in the temporal dimension, such as identifying a complete emergency braking process.
[0046] Subsequently, the basic model undergoes a triple lightweighting process (S120). The first step is knowledge distillation (S121), specifically using a large CNN-LSTM model with 8 million parameters as the teacher model and a small CNN-LSTM model with 1 million parameters as the student model. During training, a distillation strategy with a temperature coefficient of 3 is employed, and the KL divergence loss function is used to guide the student model to learn the output logic of the teacher model. Through this method, the student model retains its core recognition capabilities while successfully compressing its parameter count to 1 / 8 of the original, laying the foundation for subsequent lightweighting.
[0047] The second step is model quantization (S122). Using the TensorFlow Lite for iOS toolkit, the parameters in the student model, originally 32-bit floating-point numbers, are uniformly quantized to 8-bit integers. This operation not only eliminates redundant parameter precision but also brings significant benefits: the model file size is drastically reduced from approximately 100MB to approximately 8MB, and because integer calculations are more efficient on mobile processors, the model inference speed is also improved by approximately 60%.
[0048] The third step is channel pruning (S123). This step employs an L1 regularization-based pruning algorithm. During training, a penalty term related to the sum of the absolute values of the convolutional layer channel weights is added to the loss function, causing the model to tend to compress unimportant channel weights to near zero. After training, redundant convolutional channels whose sum of absolute weights is below a preset threshold (e.g., 0.01) are removed. Through this fine-tuning, the model size is further compressed to approximately 7MB, while the loss in recognition accuracy is strictly controlled to within 1% because the core channels with high contribution are retained.
[0049] After lightweighting, model adaptation and optimization for the S130 were performed for iOS. Regarding computing power adaptation, a dedicated GPU computing queue was created using Apple's Metal framework, and model inference tasks were allocated to the GPU for execution. By calling highly optimized functions in MetalPerformanceShaders, the parallel computing capabilities of the GPU were fully utilized, significantly reducing the CPU utilization during model runtime from 22% before optimization to approximately 8%, thus preventing application lag.
[0050] Regarding background persistence optimization, the BGTaskSchedulerPermittedIdentifiers permission is declared in the application's Info.plist file, and a high-priority background processing task is registered using the BackgroundTasks framework. When the application enters the background, the system allocates execution time slices to the recognition task of this invention at appropriate times based on this registration information. This design ensures that the model can run stably in the background for more than 4 hours without being unexpectedly reclaimed by the iOS system, significantly improving operational stability.
[0051] Finally, the optimized model was trained and validated. A dataset containing 10,000 real ride-hailing driving samples was used, including 7,000 normal driving samples and 750 samples each of dangerous driving behaviors such as rapid acceleration, sudden braking, sharp turns, and speeding. The Adam optimizer was used with a learning rate of 0.001 for 100 iterations of training. After training, the model achieved a recognition accuracy of 96.2% on an independent test set, with a false positive rate of less than 4.8%, and an average inference latency of 420 milliseconds on a mid-range iPhone. Finally, the trained model was exported as an S140 file in two formats: a full-precision `dangerous_driving_model_fp32.tflite` file and an 8-bit quantized `dangerous_driving_model_int8.tflite` file, and these were packaged into the iOS project's resource directory for dynamic loading based on device performance.
[0052] In another specific implementation, the process of acquiring and preprocessing multi-dimensional sensor data is defined in detail, such as... Figure 4 As shown. This process begins with the asynchronous acquisition of multi-sensor data S210. Specifically, the accelerometer, gyroscope, and magnetometer are initialized using the CoreMotion framework, and their initial acquisition frequencies are set, for example, motionManager.accelerometerUpdateInterval=0.1, i.e., 10Hz. Simultaneously, the GPS module is initialized using the CoreLocation framework, setting locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation to obtain high-precision positioning and velocity data, with an acquisition frequency of 1Hz.
[0053] To achieve asynchronous data acquisition, the system creates at least two independent threads (e.g., managed by creating two separate OperationQueue instances). One data acquisition thread executes all data acquisition-related tasks, with its queue priority set to normal; the other model inference thread executes model inference tasks, with its priority set to high. This separation ensures that time-consuming model inference does not block real-time data acquisition, and vice versa, thus guaranteeing system responsiveness and data continuity.
[0054] During this process, the system executes a strategy of dynamically adjusting the sampling frequency S230. It obtains the current device's battery percentage in real time by reading the `UIDevice.current.batteryLevel` property. When the battery level is detected to be below or equal to 20%, the system automatically adjusts the sampling interval of the accelerometer and gyroscope to 0.2 seconds, i.e., the frequency drops to 5Hz. This measure effectively reduces the power consumption of sensor hardware and data processing while maintaining basic recognition capabilities, thus extending the device's usage time in low-battery conditions.
[0055] The collected raw data first enters the data integrity verification step S310. This embodiment uses the 3σ criterion to remove outlier data points. Within a sliding window of 100 data points (corresponding to 10 seconds of data), the mean μ and standard deviation σ of the data within the window are calculated. Any data point falling outside the interval `[μ-3σ, μ+3σ]` is considered an outlier and is removed. For missing data points caused by various reasons, linear interpolation is used to fill in the missing data. Through these verification and repair methods, the integrity of the data input to subsequent processing steps is ensured to be no less than 99%.
[0056] The validated data is then standardized using the S320 standard. Because different sensors have significantly different data units and numerical ranges (e.g., acceleration is in g, velocity is in m / s), directly using these units would negatively impact the model's training performance. Therefore, a min-max standardization algorithm is employed, applying the formula... Mapped to a uniform interval [0,1]. Where x is the original data. It is standardized data. and These are the minimum and maximum values of this feature in the sample dataset.
[0057] The standardized data then enters the lightweight feature extraction S330 stage, a crucial step in achieving data dimensionality reduction. This embodiment employs a simplified wavelet transform algorithm to extract four key features for identifying dangerous driving behaviors from the 12-dimensional raw data, which includes acceleration (x / y / z), angular velocity (x / y / z), magnetic field (x / y / z), velocity, heading angle, and timestamp. These four features are: peak acceleration (the maximum value of the acceleration vector magnitude within a 1-second time window); rate of change of angular velocity (the standard deviation of the gyroscope readings for each axis within a 1-second time window); velocity fluctuation (the standard deviation of the GPS velocity within a 1-second time window); and rate of change of heading angle (the standard deviation of the heading angle calculated by fusing magnetometer and accelerometer readings within a 1-second time window). Through this step, the data dimensionality is successfully reduced from 12 dimensions to 4 dimensions, significantly reducing the computational burden of subsequent model inference.
[0058] Finally, the preprocessed feature data is encrypted and cached (S340) before being fed into the model for inference. The AES-128 symmetric encryption algorithm is used, and the more secure CBC block mode is selected for encryption. The encrypted binary data is stored in the application's sandbox directory `Library / Caches`. The encryption key is stored in the Keychain through iOS's security mechanisms, ensuring that even if the device is physically compromised, the application data cannot be easily read, thus meeting the stringent data security and privacy compliance requirements of the ride-hailing industry.
[0059] In another specific implementation, the local model inference, recognition, and feedback process is defined in detail, such as... Figure 5As shown. When the application starts or a background task is activated, the first step is to load the local S410 model. Using the API provided by TensorFlowLiteforiOS, the `.tflite` model file is loaded according to a preset path. For example, `letinterpreter=tryInterpreter(modelPath:modelURL.path)`. After successful loading, `interpreter.allocateTensors()` is called to allocate memory for the model's input and output tensors.
[0060] Next, the system executes a strategy to dynamically adjust the inference accuracy S420. By reading device model information (e.g., determining if it's an iPhone 12 or later), it decides which model version to load. For devices with high-end hardware, the system loads the `dangerous_driving_model_fp32.tflite` full-precision model to achieve a maximum recognition accuracy of over 96%. For lower-performance devices, the system loads the `dangerous_driving_model_int8.tflite` quantized model. While this results in a slight loss of accuracy, it ensures that the inference latency remains stable within 500 milliseconds, guaranteeing real-time recognition.
[0061] During the model inference phase S430, the system executes a strategy to dynamically adjust the inference frequency S425. Normally, the inference task execution interval is 500 milliseconds. However, if the system detects that the model's output is "normal driving" for 10 consecutive inference windows (i.e., 5 seconds), it enters a low-power cruise mode, extending the inference interval to 2000 milliseconds. This dynamic computing power adjustment mechanism significantly reduces system energy consumption under smooth driving conditions. Once the underlying sensor raw data (such as instantaneous acceleration values) exceeds a preset safety threshold, indicating a potential emergency, the system immediately exits cruise mode and resumes the 500-millisecond high-frequency inference, helping to promptly detect any potentially dangerous behaviors.
[0062] After inputting the preprocessed 4D feature data into the loaded local model, interpreter.invoke() is called to perform inference. After inference, the recognition result (such as categories like "rapid acceleration" and "sudden braking") and the corresponding confidence score are parsed from the output tensor. In this embodiment, a confidence threshold of 0.8 is set; only when the confidence score of the model output is higher than this threshold is it considered a valid recognition.
[0063] When the identified behavior is deemed dangerous, the system immediately triggers a voice / interface alert (S520). Specifically, using the AVSpeechSynthesizer class of the AVFoundation framework, a preset voice message is synthesized and played, such as: "Please note that you are currently exhibiting rapid acceleration; please drive safely." Simultaneously, a warning box pops up on the application interface (if in the foreground), displaying the type and details of the dangerous behavior. This dual feedback mechanism effectively conveys warning information to the driver.
[0064] At the same time, the raw and feature data corresponding to this dangerous driving behavior will be tagged and the abnormal data S530 operation will be performed. This data is also encrypted with AES-128 and stored in a local sandbox directory.
[0065] Finally, the system monitors network connectivity in real time using the Reachability framework. Once the network is detected as restored from a disconnected state, the system initiates the breakpoint resume S540 task. This task utilizes the `URLSession` background transport service to upload the previously cached abnormal data file to the designated platform server via an HTTP POST request. Using the background transport service ensures that even if the application is switched to the background or terminated by the system, the data upload task can continue until completion, guaranteeing reliable data reporting.
[0066] To more comprehensively demonstrate the synergistic effect of the technical solution of the present invention in practical applications, a complete embodiment integrating the above-mentioned technical features is described below. The scenario is set as follows: a ride-hailing driver is using a mid-range iPhone 12 (equipped with an A12 chip) while driving on urban roads, during which the phone's battery level drops from 50% to 15%.
[0067] When a driver launches the ride-hailing app, the method of this invention starts in the background. First, the system loads a model file of approximately 7MB, `dangerous_driving_model_int8.tflite`. Based on the device model (iPhone 12, with an A12 chip or higher), the system automatically selects to load `dangerous_driving_model_fp32.tflite` to enable high-precision inference mode. Simultaneously, background tasks are successfully registered using the BackgroundTasks framework to ensure continuous monitoring capabilities.
[0068] As the vehicle navigates complex urban roads, the data acquisition module 201 operates asynchronously, collecting data from sensors such as the accelerometer and gyroscope at a frequency of 50Hz, and GPS speed data at a frequency of 1Hz. The data preprocessing module 202 performs sliding window segmentation and feature extraction on this 12-dimensional raw data, generating 4-dimensional feature data. Subsequently, the model inference module 203 calls the local CNN-LSTM hybrid model for inference at 500-millisecond intervals. Thanks to the GPU acceleration of the Metal framework, the latency of the entire inference process remains stable at around 450 milliseconds, with extremely low CPU utilization, ensuring smooth operation of both the application interface and the mobile phone. During this period, the model's output consistently shows "normal driving."
[0069] Subsequently, the vehicle entered a section of elevated road with good road conditions. The dynamic strategy control module 206, by analyzing recent driving data (such as stable speed and minimal changes in angular velocity), determined that the vehicle had entered a stable driving state. Therefore, the module automatically reduced the model inference frequency from once every 500 milliseconds to once every 2 seconds. This adjustment significantly reduced the system's computational load and energy consumption without affecting its ability to respond to unexpected events.
[0070] During driving, the vehicle in front suddenly decelerated, and the driver braked abruptly. The acceleration data collected by the sensors changed drastically. The high-frequency inference mode was instantly activated, and the model recognized the behavior within 500 milliseconds, giving a high confidence score of 0.92. The result feedback module 204 was immediately triggered, and the mobile terminal issued a voice reminder through the speaker, "Sudden braking detected, please be careful," while a warning popped up on the interface. The data management module 205 then encrypted the original sensor data segment that triggered this alarm using AES and cached it locally.
[0071] As the journey continued, the mobile device's battery level dropped to 19%. The dynamic strategy control module 206 detected that the battery level was below the 20% threshold and, to prioritize ensuring the device's battery life, automatically reduced the sensor's sampling frequency from 50Hz to 10Hz. Although the data density was reduced, the optimized model and feature extraction algorithm still ensured effective identification of major dangerous driving behaviors.
[0072] Afterwards, the driver switched the ride-hailing app to the background to check navigation information. Thanks to the keep-alive mechanism of the BackgroundTasks framework, the identification method of this invention continued to run stably in the background. When the vehicle entered an underground tunnel, the network signal was completely interrupted. During this period, the driver made a sharp turn, and this action was still identified and alerted by the system in real time. The relevant data was also encrypted and cached locally, completely unaffected by the network status.
[0073] Once the vehicle exited the tunnel, the network signal was restored. The data management module 205 detected network connectivity and immediately initiated a background resume upload task. Through URLSession, it safely and reliably uploaded the two dangerous driving behavior data points (sudden braking and sharp turning) that had been cached offline to the platform server, reducing the probability of data loss.
[0074] By referencing performance test data from different devices and system versions, the effectiveness of this complete embodiment can be summarized. On iPhone SE 2020 (iOS 12.5), the recognition accuracy was 95.1%, the inference latency was 485ms, and the power consumption increased by 28% after one hour. On iPhone 12 (iOS 15.1), the recognition accuracy reached 96.2%, the inference latency was 420ms, and the power consumption increased by 22% after one hour. On iPhone 15 (iOS 17.0), the recognition accuracy reached 96.8%, the inference latency was only 380ms, and the power consumption increased by only 18% after one hour. The operational stability on all test devices exceeded 99%. These data fully demonstrate that the complete solution proposed in this invention can achieve high accuracy (>95%), low latency (<500ms), low power consumption, and high stability (>99%) dangerous driving behavior recognition on various iOS devices, completely eliminating dependence on real-time networks and effectively ensuring data security and privacy.
Claims
1. A method for identifying dangerous driving behavior of a mobile terminal of a network car, the method comprising: include: Perform data acquisition operations by asynchronously collecting multi-dimensional sensor data during the driving process through multiple sensors on the mobile terminal; The multi-dimensional sensing data is preprocessed to obtain feature data for model inference. For the lightweight CNN-LSTM hybrid model deployed locally on the mobile terminal, the resource configuration of the data acquisition operation and the model inference is dynamically adjusted according to the real-time status and driving status of the mobile terminal. The CNN-LSTM hybrid model is used to perform model inference on the feature data to identify dangerous driving behaviors; Based on the identified dangerous driving behavior, a preset operation is triggered on the mobile terminal.
2. The method of claim 1, wherein, The lightweighting process includes at least one of the following: compressing model parameters through knowledge distillation; compressing model volume through model quantization; and removing redundant convolutional channels through channel pruning.
3. The method of claim 1, wherein, The method further includes: The optimization is based on the characteristics of the mobile terminal's operating system. The optimization includes: using a graphics processing interface framework to allocate model inference to a graphics processing unit for execution to accelerate it; and requesting background running permissions through a background task scheduling framework to ensure that the method can run continuously in the background.
4. The method of claim 1, wherein, The dynamic adjustment of the resource configuration for the data acquisition operation and the model inference includes at least one of the following: adjusting the acquisition frequency of the multi-dimensional sensor data according to the battery status of the mobile terminal; adjusting the inference accuracy of the CNN-LSTM hybrid model according to the hardware configuration of the mobile terminal; and adjusting the inference frequency of the CNN-LSTM hybrid model according to the driving state.
5. The method of claim 4, wherein, If the dynamic adjustment of the resource configuration for the data acquisition operation and the model inference includes adjustment based on the battery status, then the acquisition frequency is reduced when the mobile terminal's battery level is below a preset battery threshold; if the dynamic adjustment of the resource configuration for the data acquisition operation and the model inference includes adjustment based on the hardware configuration, then a high-precision model is used when the mobile terminal's processor computing power is above a preset performance threshold; if the dynamic adjustment of the resource configuration for the data acquisition operation and the model inference includes adjustment based on the driving state, then the inference frequency is reduced during smooth driving and increased during complex driving.
6. The method as described in claim 1, characterized in that, The multi-dimensional sensing data includes at least one of accelerometer data, gyroscope data, and magnetometer data acquired through the motion sensor data acquisition interface, as well as velocity data acquired through the position positioning interface.
7. The method as described in claim 1, characterized in that, The asynchronous acquisition of multi-dimensional sensor data during the driving process includes: acquiring the multi-dimensional sensor data in the data acquisition thread and storing it in the data queue, and retrieving the data from the data queue for inference in the model inference thread.
8. The method as described in claim 1, characterized in that, The preprocessing of the multi-dimensional sensing data includes: segmenting the multi-dimensional sensing data using a sliding window and extracting statistical features to reduce the dimensionality of the high-dimensional original data to low-dimensional feature data.
9. The method as described in claim 1, characterized in that, The preset operations include triggering voice alarms and interface pop-up alarms.
10. The method as described in claim 1, characterized in that, The method further includes: encrypting and locally caching data related to the dangerous driving behavior when the mobile terminal is offline; and uploading the encrypted and cached data to the server after the mobile terminal restores its network connection.
