Motion state recognition method and device and electronic equipment
The differential image is calculated by frame difference method and input into the object detection and tracking model, which solves the problems of large amount of computing and poor high-speed item recognition in intelligent sales cabinets, and achieves more accurate and efficient motion trajectory recognition, reducing the error and noise of stationary items recognition interference.
Patent Information
- Application Number
- CN202411138419.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-29
AI Technical Summary
The existing smart vending cabinets have too much computing volume in product motion trajectory recognition and have poor high-speed mobile items recognition effect, the frame difference calculation outline is unclear and is susceptible to noise interference.
The frame difference method is used to calculate the differential image and input it into the object detection and tracking model to avoid identification of static goods, reduce the amount of calculation, and use differential images to record the motion trend and solve the problem of shading.
It improves the accuracy and efficiency of product motion trajectory recognition, reduces the identification error of stationary goods, enhances the recognition ability of high-speed mobile items, and reduces noise interference.
Smart Images

Figure CN119049124A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of object detection, and in particular to a motion state recognition method, device and electronic equipment. Background Art
[0002] Object detection and tracking technology is dedicated to detecting specific objects in images and tracking their motion trajectories through image processing and computer vision technology. This technology first uses the target detection technology in deep learning to achieve efficient and accurate detection of targets in images. Once the target is detected, the target tracking technology is responsible for tracking the position of the target in consecutive frames, involving aspects such as motion prediction and appearance modeling. In complex scenes, multi-target tracking technology can achieve accurate tracking of multiple targets through effective target relationship management. The development of object detection and tracking technology has promoted the automation and intelligence of dynamic visual smart vending cabinets, and has become an indispensable key technology in this field.
[0003] The existing method of identifying the motion state of an object is to combine object detection with tracking algorithms, which improves the accuracy of detection and the stability of tracking in complex environments, laying the foundation for more accurate target recognition and persistent target tracking. However, object detection will indiscriminately identify moving objects and stationary objects, which requires a large amount of calculation and has poor recognition effect for fast-moving objects. In addition, there are also methods that use frame differences to calculate the pixels of the moving part of the object to achieve motion trajectory recognition, but its disadvantages are unclear contours, many noise points, and easy interference. Summary of the invention
[0004] The main technical problem solved by the embodiments of the present invention is to provide a motion state recognition method, device and electronic equipment, which can solve the problems of excessive computational complexity in commodity motion trajectory recognition and poor recognition effect of high-speed moving objects in existing smart vending cabinets.
[0005] In order to solve the above technical problems, a technical solution adopted in an embodiment of the present invention is: providing a motion state recognition method, which is applied to a smart vending machine equipped with a camera component, comprising: extracting a first input image and a second input image according to a recorded video of the camera component, wherein the second input image is the next frame image of the first input image; performing a pixel subtraction operation on the second input image and the first input image to obtain differential image data; inputting the differential image data into a target detection and tracking model to obtain a motion trajectory recognition result of the corresponding commodity; and judging the motion state of the corresponding commodity according to the motion trajectory recognition result.
[0006] In some embodiments, after determining the motion state of the corresponding commodity based on the motion trajectory recognition result, the method further includes: labeling the first input image or the second input image based on the pixel area in the differential image data; inputting the labeled first input image or the second input image into the commodity recognition model to obtain the commodity category recognition result.
[0007] In some embodiments, before acquiring the first input image and the second input image according to the recorded video of the camera component, the method further includes: using a product image dataset to train a product category recognition model; and using a differential image dataset to train the target detection and tracking model.
[0008] In some embodiments, extracting the first input image and the second input image based on the recorded video of the camera component includes: extracting a first frame image from the recorded video as the first input image; extracting a next frame image after the first frame video from the recorded video as the second input image.
[0009] In some embodiments, performing a pixel subtraction operation on the second input image and the first input image to obtain differential image data includes: extracting pixel values for each pixel position in the first input image and the second input image, respectively; and subtracting the color value of each pixel in the second input image from the color value of the pixel at the corresponding position in the first input image to obtain differential image data.
[0010] In some embodiments, judging the motion state of the corresponding commodity based on the motion trajectory recognition result includes: obtaining key features of the motion trajectory recognition result; and comparing the key features with preset thresholds corresponding to each motion state category according to predefined motion state categories to obtain the motion state of the corresponding commodity.
[0011] In some embodiments, the use of the differential image dataset to train the target detection and tracking model includes: obtaining a differential image dataset; labeling the products in the differential image dataset; selecting a deep learning model; and training the deep learning model using the labeled differential image dataset to obtain the target detection and tracking model.
[0012] To solve the above technical problems, another technical solution adopted by the embodiment of the present invention is: to provide a motion state recognition device, including: a first model module, used to use a commodity image data set to train and obtain a commodity category recognition model; a second model module, used to use a differential image data set to train and obtain the target detection and tracking model; an image acquisition module, used to extract a first input image and a second input image according to the recorded video of the camera component, the second input image is the next frame image of the first input image; an image processing module, used to perform pixel subtraction operation on the second input image and the first input image to obtain differential image data; a commodity recognition module, used to input the differential image data into the target detection and tracking model to obtain a motion trajectory recognition result of the corresponding commodity; a state judgment module, used to judge the motion state of the corresponding commodity according to the motion trajectory recognition result; an image annotation module, used to annotate the first input image or the second input image according to the pixel area in the differential image data; a category recognition module, used to input the annotated first input image or the second input image into the commodity recognition model to obtain a commodity category recognition result.
[0013] To solve the above technical problems, another technical solution adopted in the embodiment of the present invention is: to provide an electronic device, comprising: at least one processor; at least one network interface, which is communicatively connected to the corresponding processor; and a memory which is communicatively connected to the at least one processor; wherein the network interface is used to establish a communication connection between the processor and other external devices; the memory stores instructions which can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a motion state recognition method as described above.
[0014] To solve the above technical problems, another technical solution adopted in the embodiment of the present invention is: providing a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, so that the one or more processors can execute a motion state recognition method as described above.
[0015] The beneficial effects of the embodiments of the present invention are as follows: different from the prior art, the embodiments of the present invention use the image input obtained after calculation by the frame difference method as the model input to obtain the motion trajectory recognition result of the corresponding product, thereby reducing the amount of model calculation while avoiding the recognition of static products; and the image obtained by the frame difference method itself records the movement trend of the product, so there is no need to clearly identify the product, which can solve the problem of object tracking in the case of ghosting. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a structural diagram of the intelligent vending cabinet;
[0017] Figure 2 It is a flow chart of a motion state recognition method provided by an embodiment of the present invention;
[0018] Figure 3 yes Figure 2 A schematic flow chart of step S200 in the motion state recognition method shown;
[0019] Figure 4 yes Figure 2 A schematic flow chart of step S300 in the motion state identification method shown;
[0020] Figure 5 yes Figure 2 A schematic flow chart of step S400 in the motion state identification method shown;
[0021] Figure 6 yes Figure 2 A schematic flow chart of step S600 in the motion state recognition method shown;
[0022] Figure 7 It is a structural schematic diagram of a motion state recognition device provided by an embodiment of the present invention;
[0023] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to facilitate the understanding of the present application, the present application is described in more detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that when an element is described as "fixed to" another element, it can be directly on another element or there can be one or more centered elements therebetween. When an element is described as "connected" to another element, it can be directly connected to another element or there can be one or more centered elements therebetween. The orientation or positional relationship indicated by the terms "upper", "lower", "inner", "outer", "bottom" and the like used in this specification is based on the orientation or positional relationship shown in the accompanying drawings, only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third" and the like are used only for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0025] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in this specification and in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0026] In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0027] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0028] For example, Figure 1 It is a structural diagram of an existing smart vending cabinet, which includes a camera component 210 and a processor (set in the smart vending cabinet, not shown in the figure). The number of camera components set depends on the specific structure of the smart vending cabinet, and it is only necessary to ensure that all the goods placed in the smart vending cabinet are within the camera range of the camera component.
[0029] The processor will initialize the camera component at startup, including setting the camera's resolution, frame rate, focus and other parameters to ensure that the camera component can clearly capture image information; and configure the camera component's working mode and image transmission format to ensure that they can capture images as expected. After the parameters are set and configured, the image information inside the smart vending machine is captured in real time and transmitted to the processor. The processor will process the received image information, such as performing image compression, feature extraction and other operations, to facilitate subsequent analysis and processing.
[0030] The processor will analyze the image information transmitted by the camera component, such as target detection and product recognition. This step usually requires the use of artificial intelligence algorithms, such as deep learning models, to improve the accuracy and efficiency of recognition. The processor will determine the type and quantity of goods taken during the transaction based on the results of the image analysis, and further generate bills based on the type and quantity of the goods. The processor will also record and store the image information captured by the camera component and related event information for subsequent query and analysis. These data are usually stored in the built-in storage device of the smart vending machine or on a remote server. The processor can also recognize and verify the user's identity through the user's image information captured by the camera component, such as unlocking with face recognition. At the same time, the controller can also provide corresponding interactive feedback based on the user's operating behavior, such as displaying operation guides, prompt information, etc.
[0031] Of course, other components are also included in the smart vending machine, such as a display screen for displaying operating guides, user interaction interfaces, advertising information, etc.; input devices for users to input information, such as passwords, verification codes or identity information, such as touch screens, keyboards or scanners; several types of sensors, such as door status sensors for detecting whether the cabinet door is closed, vibration sensors for detecting whether there is any vandalism, and temperature and humidity sensors for monitoring the storage environment; communication modules for communication between smart vending machines and external systems (such as servers, user mobile phones, etc.), including Wi-Fi, Bluetooth, 4G / 5G network modules, etc.; a power management system to ensure that the smart vending machine can still operate normally in the event of power fluctuations or power outages, including main power access, backup batteries (UPS uninterruptible power supply), power controllers, etc.; storage devices for storing operation logs, user data, image records, etc. of the smart vending machine, which can be built-in hard disks or solid-state drives, or storage space connected to remote servers.
[0032] In existing smart vending machines, such as Figure 1 In the smart vending machine shown in the figure, the existing method for identifying the motion state of goods is to combine object detection and tracking algorithms, which improves the accuracy of detection and the stability of tracking in complex environments, laying the foundation for more accurate target recognition and persistent target tracking. However, object detection will indiscriminately identify moving objects and stationary objects, which requires a large amount of calculation and has poor recognition effect for fast-moving objects. In addition, there is also the use of frame difference to calculate the pixels of the moving part of the object to realize motion trajectory recognition, but its disadvantages are unclear contours, many noise points, and easy interference.
[0033] To solve the above problems, the present invention provides a motion state recognition method, the flow chart of which is as follows: Figure 2 As shown, the specific steps include:
[0034] Step S100: using a commodity image dataset to train a commodity category recognition model.
[0035] Specifically, images of various product categories are collected in advance to form a product image dataset. The number of images in each category needs to be relatively balanced to avoid category skewness in the model during training. The product image dataset should be divided into a training set, a validation set, and a test set. The training set is used to train the product category recognition model, the validation set is used to adjust the model parameters and select the best model, and the test set is used to evaluate the final performance of the product category recognition model.
[0036] Before training the model, the image data needs to be preprocessed, including: image resizing: resizing all images to the uniform size required by the model; normalization: normalizing the pixel values of the image to between 0 and 1, which helps the model converge faster; data enhancement: in order to improve the generalization ability of the model, the training set can be enhanced by data enhancement, such as rotation, flipping, scaling, etc.
[0037] Choose a suitable deep learning model architecture based on your needs and resources. Common architectures include VGG, ResNet, Inception, etc. These architectures have been pre-trained on large datasets such as ImageNet and can be effectively transferred to product category recognition tasks.
[0038] It should be noted that since training a deep learning model from scratch requires a lot of data and computing resources, transfer learning can be used. Transfer learning uses a model pre-trained on a large dataset to adapt it to a new task through fine-tuning.
[0039] Specifically, it includes: Loading a pre-trained model: Select a model pre-trained on a dataset such as ImageNet; Replace the top layer: Replace the top layer of the model (usually a fully connected layer) with a new layer suitable for the number of product categories; Freeze some layers: In the early stage of fine-tuning, you can freeze most of the layers of the model and only train the top layers. This can converge faster and reduce the risk of overfitting; Gradually unfreeze: During the training process, you can gradually unfreeze more layers for fine-tuning to obtain better performance.
[0040] Use the training set to train the model. During the training process, choose a suitable loss function (such as cross entropy loss) and optimizer (such as Adam or SGD). At the same time, set a suitable learning rate and batch size. Evaluate the performance of the model on the validation set and adjust the model parameters based on the evaluation results. This includes learning rate, batch size, number of training rounds, etc. Find the best model parameters through multiple iterations and adjustments. Use the test set to test the final model and evaluate its performance. Common evaluation indicators include accuracy, precision, recall, and F1 score.
[0041] Deploy the trained model to actual applications, such as as a backend service for an online product category recognition system. In actual applications, factors such as the real-time performance, stability, and scalability of the model also need to be considered.
[0042] Step S200: Using the differential image dataset, training a target detection and tracking model.
[0043] Specifically, differential images of various commodity categories are collected in advance to form a differential image dataset, and the differential image highlights the moving target. The differential image can be obtained by subtracting two or more consecutive frames of original images, thereby highlighting the dynamically changing parts.
[0044] Before model training, the difference image needs to be preprocessed. The data preprocessing of the difference image may include: Binarization: Set a threshold to convert the difference image into a binary image so that the moving target can be identified more clearly. Denoising: Remove noise caused by light changes, camera shaking, etc. Image resizing: If necessary, resize all images to a uniform size for input into the model.
[0045] For target detection and tracking, you can choose target detection models in deep learning, such as YOLO (You Only Look Once), SSD (Single Shot MultiBox Detector) or Faster R-CNN (Faster Region-based Convolutional Neural Network), etc. These models can directly predict the location and category of the target in the image.
[0046] Use the prepared differential image dataset to train the selected object detection model. During the training process, it is necessary to define a suitable loss function, such as a combination of cross entropy loss and regression loss, to optimize the classification and positioning capabilities of the model. At the same time, select a suitable optimizer and learning rate to adjust the model parameters.
[0047] Evaluate the performance of the model on the validation set and make necessary adjustments based on the evaluation results. This may include adjusting model parameters, optimizer settings, learning rate, etc. Find the best model configuration through multiple iterations and adjustments. Test the final model using the test set to evaluate its performance in real-world applications. Evaluation metrics may include accuracy, recall, F1 score, mAP (mean Average Precision), etc.
[0048] Deploy the trained model to actual application scenarios, such as target detection and tracking in video surveillance systems. In actual applications, the model needs to be able to process video streams in real time and accurately detect and track targets. For target tracking tasks, it may be necessary to apply some algorithms in the post-processing stage to optimize the tracking results, such as using a Kalman filter to smooth the tracking trajectory, or using a multi-target tracking algorithm to handle the interaction of multiple targets.
[0049] Step S300: extracting a first input image and a second input image according to the recorded video of the camera assembly, wherein the second input image is a next frame image of the first input image.
[0050] Specifically, we obtain the recorded video file from the camera device and determine the time point in the video from which to extract the image. This can be any position in the video, but we usually choose a representative time point, such as the beginning or end of the video, or the moment when a specific event occurs.
[0051] At a selected point in time, extract the first frame from the video as the first input image. This usually involves decoding the video stream and extracting the image data at a specific point in time. Since the second input image is defined as the next frame after the first input image, it is necessary to determine what exactly "next frame" means. In most cases, it refers to the frame immediately after the first input image on the video timeline. After extracting the first input image, continue along the video timeline to the next frame and extract it as the second input image. This process is similar to extracting the first input image, but at a different time point.
[0052] The extracted first input image and the second input image are saved in an appropriate file format (such as JPEG, PNG, etc.) for subsequent processing and analysis. If necessary, further image processing operations can be performed on the two images, such as resizing, cropping, color correction, etc.
[0053] Finally, the two extracted images are verified to ensure that they are indeed two consecutive frames and that the quality is as expected. This can be done by comparing the similarity of the two images, checking their timestamps, etc.
[0054] Step S400: performing pixel subtraction operation on the second input image and the first input image to obtain differential image data.
[0055] Before performing pixel subtraction, ensure that the first input image and the second input image have the same attributes such as size, resolution, and color space. If there are differences, the images need to be adjusted accordingly, such as by scaling, cropping, or color space conversion, to align them.
[0056] For each pixel in the first input image and the second input image, perform pixel-by-pixel subtraction. The specific steps are as follows: Pixel traversal: traverse each pixel of the image through a double loop, usually starting from the upper left corner, row by row, until the lower right corner; Color channel processing: For color images, each pixel is usually composed of multiple color channels (such as RGB three channels). Subtraction operations need to be performed on each channel separately; Subtraction operation: subtract the value of the corresponding pixel of the first input image from the current pixel value of the second input image. This operation is usually performed independently for each color channel; Result assignment: assign the result of the subtraction operation to the pixel at the same position in the differential image.
[0057] Through pixel-by-pixel subtraction, a new image, the difference image, is generated. In the difference image, the value of each pixel represents the difference between the first input image and the second input image at the corresponding position.
[0058] The generated difference image may contain negative values or pixel values that exceed the normal display range. Therefore, post-processing may be required, such as: absolute value processing: Since the difference may be positive or negative, the absolute value of the difference result is usually taken to more intuitively display the amount of change; normalization or scaling: In order to facilitate display and observation, the difference image may need to be normalized or scaled to adapt its pixel value range to the standard image display range (such as 0-255 for 8-bit grayscale images); binary processing: set a threshold to convert the difference image into a binary image to more clearly display the changed area.
[0059] Step S500: inputting the differential image data into the target detection and tracking model to obtain the motion trajectory recognition result of the corresponding commodity.
[0060] The difference image data is passed as input to the selected object detection and tracking model. Since the difference image has highlighted the dynamically changing parts, the model can more easily identify and locate moving products.
[0061] The model first detects the target product in the differential image. Once the target is detected, the model will start tracking the movement of the target. Usually the following steps are involved: Feature extraction: The model extracts the features of the target from the differential image. These features may include shape, texture, color, etc.; Target matching: In consecutive differential image frames, the model will try to match the previously detected target to determine whether its position has changed; Track update: With the arrival of new frames, the model will update the position of the target and record its movement trajectory.
[0062] By continuously detecting and tracking the position of the target product in the differential image sequence, the model can generate the product's motion trajectory. The motion trajectory can be a series of coordinate points that represent the position of the product at different points in time. For easy observation and analysis, the identified motion trajectory can be visualized, such as superimposing trajectory lines or points on the original video. In addition, post-processing can be performed, such as smoothing the trajectory and removing noise, to improve the accuracy of trajectory recognition.
[0063] Step S600: judging the motion state of the corresponding commodity according to the motion trajectory recognition result.
[0064] By observing and analyzing the movement trajectory, the movement pattern of the product can be obtained. For example, the linearity, curve shape, speed change, etc. of the trajectory can provide clues about the movement status of the product.
[0065] Based on the trajectory data, some key motion parameters can be calculated, such as speed, acceleration, direction of movement, etc. These parameters help to more accurately describe the motion state of the product. Speed calculation: By measuring the distance the product moves between consecutive time points and dividing it by the time interval, the average speed or instantaneous speed can be calculated; Acceleration calculation: By observing the change in speed, the acceleration of the product can be calculated to understand whether the product is accelerating, decelerating or moving at a constant speed; Motion direction: By analyzing the coordinate changes of the trajectory points, the direction of movement of the product can be determined.
[0066] Based on the calculated motion parameters, the motion state of the product can be determined. The following are some possible determinations:
[0067] Stationary: If the position of the product does not change significantly for a long time, or the speed and acceleration are close to zero, it can be determined that the product is in a stationary state; uniform motion: If the speed of the product remains relatively stable and the acceleration is close to zero, it can be determined that the product is in uniform motion; accelerated motion: If the speed of the product gradually increases and the acceleration is positive, it can be determined that the product is in accelerated motion; decelerated motion: If the speed of the product gradually decreases and the acceleration is negative, it can be determined that the product is in decelerated motion; curved motion: If the trajectory of the product is in a curved shape, and the speed and direction are constantly changing, it can be determined that the product is in curved motion.
[0068] In addition to the above-mentioned regular motion states, the trajectory data can also be analyzed to identify abnormal motions, such as sudden stops, sharp turns, rapid acceleration or deceleration, etc. These abnormal motions may indicate that something special has occurred, such as the product being taken away, dropped, or disturbed by external forces.
[0069] Step S700: labeling the first input image or the second input image according to the pixel area in the differential image data.
[0070] Based on the analysis of the difference image, the area that needs to be annotated on the first input image or the second input image is determined. This is usually the part of the difference image where the pixel value changes significantly, which may represent moving goods, people or other dynamic elements.
[0071] Choose the appropriate annotation method according to specific needs and application scenarios. Annotation can include but is not limited to the following forms: Rectangular box annotation: draw a rectangular box around the target area to highlight moving or changing objects; Polygonal annotation: if the shape of the target area is irregular, you can use polygons to more accurately annotate its boundaries; Key point annotation: place key points at specific locations of the target area (such as corner points, center points, etc.) for subsequent analysis and processing; Text annotation: add text descriptions to the image to explain or describe the content or characteristics of the target area.
[0072] Step S800: inputting the annotated first input image or the second input image into a commodity recognition model to obtain a commodity category recognition result.
[0073] The labeled first input image or the second input image is passed as input to the selected product recognition model. Since the image has been labeled, the model can more easily locate and identify the products in the image.
[0074] The model analyzes the input annotated image and tries to identify the products in it. It usually involves the following steps: Feature extraction: The model extracts the features of the product from the annotated area, such as shape, texture, color, etc. Classification decision: Based on the extracted features, the model uses the classification rules it has learned to determine the category of the product; Output category: The model will eventually output one or more possible product categories, usually accompanied by a confidence score, indicating the certainty of the model's judgment on the category.
[0075] The product category recognition result output by the model can be a specific product name, a product category label (such as "beverages", "snacks", etc.), or a more detailed subcategory. This result is usually accompanied by a confidence score to indicate the model's confidence level in the recognition result.
[0076] After obtaining the product category recognition results, some post-processing steps may be required to improve the accuracy and reliability of the results. For example: Threshold screening: set a threshold based on the confidence score and only accept recognition results above the threshold; Result fusion: if multiple images or multiple annotated areas of the same image are recognized at the same time, multiple recognition results can be fused through certain strategies (such as voting, weighted averaging, etc.).
[0077] In some embodiments of the present application, step S200 specifically includes the following steps, and its flowchart is as follows: Figure 3 As shown:
[0078] Step S210: Acquire a differential image data set.
[0079] Specifically, a series of image sequences or videos containing dynamic products are collected in advance. For each image sequence or video, a differential image is generated by calculating the difference between adjacent frames. This can be achieved by pixel-by-pixel subtraction or other differential algorithms. The generated differential images are organized into a dataset, ensuring that the dataset contains a variety of products, different motion patterns, and background changes to improve the generalization ability of the model.
[0080] Step S220: labeling the commodities in the differential image dataset.
[0081] Establish clear annotation specifications, such as using a rectangular box to mark the boundaries of the product. Manually annotate the products in the differential image using annotation tools (such as LabelImg, VIA, etc.), or develop an automatic annotation algorithm to assist or fully automate this process. Perform quality checks on the annotated data to ensure the accuracy of the annotations.
[0082] Step S230: Select a deep learning model.
[0083] Study existing object detection and tracking models, such as YOLO, SSD, Faster R-CNN, etc., to understand their performance, speed, and applicable scenarios. Select a suitable deep learning model as the basis for training based on specific requirements (such as real-time performance, accuracy, etc.). Adjust the structure or optimize the parameters of the selected model as needed to adapt to the characteristics of the differential image dataset.
[0084] Step S240: Use the labeled differential image dataset to train the deep learning model to obtain a target detection and tracking model.
[0085] Specifically, perform appropriate preprocessing on the labeled differential image dataset, such as normalization, data augmentation, etc., to improve the generalization ability and training stability of the model. Divide the dataset into training set, validation set, and test set to evaluate the performance of the model and prevent overfitting. Set appropriate training parameters, such as learning rate, batch size, number of iterations, etc., according to the requirements of the model and hardware resources. Use the training set to train the deep learning model, and adjust the model parameters through the back propagation algorithm to minimize the loss function. Evaluate the performance of the model on the validation set, and adjust the model structure or training parameters based on the evaluation results. Test the trained model on the test set to evaluate its performance in practical applications. Save the trained object detection and tracking model for subsequent use in practical applications.
[0086] In some embodiments of the present application, step S300 specifically includes the following steps, and its flowchart is as follows: Figure 4 As shown:
[0087] Step S310: extracting a first frame image from a recorded video as a first input image.
[0088] In an embodiment of the present application, the beginning of recording the video is selected as the time point for image extraction, that is, at the beginning of recording the video, the first frame is extracted from the video as the first input image.
[0089] Step S320: extracting the next frame image after the first frame video from the recorded video as the second input image.
[0090] After the first input image is extracted, the video timeline is continued to advance to the next frame and the next frame is extracted as the second input image.
[0091] In some embodiments of the present application, step S400 specifically includes the following steps, and its flowchart is as follows: Figure 5 As shown:
[0092] Step S410: extracting pixel values of each pixel position in the first input image and the second input image respectively.
[0093] Specifically, load the first input image and the second input image into the processing environment. This is usually done by using an image processing library (such as OpenCV, PIL, etc.); Ensure the image size is consistent: Before performing pixel-level operations, you must ensure that the dimensions (width and height) of the two images are exactly the same. If the dimensions are different, you may need to scale or crop the images to make them match; Traverse the pixels: Traverse each pixel of the image through a double loop. The outer loop traverses the rows (height) of the image, and the inner loop traverses the columns (width) of the image; Extract pixel values: During the traversal process, for each pixel position, extract the pixel value of the first input image and the second input image at that position respectively. The pixel value is usually a vector containing three components: red, green, and blue (RGB), and each component represents the intensity of the color.
[0094] Step S420: subtract the color value of each pixel in the second input image from the color value of the pixel at the corresponding position in the first input image to obtain differential image data.
[0095] For each pixel position, the pixel value (RGB component) of the second input image is subtracted from the pixel value at the corresponding position in the first input image component by component. This usually involves performing a subtraction operation on each color channel (red, green, and blue) separately; since the range of pixel values is limited (usually 0 to 255), the result of the subtraction operation may be negative. In practical applications, these negative numbers are usually set to 0 to indicate no change or reduced to a minimum value; the results of the calculations for each pixel position are combined to form a new image, the difference image. The difference image highlights the differences between the first and second input images; if necessary, it may be necessary to convert the data type of the difference image to the same data type as the original image (such as an 8-bit unsigned integer) for subsequent processing and display.
[0096] In some embodiments of the present application, step S600 specifically includes the following steps, and its flowchart is as follows: Figure 6 As shown:
[0097] Step S610: Acquire key features of the motion trajectory recognition result.
[0098] Specifically, it is necessary to extract key motion trajectory data from the motion trajectory recognition results. These data may include the position change, speed, acceleration, direction change, etc. of the product. Based on the extracted motion trajectory data, calculate the key features that can reflect the motion characteristics of the product. For example, the average speed, maximum speed, speed change rate (acceleration), and frequency of change in the moving direction of the product can be calculated. Perform necessary preprocessing on the calculated features, such as denoising, smoothing, or normalization, to ensure the accuracy and comparability of the data.
[0099] Step S620: According to the predefined motion state categories, the key features are compared with the preset thresholds corresponding to the respective motion state categories to obtain the motion state of the corresponding commodity.
[0100] Before motion state recognition, a series of possible motion state categories need to be predefined, such as "stationary", "slow movement", "fast movement", "accelerated movement", "decelerated movement", "turning", etc. For each motion state category, set the corresponding feature threshold. These thresholds are determined based on experimental data, empirical knowledge or statistical analysis, and are used to distinguish different motion states. The extracted key features are compared with the preset thresholds. For example, if the speed of the product remains at a very low level (below a certain threshold) for a long time, it can be judged that the product is in a "stationary" state; if the speed continues to increase and exceeds a certain threshold, it can be judged as "accelerated movement".
[0101] Based on the result of feature comparison, the current motion state of the product is determined. This may require comprehensive consideration of the values of multiple features and their changing trends over time. Since the motion state of the product may change over time, it is necessary to continuously monitor and update the motion trajectory data in order to adjust the judgment of the motion state of the product in a timely manner.
[0102] Different from the prior art, the implementation method of the present invention uses the image input obtained after calculation by the frame difference method as the model input to obtain the motion trajectory recognition result of the corresponding product, thereby reducing the amount of model calculation while avoiding the recognition of static products. Moreover, the image obtained by the frame difference method itself records the movement trend of the product, so there is no need to clearly identify the product, which can solve the problem of object tracking in the case of ghosting.
[0103] Based on the motion state recognition method provided in the above embodiment, the present invention also provides a motion state recognition device, whose structural diagram is as follows: Figure 7 As shown, the motion state recognition device includes a first model module 110, a second model module 120, an image acquisition module 130, an image processing module 140, a commodity recognition module 150, a state judgment module 160, an image annotation module 170 and a category recognition module 180.
[0104] In an embodiment of the present application, the first model module 110 is used to use a commodity image data set to train a commodity category recognition model; the second model module 120 is used to use a differential image data set to train a target detection and tracking model; the image acquisition module 130 is used to extract a first input image and a second input image based on a recorded video of a camera component, wherein the second input image is the next frame image of the first input image; the image processing module 140 is used to perform a pixel subtraction operation on the second input image and the first input image to obtain differential image data; the commodity recognition module 150 is used to input the differential image data into the target detection and tracking model to obtain a motion trajectory recognition result of the corresponding commodity; the state judgment module 160 is used to judge the motion state of the corresponding commodity based on the motion trajectory recognition result; the image annotation module 170 is used to annotate the first input image or the second input image based on the pixel area in the differential image data; the category recognition module 180 is used to input the annotated first input image or the second input image into the commodity recognition model to obtain a commodity category recognition result.
[0105] The embodiment of the present invention also provides an electronic device based on the above-mentioned motion state recognition method, and its structural schematic diagram is as follows: Figure 8 As shown, the electronic device 200 includes:
[0106] One or more processors 201, network interface 202 and memory 203, Figure 8 In the figure, a processor 201, a network interface 202 and a memory 203 are taken as an example.
[0107] The network interface 202 is in communication with the corresponding processor 201, and the processor 201 and the memory 202 can be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0108] The network interface 202 is used to establish a communication connection between the processor 201 and other external devices, including the following types: RJ-45 interface, SC optical fiber interface, AUI interface, FDDI interface, and Console interface.
[0109] The memory 203 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 201 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions and units stored in the memory 203, that is, the motion state recognition method of the above method embodiment is implemented.
[0110] The memory 203 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 203 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 203 may optionally include a memory remotely arranged relative to the processor 201, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0111] The one or more units are stored in the memory 203, and when executed by one or more processors 201, execute the motion state recognition method in any of the above method embodiments, for example, execute the above described Figure 2 The method comprises steps S100 to S800.
[0112] The electronic device can execute the motion state recognition method provided by the embodiment of the present invention, and has the corresponding program modules and beneficial effects of the execution method. For technical details not fully described in the electronic device embodiment, please refer to the motion state recognition method provided by the embodiment of the present invention.
[0113] The embodiment of the present invention also provides a non-volatile computer-readable storage medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above non-volatile computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the motion state recognition method of the embodiment of the present disclosure is implemented.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other changes in different aspects of the present application as above, which are not provided in detail for the sake of simplicity. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A motion state recognition method, applied to a smart vending machine equipped with a camera assembly, characterized in that: include: Extracting a first input image and a second input image according to the recorded video of the camera assembly, wherein the second input image is a next frame image of the first input image; Performing pixel subtraction operation on the second input image and the first input image to obtain differential image data; Inputting the differential image data into a target detection and tracking model to obtain a motion trajectory recognition result of the corresponding commodity; The motion state of the corresponding commodity is determined according to the motion trajectory recognition result.
2. The method according to claim 1, characterized in that After determining the motion state of the corresponding commodity according to the motion trajectory recognition result, the method further includes: Annotating the first input image or the second input image according to a pixel area in the differential image data; The labeled first input image or the second input image is input into the commodity recognition model to obtain a commodity category recognition result.
3. The method according to claim 1, characterized in that Before acquiring the first input image and the second input image according to the recorded video of the camera assembly, the method further includes: Use the product image dataset to train a product category recognition model; The target detection and tracking model is trained using a differential image dataset.
4. The method according to claim 1, characterized in that The step of extracting a first input image and a second input image according to the recorded video of the camera assembly comprises: Extracting a first frame image from the recorded video as the first input image; A next frame image after the first frame video is extracted from the recorded video as the second input image.
5. The method according to claim 1, characterized in that The step of performing a pixel subtraction operation on the second input image and the first input image to obtain differential image data comprises: For each pixel position in the first input image and the second input image, extract the pixel value thereof respectively; The color value of each pixel in the second input image is subtracted from the color value of the pixel at the corresponding position in the first input image to obtain differential image data.
6. The method according to claim 1, characterized in that The step of determining the motion state of the corresponding commodity according to the motion trajectory recognition result includes: Obtaining key features of the motion trajectory recognition result; According to the predefined motion state categories, the key features are compared with the preset thresholds corresponding to the respective motion state categories to obtain the motion state of the corresponding commodity.
7. The method according to claim 3, characterized in that The method of using the differential image dataset to train and obtain the target detection and tracking model includes: Obtain a differential image dataset; Labeling the commodities in the differential image dataset; Select a deep learning model; The deep learning model is trained using the labeled differential image dataset to obtain the target detection and tracking model.
8. A motion state recognition device, characterized in that: include: The first model module is used to train a product category recognition model using a product image dataset; A second model module is used to train the target detection and tracking model using a differential image dataset; An image acquisition module, used to extract a first input image and a second input image according to the recorded video of the camera assembly, wherein the second input image is a next frame image of the first input image; An image processing module, configured to perform a pixel subtraction operation on the second input image and the first input image to obtain differential image data; A commodity recognition module, used for inputting the differential image data into a target detection and tracking model to obtain a motion trajectory recognition result of a corresponding commodity; A state judgment module, used to judge the movement state of the corresponding commodity according to the movement trajectory recognition result; An image annotation module, configured to annotate the first input image or the second input image according to a pixel area in the differential image data; The category recognition module is used to input the annotated first input image or the second input image into the commodity recognition model to obtain a commodity category recognition result.
9. An electronic device, characterized in that: include: at least one processor; at least one network interface, the network interface being communicatively connected to a corresponding processor; as well as, a memory communicatively connected to the at least one processor; wherein, The network interface is used to establish a communication connection between the processor and other external devices; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a motion state recognition method as described in any one of claims 1-7.
10. A non-volatile computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, which are executed by one or more processors, enabling the one or more processors to execute a motion state recognition method as described in any one of claims 1-7.
