Pharmacy unmanned vehicle path planning and drug matching method based on JPS and RRT algorithms
By fusing JPS and RRT* algorithms for path planning and combining SAD template matching for drug identification, the computational efficiency and identification accuracy issues of unmanned pharmacy vehicles in complex environments are solved, achieving efficient and robust drug matching and path planning.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN UNIV
- Filing Date
- 2026-01-12
- Publication Date
- 2026-04-21
AI Technical Summary
Existing path planning algorithms are computationally inefficient in complex environments, and drug identification systems are sensitive to environmental changes and have poor scalability, making it difficult to meet the real-time and accuracy requirements of unmanned pharmacy vehicles.
The path planning is performed by fusing JPS and RRT* algorithms, and drug identification is performed by combining SAD template matching. JPS is used to quickly generate the initial path, RRT* is used to optimize the local path, edge detection and shape classification are used to narrow the matching space, and the improved SAD algorithm is used for drug identification.
It improves the efficiency and accuracy of path planning, reduces the waste of computing resources, enhances the robustness and real-time performance of drug identification, and supports rapid response and drug identification in dynamic environments.
Smart Images

Figure CN121903522A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and robotics, and more specifically, to a method for path planning and drug matching for unmanned pharmacy vehicles based on JPS and RRT algorithms. Background Technology
[0002] In the field of path planning algorithms, existing methods are mainly divided into two categories: global path planning and local path planning algorithms. Global path planning algorithms, based on environmental conditions, can be further divided into statically-oriented and dynamically-oriented algorithms. If classified according to whether perception and decision-making are separated, they can be mainly divided into traditional algorithms and intelligent algorithms. However, they all have significant limitations, specifically as follows:
[0003] Traditional path planning algorithms are primarily based on graph search and geometric models. Classic algorithms like Dijkstra's and A* find the shortest path by traversing graph nodes, but their computational complexity increases exponentially with environment size, and their efficiency is significantly affected by the design of heuristic functions. Quantitative efficiency differences in complex scenarios remain problematic.
[0004] Jump Point Search (JPS) improves search efficiency by pruning redundant nodes; however, it struggles with continuous spaces and unstructured environments. Random sampling-based algorithms like RRT and PRM demonstrate flexibility in high-dimensional spaces such as robotic arm motion planning through probabilistic graphing and path connection mechanisms, but their paths are highly stochastic and their convergence speed is insufficient. Subsequent improved algorithms, such as RRT*, approximate the optimal path through asymptotic optimization strategies, but computational costs still limit their practical application.
[0005] Currently, drug image recognition and automatic grasping technologies are widely used in smart pharmacy systems to improve the efficiency and accuracy of drug sorting. Traditional image processing methods and deep learning-based recognition techniques each have their applications in such systems, but they still have many limitations in practical scenarios, specifically including the following three aspects:
[0006] High dependence on environmental changes and data distribution, and poor generalization ability: Existing image recognition systems are quite sensitive to external factors such as lighting conditions, background clutter, and shooting angle. In traditional image processing methods, the parameters for contour extraction and edge detection need to be manually adjusted, making it difficult to adapt to diverse scenarios. Although deep learning methods have high accuracy, they heavily rely on large-scale, high-quality labeled image data, resulting in high training costs, difficulty in updating, and poor adaptability to changes in data distribution.
[0007] Recognition accuracy is affected by the similarity of drug appearance and lacks the ability to effectively distinguish complex shapes: many common drugs have similar shapes and colors, such as single-color and two-color capsules, white tablets from different manufacturers, or transparent cod liver oil. Traditional template matching methods struggle to capture subtle feature differences, and deep learning is also prone to recognition confusion when samples are imbalanced or insufficient. Furthermore, existing algorithms are mostly based on two-dimensional image feature extraction and lack the ability to model three-dimensional shapes, leading to decreased recognition performance in non-frontal or occluded conditions.
[0008] The system suffers from poor scalability and real-time performance, making it difficult to meet the demands for dynamic updates and rapid response. Given the large variety and frequent updates of pharmaceutical products, existing systems often require redesigning templates or retraining models when adding new drug identification tasks. This process is complex, time-consuming, and hinders rapid deployment and maintenance. Furthermore, in practical applications, image recognition not only demands high accuracy but also fast response times to meet continuous and efficient grasping rhythms. Current solutions, while ensuring accuracy, often struggle to achieve high real-time performance, impacting the overall system's practicality and promotional value. Summary of the Invention
[0009] This invention aims to overcome the challenges faced by existing path planning and drug identification technologies under limited computing resources. It provides a novel algorithm that integrates JPS and RRT* algorithms and a drug identification method based on template matching to solve the problems of high computing power dependence, poor environmental adaptability and insufficient system coordination in existing technologies.
[0010] To achieve the above objectives, this invention proposes a path planning and drug matching method for unmanned pharmacy vehicles based on JPS and RRT algorithms, including:
[0011] Construct a map of the pharmacy environment and determine the real-time location of the unmanned vehicle;
[0012] The JPS-RRT* algorithm is used for autonomous vehicle path planning to obtain the final driving path;
[0013] The target drug image is acquired, a drug feature template library is constructed, and drug images in the current field of view are periodically acquired. After the drug images are preprocessed, the SAD template matching algorithm is used to match them with the drug feature template library to obtain the drug classification result.
[0014] The unmanned vehicle is controlled to move to the target location according to the final driving path, and performs the corresponding drug grabbing or sorting tasks according to the drug classification results.
[0015] Furthermore, the process of using the JPS-RRT* algorithm for autonomous vehicle path planning includes:
[0016] The JPS algorithm is used to quickly prune symmetrical paths in the pharmacy environment map to generate the initial JPS path.
[0017] The initial JPS path is divided into multiple JPS path segments based on curvature or obstacle density, and the areas that need optimization are marked.
[0018] The JPS path segments are mapped to a continuous space to generate a safe region with adjustable width.
[0019] Sampling is performed within the safe area, and the RRT* algorithm is used to generate progressively optimal sub-paths within the corridor. The path length is reduced by rewiring to obtain a smooth driving path.
[0020] The smooth driving path is then combined with other parts of the initial JPS path to form the final driving path.
[0021] Furthermore, the area to be optimized for the marking is based on the curvature of the path segment or the obstacle density of the environment in which the segment is located.
[0022] Furthermore, the process of using the JPS-RRT* algorithm for autonomous vehicle path planning also includes:
[0023] If a new dynamic obstacle is detected during the autonomous vehicle's operation, the RRT* algorithm is used to replan and avoid the local path segment affected by the new dynamic obstacle, and the replanned smooth driving path is seamlessly spliced with the initial JPS path.
[0024] Furthermore, the local path segment affected by the newly added dynamic obstacle is specifically a path segment within a preset radius centered on the newly added dynamic obstacle.
[0025] Furthermore, the preprocessing of the drug image specifically includes: image grayscale conversion, contrast enhancement, size normalization, contour extraction, and shape classification.
[0026] Furthermore, the size normalization, contour extraction, and shape classification specifically include:
[0027] Use the Canny algorithm or other edge detection operators to extract salient edge information from drug images;
[0028] The significant edge information is subjected to contour tracking and closure processing to remove stray edges and small block interference, and the main drug contour is selected.
[0029] Geometric feature indicators are calculated based on the outline of the main drug, and the drug is initially classified using preset rules.
[0030] Furthermore, the process of matching the drug feature template library using the SAD template matching algorithm includes:
[0031] The SAD algorithm is used to calculate the similarity between drug image regions and drug feature template libraries at the pixel level.
[0032] A weighted strategy is applied to key areas of the drug to make the matching results more distinctive, enhance the ability to identify drugs with similar appearances, and output the drug classification results.
[0033] When the matching score of all candidate templates is lower than the set threshold, it is determined to be in an unidentified state.
[0034] Furthermore, the drug classification results include the drug name, category, location information, and confidence score.
[0035] Furthermore, the pharmacy environment map is constructed using simultaneous localization and mapping (SMR) technology, and the real-time location of the unmanned vehicle is determined using an adaptive Monte Carlo localization algorithm.
[0036] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0037] In terms of path planning, this invention optimizes the structured inefficiency of the RRT* algorithm by using the JPS jump point method to quickly generate the initial path when in a regular region, thereby reducing the global sampling requirement of the RRT* algorithm.
[0038] Furthermore, this invention optimizes the problem of JPS algorithm failure in unstructured environments. Specifically, in complex environments, the algorithm is switched to RRT* algorithm for optimization, thereby avoiding the infeasibility of JPS paths. At the same time, when dealing with dynamic obstacles, the two work together. The JPS algorithm provides a global static path framework, and when dynamic obstacles are detected, the RRT* algorithm makes local real-time adjustments. This not only meets the requirement of running in dynamic environments, but also reduces the scope of replanning.
[0039] In terms of image recognition, this invention performs edge detection and shape recognition on drug images, initially classifying drugs into three categories: round, elliptical, and capsule-shaped, significantly reducing the search space for subsequent template matching. This step effectively avoids traversing a large number of irrelevant templates in global matching, greatly reducing the waste of computational resources.
[0040] This invention employs shape classification results, allowing the system to quickly locate matching templates by simply calling the template library for the corresponding category, thus reducing the risk of false matches. This strategy accelerates the matching process, shortens recognition time, and maintains high recognition accuracy.
[0041] By combining shape classification results and using the improved SAD algorithm to perform local matching on normalized and standardized images, the ability to resist illumination and noise interference is further enhanced, making drug identification more robust and efficient. Attached Figure Description
[0042] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. In the drawings:
[0043] Figure 1 This is a schematic diagram of the overall process of the pharmacy unmanned vehicle path planning and drug matching method based on JPS and RRT algorithms of the present invention.
[0044] Figure 2 This is a flowchart of the path planning and navigation process in an embodiment of the present invention;
[0045] Figure 3 This is a path diagram of the JPS algorithm in an embodiment of the present invention;
[0046] Figure 4 This is a path diagram of the RRT* algorithm in an embodiment of the present invention;
[0047] Figure 5 This is a flowchart illustrating the drug identification process in an embodiment of the present invention;
[0048] Figure 6 This is a schematic diagram of a high-definition map test scenario in an embodiment of the present invention;
[0049] Figure 7 This is a schematic diagram of vehicle position mapping in an embodiment of the present invention;
[0050] Figure 8 This is a schematic diagram illustrating accurate vehicle positioning in an embodiment of the present invention;
[0051] Figure 9 This is a simulation image of the path navigation algorithm in this embodiment of the invention;
[0052] Figure 10 The image recognition results are shown in the embodiments of the present invention. Detailed Implementation
[0053] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the disclosure to those skilled in the art. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0054] This embodiment proposes a method for path planning and drug matching for unmanned pharmacy vehicles based on JPS and RRT algorithms, such as... Figure 1 As shown, the specific steps include:
[0055] 1. Hardware Configuration
[0056] Chassis controller: Chassis controller based on ARM Cortex-M4 microcontroller.
[0057] Core processor: Raspberry Pi 4B, equipped with a 1.5GHz processor.
[0058] Camera: Depth camera, resolution 640×480.
[0059] Main control device: Raspberry Pi 4B (4GB memory), running Ubuntu 18.04 and ROS Melodic.
[0060] Other hardware configurations: voice broadcast module, LiDAR.
[0061] 2. Map building:
[0062] First, ensure that the SLAM map is completed. Then, use the AMCL algorithm to locate the car and record its coordinates. Modify the various markers in the code. Finally, put the collected multiple datasets into a pre-trained CNN model to automatically correct the map and make it more accurate.
[0063] 3. The route planning and navigation process, such as... Figure 2 As shown, it specifically includes:
[0064] a) Interaction process of JPS-RRT* algorithm
[0065] (1) Global path generation (JPS-driven):
[0066] Input a rasterized map (obtained from SLAM mapping), set the endpoint and start point.
[0067] (a) JPS quickly prunes symmetrical paths in a raster map to generate an initial path consisting of Jump Points.
[0068] (b) Divide the JPS path into multiple segments based on curvature or obstacle density, and mark the areas that need optimization (such as narrow passages and complex curves).
[0069] Output line segments and optimization requirement markers; JPS algorithm path diagram as follows: Figure 3 As shown.
[0070] (2) Local optimization (dominated by RRT* algorithm)
[0071] Input: JPS path segment, continuous spatial map, optimization requirement markers
[0072] process:
[0073] (a) Map the JPS path segment to a contiguous space to generate a safe region with adjustable width.
[0074] (b) Sampling with high probability (e.g., 70%) within the safe corridor guides the RRT* tree to grow along the JPS path, with specific effects as follows: Figure 4 As shown.
[0075] Sampling probability distribution:
[0076] (c) The RRT* algorithm generates asymptotically optimal subpaths within the corridor and reduces path length by rewiring.
[0077] Output: A smooth and near-optimal continuous path.
[0078] (3) Dynamic obstacle response (cooperative processing):
[0079] Input: Point cloud data collected by external sensors
[0080] process:
[0081] (a) Identify new obstacles added by JPS when planning the global path;
[0082] (b) RRT* optimization is only performed on the affected path segments (such as the area within 2m around the obstacle) while keeping other path segments unchanged to reduce computational overhead;
[0083] (c) Seamlessly merge the RRT* optimized local paths with the JPS global paths to ensure continuity.
[0084] Output: The updated obstacle avoidance path.
[0085] The complementary process of the JPS-RRT* algorithm achieves the following technical effects:
[0086] RRT* suffers from redundant computations due to random sampling in regular grids (such as invalid exploration in long straight channels). Therefore, a static straight path can be quickly generated using JPS, and RRT* only needs to expand nodes and verify path feasibility through local sampling, avoiding global sampling and thus preventing resource waste.
[0087] Using this method, it was tested that the planning time in a 50×50 raster map was reduced from 320ms in RRT to 80ms in JPS-RRT.
[0088] The path may be infeasible in complex terrain (e.g., unable to pass through narrow bends). However, by using the marked nodes obtained in previous steps, we can determine how RRT* can perform local optimization in the complex regions marked by JPS to generate a smooth path that satisfies kinematic constraints. This can reduce the path curvature by 60%, adapting to the vehicle's minimum turning radius.
[0089] Because JPS cannot handle dynamic obstacles, and RRT*'s global replanning is too time-consuming, a collaborative approach is used. JPS provides a global reference path, while RRT* only adjusts the affected local area. This ultimately reduces the dynamic obstacle avoidance response time from 500ms for pure RRT* to 150ms.
[0090] The drug identification process in this embodiment is as follows: Figure 5 As shown, it specifically includes:
[0091] 4. Template image preparation stage:
[0092] High-resolution image samples of various drug categories are collected by capturing target drug images from standard angles using a camera. The acquired images are then manually or semi-automatically annotated to extract edge contours and key texture features, and a drug feature template library is constructed. This template library can be quickly accessed during subsequent recognition processes and is dynamically expandable without requiring model retraining.
[0093] Elliptical Pill Template Library 1
[0094] 5. Image acquisition and preprocessing stage:
[0095] (1) Real-time image acquisition
[0096] During system operation, the robot's camera periodically captures images of the medicine in its current field of view and caches them in a processing queue.
[0097] (2) Image preprocessing:
[0098] The following processing steps are performed on the acquired images to improve subsequent recognition accuracy:
[0099] Image grayscale conversion: Removes color interference and unifies image channels;
[0100] Denoising: Use Gaussian filtering, median filtering, etc. to suppress image noise;
[0101] Contrast enhancement: Improves the clarity of image edges and textures, facilitating feature extraction;
[0102] Size normalization: Unify resolution and standardize image size to adapt to algorithm processing.
[0103] 6. Contour extraction and shape classification stage
[0104] (1) Edge detection:
[0105] Use the Canny algorithm or other edge detection operators to extract salient edge information from drug images.
[0106] (2) Contour extraction and processing:
[0107] The edge map is processed by contour tracking and closure to remove stray edges and small block interference, and the main drug contour is selected.
[0108] (3) Shape feature analysis and classification:
[0109] Based on the extracted contour information, calculate its geometric feature indices:
[0110] Aspect ratio, perimeter to area ratio, roundness, rectangularity, concavity / convexity, etc.;
[0111] Based on the established rules, drugs are initially classified into five categories: round tablets, oval pills, single-color capsules, two-color capsules, and cod liver oil.
[0112] The classification results are used to narrow down the matching search space.
[0113] 7. Template matching stage:
[0114] SAD template matching algorithm:
[0115] Matching is performed only in the template sub-library corresponding to the current image shape category, narrowing the matching range to improve recognition efficiency;
[0116] The SAD (Sum of Absolute Differences) algorithm is used to calculate the similarity between the image region and the template image at the pixel level.
[0117] A weighted strategy is applied to key areas of the drug (such as the central axis and core pattern area) to make the matching results more distinctive and enhance the ability to identify drugs with similar appearances.
[0118] When the matching score of all candidate templates is lower than the set threshold, the system outputs an "unrecognized" status to prevent misidentification.
[0119] 8. Output identification and task control phase:
[0120] (1) Recognition result output:
[0121] The final recognition output includes the following information:
[0122] Drug name (template corresponding label);
[0123] Category (round / capsule, etc.);
[0124] Location information (bounding box coordinates / center point);
[0125] Confidence score.
[0126] (2) Robot task linkage control:
[0127] If the recognition is successful, the output will be sent to the control system of the pharmacy robot to perform corresponding operations such as grasping, sorting, and dispensing medicine;
[0128] If recognition fails or the confidence level is insufficient, the system will enter a "pending confirmation" state, triggering a prompt or a re-recognition process.
[0129] As a preferred embodiment, a path planning and drug matching system is further proposed based on the above method. The functions and principles of each module are as follows:
[0130] 1. Image acquisition module
[0131] Real-time capture of drug images using a depth camera (640×480 resolution, 30Hz frame rate), with support for ROS image message subscription.
[0132] Image streams are read via ROS nodes to ensure real-time performance.
[0133] Implementation method:
[0134] The connection to the depth camera is achieved by calling the OpenCV cv2.VideoCapture interface, setting the image acquisition resolution to 640×480 pixels, and the frame rate to be stable at 30 frames per second to ensure the real-time performance and smoothness of image data.
[0135] Each frame of the acquired image is normalized and preprocessed, including grayscale conversion and Gaussian filtering for noise reduction, to reduce the computational complexity of subsequent image processing, while highlighting the outline and key features of the drug, ensuring the efficient operation of the recognition algorithm under limited computing power.
[0136] 2. Path planning module
[0137] Use Raspberry Pi 4B to process relevant information and plan paths.
[0138] The system subscribes to LiDAR scanning information via ROS nodes and uses odometers to determine its location.
[0139] Implementation method:
[0140] The current location is determined by comparing the data currently recorded by the odometer with the data before departure, and the location is further confirmed by scanning obstacles with LiDAR.
[0141] By comparing the distance between the current location and the target location, the shortest path is selected.
[0142] 3. Image preprocessing module
[0143] Image grayscale conversion:
[0144] A weighted average method is used to convert the color image to grayscale (Gray=0.299×R+0.587×G+0.114×B) to reduce computational complexity and preserve brightness information.
[0145] Image denoising:
[0146] Gaussian filtering is used to denoise grayscale images, reducing the impact of acquisition and environmental noise while preserving edge details.
[0147] Image enhancement:
[0148] By using piecewise linear grayscale transformation to enhance image contrast, the shape and outline of the medicine are highlighted, thus improving recognition accuracy.
[0149] 4. Image Shape Classification Module
[0150] Edge monitoring:
[0151] Edge detection is performed on the preprocessed image using the Canny operator, and a Gaussian filtering and smoothing dual-threshold strategy is combined to extract clear and complete drug outlines.
[0152] Shape recognition and classification:
[0153] The circular medicine bottle recognition uses the Hough Circle Detection algorithm to locate the center and radius of the circle, achieving robust circular recognition.
[0154] Ellipse recognition extracts elliptical contour pixels from images, uses k-means clustering to separate edge points, fits the elliptical model using the least squares method, removes outliers, and adapts to deformation and rotation.
[0155] Capsule recognition is based on aspect ratio (>2.0) and LBP texture uniformity (>0.15). Local Binary Pattern (LBP) is used to extract texture features to achieve fast and accurate capsule recognition.
[0156] 5. Template Matching Module
[0157] Template library selection:
[0158] Based on the shape classification results, the corresponding category template library is selected for matching, reducing the search space and improving efficiency.
[0159] Secondary image preprocessing:
[0160] Grayscale normalization and size standardization are performed on the target and template images to reduce the impact of lighting and scale differences.
[0161] Template matching algorithm:
[0162] An improved SAD algorithm is used to calculate the matching similarity. The absolute difference of pixel gray levels is accumulated by traversing the window, and the template with the smallest SAD value is selected as the recognition result.
[0163] Matching optimization:
[0164] By combining shape classification to narrow down the matching range, the probability of false matches is reduced, and fast and accurate recognition is achieved.
[0165] 6. Result Output Module
[0166] Topics and data transmission:
[0167] The recognition results are published via ROS topic (Int32MultiArray message type), and the message content is the drug category number and the corresponding voice broadcast.
[0168] Function trigger:
[0169] Control the frequency of receiving topics (configurable from 0.5-10Hz) to avoid wasting computing power.
[0170] The recognition process is initiated upon receiving a topic. For example, when the robot arrives at the medication dispensing station, it can trigger the next recognition step by locating its own position.
[0171] The real-world test scenario in this embodiment is as follows: Figure 6 As shown, map drawing is performed using LiDAR, and map iteration is carried out using deep learning, thereby achieving the effect of map refinement and obtaining accurate high-definition maps.
[0172] like Figure 7As shown, the vehicle's position in space can be obtained by calculating its own position through the algorithm. However, the vehicle's position at this time is an approximate position inferred based on probability. The yellow mark indicates the possible positions.
[0173] like Figure 8 As shown, the algorithm can further compress its probability position, thereby achieving the goal of determining its accurate position.
[0174] After determining its own position, the JPS and RRT* fusion algorithm is used for the next step of planning, and the central controller issues execution decisions. The algorithm simulation image is as follows. Figure 9 As shown in the figure, the blue part represents the route searched by the JPS algorithm, the green part represents the route searched by the RRT* algorithm, and the red part represents the final algorithm route after local optimization by the RRT* algorithm based on the JPS algorithm.
[0175] experiment
[0176] This embodiment obtains relevant performance comparisons through tests in real-world scenarios. Path planning comparisons were performed on the JPS-RRT* algorithm and its individual component decompositions. Performance comparisons of the same task under different planning algorithms were also conducted, resulting in relevant comparison data tables. Table 1 shows the performance comparison data of the JPS-RRT* algorithm with the two individual algorithms, and Table 2 shows the efficiency comparison results of each algorithm.
[0177] Table 1
[0178] index JPS <![CDATA[RRT * ]]> <![CDATA[JPS- RRT * ]]> Planning time (s) 0.1 2.3 0.4 Path length (m) 28.5 25.3 25.8 Number of emergency stops (times) 6 2 1
[0179] Table 2
[0180] algorithm Planning time (ms) Path length (m) Smoothness (1 / m) Dijkstra 620 28.5 3.1 A* 85 28.7 2.8 RRT* 320 25.3 1.2 JPS-RRT* 135 25.9 1.4
[0181] The comparison results above show that the pruning characteristics of the JPS algorithm significantly improve the global path search efficiency, while the RRT* algorithm ensures path smoothness and adaptability to dynamic environments in terms of local optimization. Experimental results demonstrate that this method outperforms the traditional Dijkstra and A* algorithms in terms of path planning time, path quality, and computational resource consumption, and also shows a significant improvement in adaptability to dynamic environments.
[0182] In image recognition, this system pre-screens drug images through edge extraction and shape classification before template matching, effectively eliminating a large number of irrelevant templates and significantly reducing the matching search space. This strategy not only greatly reduces the number of traversals and computational overhead of the matching algorithm, but also effectively avoids resource waste caused by redundant comparisons, significantly improving overall recognition efficiency. Especially in platforms with limited computing resources, such as pharmacy robots, this method can achieve faster response speeds and lower energy consumption, helping to improve the system's real-time performance and deployment flexibility. Table 3 shows a comparison of the time consumption of SAD template matching combined with contour feature analysis and SAD template matching.
[0183] Table 3
[0184] Matching Algorithm round pills oval pills Cod liver oil Monochrome capsules Two-color capsules SAD Algorithm 9.34s 12.57s 10.21s 13.12s 12.71s Improved SAD algorithm 3.23s 4.18s 3.65s 4.51s 4.39s
[0185] As shown in Table 3, even when drugs have similar appearances (e.g., similar colors, sizes, and outlines), this system can still effectively distinguish them based on high-precision edge information and shape feature extraction. Subsequently, the SAD matching algorithm further improves the accuracy of identifying similar drugs in complex scenarios. Simultaneously, the constructed drug template library supports dynamic expansion; adding new drug categories does not require retraining the model, significantly improving the system's adaptability and maintainability. The template matching algorithm exhibits good resistance to changes in lighting and scale, ensuring stable and accurate recognition results even in varied pharmacy environments.
[0186] Drug identification test results as follows Figure 10 As shown, the organic integration of the recognition process in this embodiment not only enhances the system's ability to distinguish between drugs with similar appearances, but also significantly improves the overall recognition accuracy and response speed. Compared with traditional methods based on full-image matching or end-to-end training, this system achieves a good balance between accuracy, efficiency, and computational resource utilization, possessing stronger practicality and scalability, and can stably adapt to the intelligent recognition needs of pharmacy robots for various drugs.
[0187] In summary, the method proposed in this embodiment effectively narrows the search range for template matching and significantly improves the system's operating efficiency by using edge extraction and shape classification as preprocessing steps. Simultaneously, by combining local texture features with an improved SAD algorithm, the system's ability to distinguish similar drugs and its robustness in complex environments are enhanced while ensuring recognition accuracy. Furthermore, the designed template library supports dynamic expansion, further improving the system's adaptability and maintainability. Therefore, this invention is not only applicable to standard drug recognition tasks but also possesses engineering application value for stable and rapid operation in real-world pharmacy scenarios.
[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for path planning and drug matching for unmanned pharmacy vehicles based on JPS and RRT algorithms, characterized in that, include: Construct a map of the pharmacy environment and determine the real-time location of the unmanned vehicle; The JPS-RRT* algorithm is used for autonomous vehicle path planning to obtain the final driving path; The target drug image is acquired, a drug feature template library is constructed, and drug images in the current field of view are periodically acquired. After the drug images are preprocessed, the SAD template matching algorithm is used to match them with the drug feature template library to obtain the drug classification result. The unmanned vehicle is controlled to move to the target location according to the final driving path, and performs the corresponding drug grabbing or sorting tasks according to the drug classification results.
2. The method according to claim 1, characterized in that, The process of using the JPS-RRT* algorithm for autonomous vehicle path planning includes: The JPS algorithm is used to quickly prune symmetrical paths in the pharmacy environment map to generate the initial JPS path. The initial JPS path is divided into multiple JPS path segments based on curvature or obstacle density, and the areas that need optimization are marked. The JPS path segments are mapped to a continuous space to generate a safe region with adjustable width. Sampling is performed within the safe area, and the RRT* algorithm is used to generate progressively optimal sub-paths within the corridor. The path length is reduced by rewiring to obtain a smooth driving path. The smooth driving path is then combined with other parts of the initial JPS path to form the final driving path.
3. The method according to claim 2, characterized in that, The area to be optimized for marking is based on the curvature of the path segment or the obstacle density of the environment in which the segment is located.
4. The method according to claim 1, characterized in that, The process of using the JPS-RRT* algorithm for autonomous vehicle path planning also includes: If a new dynamic obstacle is detected during the autonomous vehicle's operation, the RRT* algorithm is used to replan and avoid the local path segment affected by the new dynamic obstacle, and the replanned smooth driving path is seamlessly spliced with the initial JPS path.
5. The method according to claim 4, characterized in that, The local path segment affected by the newly added dynamic obstacle is specifically the path segment within a preset radius centered on the newly added dynamic obstacle.
6. The method according to claim 1, characterized in that, The preprocessing of the drug image specifically includes: image grayscale conversion, contrast enhancement, size normalization, contour extraction, and shape classification.
7. The method according to claim 6, characterized in that, The size normalization, contour extraction, and shape classification specifically include: Use the Canny algorithm or other edge detection operators to extract salient edge information from drug images; The significant edge information is subjected to contour tracking and closure processing to remove stray edges and small block interference, and the main drug contour is selected. Geometric feature indicators are calculated based on the outline of the main drug, and the drug is initially classified using preset rules.
8. The method according to claim 1, characterized in that, The process of matching the drug feature template library with the SAD template matching algorithm includes: The SAD algorithm is used to calculate the similarity between drug image regions and drug feature template libraries at the pixel level; A weighted strategy is applied to key areas of the drug to make the matching results more distinctive, enhance the ability to identify drugs with similar appearances, and output the drug classification results. When the matching score of all candidate templates is lower than the set threshold, it is determined to be in an unidentified state.
9. The method according to claim 1, characterized in that, The drug classification results include the drug name, category, location information, and confidence score.
10. The method according to claim 1, characterized in that, The pharmacy environment map is constructed using simultaneous localization and mapping (SMR) technology, and the real-time location of the unmanned vehicle is determined using an adaptive Monte Carlo localization algorithm.