Intelligent medicine box and system based on Raspberry Pi

Through the Raspberry Pi-based intelligent medicine box system, combined with the rotation axis, CSI camera and support vector machine algorithm, drug detection and automatic drug distribution are realized, solving the problems of single function and complex operation of the medicine box, and providing safe storage and The remote monitoring function improves the intelligence and practicality of the medicine box.

CN119097555APending Publication Date: 2024-12-10KUNMING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411181865.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-27
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

The medicine boxes on the market have single functions, poor practicality, and complex operations. They are especially not suitable for the elderly and have high prices.

Method used

Design a smart medicine box system based on Raspberry Pi to realize safe storage of drugs, automatic drug distribution, regular reminder, use detection, remote real-time query and remote function settings, through rotating axis, drug distribution barrel, CSI camera, support vector machine A combination of technologies such as algorithms, voice modules and MQTT protocols to realize drug detection and remote communication.

Benefits of technology

It realizes the accuracy of drug detection and automatic drug production function, reduces human errors, provides safe storage of drugs, automatic drug distribution, timed reminders and remote monitoring functions, and improves the intelligence and practicality of the drug box.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119097555A_ABST
    Figure CN119097555A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent medicine box and system based on Raspberry Pi, and relates to an embedded technology and a digital image processing technology. Safe medicine storage, automatic medicine distribution, timed reminding, medicine detection, remote communication and the like are achieved. At least one medicine dispensing barrel is placed in the shell, a conical inclined plane body, a rotating shaft, a medicine dispensing upper part and a medicine dispensing lower part are arranged in each medicine dispensing barrel, the rotating shaft is driven by the motor to realize that medicines fall into the medicine outlet channel, and the medicine outlet channel is blocked by the baffle, so that only one medicine is discharged at a time; and correct medicine discharge is ensured through a support vector machine algorithm image processing and medicine detection function. The system is further provided with a voice module for interaction, the Raspberry Pi and the mobile terminal conduct information intercommunication through an MQTT protocol, and an applet remotely sets medicine taking information and obtains medicine taking records. According to the method, more convenient and safer medication management experience is provided, the problems of forgetting, wrong taking and the like possibly occurring in the medication process are effectively solved, and the medication safety and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of electronic digital data processing, and specifically to a smart medicine box and system based on Raspberry Pi. Background Art

[0002] At present, there are three common types of medicine boxes on the market: 1. Conventional plastic medicine boxes, 2. Electronic alarm medicine boxes, and 3. Remote monitoring medicine boxes. Conventional plastic medicine boxes are usually made of plastic and have different compartments for storing medicines. They are cheap and easy to obtain. Electronic alarm medicine boxes are improved from conventional medicine boxes and have reminder functions. Electronic alarm medicine boxes can set multiple reminder times to ensure that medicines are taken on time and avoid missing or repeating medicines. Remote monitoring medicine boxes are usually equipped with intelligent reminder systems that can be connected through mobile phone APPs to remind users to take medicines on time and record medication status. The advantage is that they can be remotely monitored, which helps to regularize medication.

[0003] However, conventional plastic medicine boxes are not intelligent enough to remind people to take medicine, and are easy to forget. Electronic alarm medicine boxes are not suitable for the elderly. For some elderly people, operating electronic devices may be difficult, and they may prefer simple and easy-to-use manual medicine boxes. Remote monitoring medicine boxes are expensive, have single functions, and have low cost performance. Summary of the invention

[0004] In view of the above problems, the present invention discloses a smart medicine box and system based on Raspberry Pi, which can realize safe storage of medicines, automatic dispensing, timed reminders, intake detection, remote real-time query, remote function setting, etc., so as to solve the problems of single function, poor practicality and complicated operation of various medicine boxes on the market.

[0005] The technical solution of the present invention is as follows:

[0006] A smart medicine box based on Raspberry Pi, comprising: a rotating shaft 1, a medicine dispensing barrel 2, a shell 3, a medicine taking box 4, a conical inclined plane 5, a card pin 6, a card pin hole 7, a preset medicine dispensing channel, at least two of the medicine dispensing channels, a baffle groove 10, a medicine dispensing lower part 11, a baffle 12, a photoelectric sensor 13, a medicine dispensing port 14, a CSI camera 15, a steering gear 16, a medicine dispensing selection port 17, and a medicine dispensing upper part 18;

[0007] At least four medicine dispensing barrels 2 are evenly fixed on the inner wall of the shell 3, and an opening is opened at the bottom of the outer wall of the shell 3 to put a medicine box 4 in. A steering gear 16 is provided next to the medicine box 4.

[0008] Each medicine dispensing barrel 2 is composed of a rotating shaft 1, a conical inclined surface 5, a medicine dispensing selection port 17, a clamping needle 6, a clamping needle hole 7, a medicine dispensing upper part 18, a medicine dispensing lower part 11, and a baffle groove 10. The rotating shaft 1 sequentially penetrates and connects the conical inclined surface 5, the medicine dispensing upper part 18, the baffle groove 10, and the medicine dispensing lower part 11.

[0009] A locking pin 6 is provided at the bottom of the conical bevel body 5, and the same number of locking pin holes 7 as the number of the medicine dispensing channels are evenly provided at the top of the medicine dispensing upper part 18; the locking pin 6 is located behind the medicine dispensing selection port 17, and the locking pin hole 7 is located behind the medicine dispensing channel. By inserting the locking pin 6 into the locking pin hole 7, the conical bevel body 5 is locked with the medicine dispensing upper part 18 and the medicine dispensing lower part 11;

[0010] The edge of the conical bevel body 5 is provided with a drug outlet selection port 17. When a drug is put into the conical bevel body 5, it will naturally fall to the bottom due to gravity. By rotating the rotating shaft 1, the drug falls to the drug outlet channel at the upper part of the drug dispensing part. The rotating shaft 1 is manually rotated to drive the conical bevel body 5, so that the drug outlet selection port 17 matches the drug outlet channel, and the card needle 6 is inserted into the card needle hole 7 for fixing.

[0011] The medicine dispensing upper part 18 and the medicine dispensing lower part 11 are provided with grooves, and the size specifications of the grooves may be inconsistent, corresponding to medicines of different shapes, and when the grooves of corresponding specifications of the medicine dispensing upper part 18 and the medicine dispensing lower part 11 are combined together to form a medicine outlet channel;

[0012] The medicine dispensing lower part 11 is provided with a medicine outlet 14, and the medicine dispensing lower part is driven by the rotating shaft 1, so that the medicine in the medicine dispensing lower part falls to the medicine outlet 14, and the medicine in the medicine dispensing channel of the medicine dispensing upper part 18 is blocked by the baffle, and the medicine dispensing upper part 18 is driven by the rotating shaft, so that the medicine in the medicine dispensing channel of the medicine dispensing upper part falls to the medicine dispensing channel of the medicine dispensing lower part 11;

[0013] The baffle groove 10 is provided in the medicine dispensing upper part 18 and the medicine dispensing lower part 11, and the baffle 12 is installed in the baffle groove 10, the purpose is to prevent all the medicines in the medicine dispensing channel from falling; the conical inclined plane body 5, the medicine dispensing upper part 18 and the medicine dispensing lower part 11 are driven by the rotating shaft 1, so that the medicine enters the medicine dispensing channel from the medicine dispensing selection port 17; through continuous rotation, the medicine in the medicine dispensing channel gradually accumulates, and when the medicine dispensing channel passes through the medicine dispensing port, the medicine in the medicine dispensing lower part 11 falls into the medicine dispensing box 4; because the baffle 12 is provided in the baffle groove 10 just above the medicine dispensing port 14, the medicine in the medicine dispensing upper part 18 will fall onto the baffle, and will not enter the medicine dispensing channel of the medicine dispensing lower part 11;

[0014] The area of ​​the baffle 12 is smaller than the bottom area of ​​the medicine dispensing barrel 2, and the gap formed is only enough for one medicine to pass through. The medicine can be a capsule or a granule. When the baffle groove 10 is above the non-drug outlet, there is no baffle 12 to block it. By rotating, when a medicine in the drug outlet channel in the upper part 18 of the medicine dispensing falls to the lower part 11 of the medicine dispensing, it rotates again, so that the drug outlet channel in the upper part 18 of the medicine dispensing is misaligned with the gap formed by the baffle 12 and the medicine dispensing barrel 2, reducing the size of the gap and preventing the medicine from falling. When the drug outlet channel of the lower part 11 of the medicine dispensing passes through the drug outlet 14, the medicine falls into the medicine box 4. Repeating the above steps can achieve the dropping of a single medicine.

[0015] A photoelectric sensor 13 is provided below the medicine outlet 14, and a CSI camera 15 is provided at the center of the bottom of the medicine dispensing barrel 2;

[0016] An intelligent system based on Raspberry Pi, comprising the following steps:

[0017] S1, put the medicine into the medicine box 4, and use the upper CSI camera 15 to take pictures and samples;

[0018] S2. Obtain the grayscale mean value in the layer channel of each drug after photo sampling through the Raspberry Pi main control board. The specific steps are as follows:

[0019] S2.1. Use the Raspberry Pi main control board to perform layer separation on the photo to obtain the red layer, green layer, and blue layer respectively;

[0020] S2.2, using edge detection algorithm to detect the outline of the drug for each layer, and calculating the grayscale mean of the pixels within the outline;

[0021] S2.3. The calculated grayscale mean will be used as a training sample.

[0022] The training sample is represented as (x i ,y i ),i=1,2,3,…,n, where, y i is the type of drug, x i Testing samples;

[0023] S3, taking the grayscale mean in the layer channel of each drug as a training sample;

[0024] S4, establishing a support vector machine algorithm, and using training samples to train the support vector machine algorithm;

[0025] The support vector machine algorithm solves the maximum spacing hyperplane for the learning samples, and when they are linearly separable, finds the optimal classification hyperplane for two types of samples in the original space;

[0026] When the samples are not linearly separable, a slack variable is added and the samples of the low-dimensional input space are mapped to the high-dimensional space by using nonlinear mapping to make them linearly separable. In this way, the optimal classification hyperplane can be found in the feature space. This optimal classification hyperplane is the maximum spacing hyperplane. The key to SVM is to maximize this spacing to achieve effective classification.

[0027] The hyperplane is a geometric object with one dimension lower than the data space; specifically, the hyperplane is mathematically a (p-1)-dimensional plane, where p is the dimension of the data space, so the hyperplane is not necessarily a two-dimensional plane;

[0028] The specific steps of establishing a support vector machine algorithm and using training samples to train the support vector machine algorithm are as follows:

[0029] S4.1. Obtain the linear equation of the optimal hyperplane based on the training samples. The specific expression is as follows:

[0030] w T x+b=0

[0031] In the formula, w represents the hyperplane normal vector, b represents the intercept, T represents the training sample, and x represents the new input;

[0032] The training sample is {(x 1 ,y 1 ),(x 2 ,y 2 ),…,(x n ,y n ),}, where y i ∈{1,-1}, that is, the output of the function. To get a new input x, we need to infer y i Is it 1 or -1? We can define a decision function g(x)=sgn(f(x)), where sgn(f(x)) is a sign function, that is, it takes the value 1 when f(x)≥0, otherwise it takes the value -1. The linear equation of the optimal hyperplane is:

[0033] f(x)=w T ·x+b

[0034] In the formula, w represents the hyperplane normal vector, b represents the intercept, T represents the training sample, and x represents the new input;

[0035] S4.2. The optimal hyperplane is determined by determining the hyperplane normal vector w and the intercept b, and the problem is transformed. In this case, all training samples are required to satisfy |f(x)|≥1. When f(x)=1, it means that the sample is closest to the hyperplane.

[0036] Therefore, the correctly classified sample can be expressed as yi(w T ·x i +b)-1≥0,i=1,2,3,…,n, n represents the number of samples;

[0037] When the training sample satisfies yi(w T ·x i +b)-1=0, the training sample is called a "support vector"; and at this time, w T The hyperplane where x+b=1 is called the first hyperplane h 1 and satisfy w T The hyperplane where x+b=-1 is called the second hyperplane h 2 ,h1 and h 2 They are collectively called support hyperplanes. They support two types of data respectively, and are located at h 1 and h 2 The hyperplane in the middle is the best choice to separate the two types of data. The distance between the two supporting hyperplanes is called "interval", represented by r. It can be said that one of the core of SVM is to maximize the interval r. The expression of r is:

[0038]

[0039] At this point, solving the hyperplane problem can be simplified to "find the minimum value of w, that is, make The Lagrange function is introduced to solve the problem of "minimum value". Where ai represents the Lagrange multiplier, ai=(a 1 ...a n ) T ∈R, and a i ≥0, take the partial derivative of the Lagrange function L(w,b,a) with respect to w and b and make it equal to 0. The specific expression is as follows:

[0040]

[0041] S4.3. Substitute the Lagrange function L(w,b,a) for the partial derivative of w and b into In the equation, eliminating w and b, we can get the Lagrange dual expression, which is as follows:

[0042]

[0043] Solve for a i The optimal solution Then solve for w * and b * , the specific expression is as follows:

[0044]

[0045] At this point, the SVM classification function can be obtained, and the specific expression is as follows:

[0046]

[0047] Classify unknown test sample data points through SVM classification function;

[0048] S5. Use the Raspberry Pi main control board to save photos of different types of medicines, record the names of the medicines, and upload them to the cloud platform;

[0049] Using the MQTT communication protocol, the Raspberry Pi main control board transmits data to the device cloud, that is, the Alibaba Cloud platform, in the form of publishing topics, and obtains data through the device cloud subscription topic. The mobile terminal, that is, the WeChat applet, obtains the uploaded data stream through the device cloud subscription topic, and issues instructions through the publishing topic to transmit it to the Raspberry Pi main control board through the device cloud, so as to realize the information exchange between the publishing topic of the Raspberry Pi main control board and the subscription topic of the mobile terminal, and the information exchange between the subscription topic of the Raspberry Pi main control board and the publishing topic of the mobile terminal;

[0050] Furthermore, after the drug test is completed, the voice module starts playing the medication reminder. The user needs to say "open the medicine box" to the voice module to stop the medication reminder, and the servo behind the medicine box rotates 180°, and the medicine box can be taken out. After taking the medicine, the user needs to say "I have taken the medicine" to the voice module. The Raspberry Pi will record the time of taking the medicine and upload it to the server for the mobile terminal to obtain the medication record.

[0051] The beneficial effects of the present invention are:

[0052] 1. It realizes the function of automatic medicine dispensing. Compared with the existing smart medicine box, it has a separate medicine barrel, which can store more medicines and does not need to be frequently replenished. Any amount of medicine can be dispensed at a time. It avoids the error of medicine type and dosage when taking medicine manually.

[0053] 2. The drug detection function is realized to confirm the type and quantity of drugs to prevent errors in the automatic drug dispensing function. The system can detect the type and quantity of drugs through highly accurate image recognition and calculation functions, thereby reducing the risk of human error. Traditional medicine boxes often rely on manual sorting, usually only one sorting process, lack of additional confirmation mechanism, and prone to errors.

[0054] 3. Raspberry Pi 4B is used as the main control module, and peripherals are connected through the general input and output ports. The peripheral circuit consists of stepper motors, CSI cameras, voice modules, audio players, and photoelectric sensors. In order to achieve remote communication, the MQTT protocol is used to connect to the IoT cloud platform. WeChat applet is used for user interaction. It realizes safe storage of drugs, automatic dispensing, timed reminders, drug detection, real-time query, remote configuration functions, etc., to solve the problems of single functions, poor practicality, and complex operation of various medicine boxes on the market. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a schematic diagram of the appearance and structure of a smart medicine box and system based on Raspberry Pi;

[0056] Figure 2 This is a schematic diagram of the structure inside the medicine barrel of a smart medicine box and system based on Raspberry Pi;

[0057] Figure 3A cross-sectional diagram of a smart medicine box based on Raspberry Pi and multiple medicine barrels of the system;

[0058] Figure 4 It is a gap diagram of a smart medicine box and system based on Raspberry Pi;

[0059] Figure 5 A top view of a smart medicine box based on Raspberry Pi and a medicine box of the system;

[0060] Figure 6 A side view of a smart medicine box based on Raspberry Pi and a medicine box dispensing part of the system;

[0061] Figure 7 This is a Raspberry Pi-based smart medicine box and system medicine dispensing flow chart;

[0062] Figure 8 It is a drug testing flow chart of a smart medicine box and system based on Raspberry Pi;

[0063] Fig. 9 This is a system framework diagram of a smart medicine box and system based on Raspberry Pi;

[0064] Fig.10 It is a communication flow chart of a smart medicine box and system based on Raspberry Pi;

[0065] Fig.11 This is a voice interaction flow chart of a smart medicine box and system based on Raspberry Pi;

[0066] The numbers in the figure represent in sequence: 1-rotating axis, 2-drug dispensing barrel, 3-housing, 4-drug box, 5-conical slope, 6-pin, 7-pin hole, and preset drug outlet channel, there are at least two drug outlet channels, and the figure shows the situation of 4 drug outlet channels, only two drug outlet channels are marked, namely 8-second drug outlet channel, 9-first drug outlet channel, 10-baffle groove, 11-lower part of drug dispensing, 12-baffle, 13-opposite photoelectric sensor, 14-drug outlet, 15-CSI camera, 16-servo, 17-drug outlet selection port, 18-upper part of drug dispensing. DETAILED DESCRIPTION

[0067] The present invention is further described in detail below in conjunction with specific embodiments.

[0068] See also Figure 1-6 A smart medicine box based on Raspberry Pi includes: a rotating shaft 1, a medicine dispensing barrel 2, a shell 3, a medicine taking box 4, a conical inclined plane 5, a card pin 6, a card pin hole 7, a first medicine dispensing channel 9, a second medicine dispensing channel 8, a baffle groove 10, a medicine dispensing lower part 11, a baffle 12, a photoelectric sensor 13, a medicine dispensing port 14, a CSI camera 15, a steering gear 16, a medicine dispensing selection port 17, and a medicine dispensing upper part 18;

[0069] Specifically, Figure 1 As shown, in this embodiment, the inner wall of the shell 3 is evenly provided with four medicine dispensing barrels 2, and the bottom of the outer wall of the shell 3 is provided with an opening, into which the medicine box 4 can be placed;

[0070] like Figure 2 As shown, each medicine dispensing barrel 2 is composed of a rotating shaft 1, a conical inclined surface body 5, a medicine dispensing selection port 17, a clamping needle 6, a clamping needle hole 7, a medicine dispensing upper part 18, a medicine dispensing lower part 11, and a baffle groove 10. The rotating shaft 1 sequentially penetrates and connects the conical inclined surface body 5, the medicine dispensing upper part 18, the baffle groove 10, and the medicine dispensing lower part 11;

[0071] A locking pin 6 is provided at the bottom of the conical bevel body 5. In this embodiment, four locking pin holes 7 are evenly provided at the top of the medicine dispensing upper part 18. The locking pin 6 is located behind the medicine dispensing selection port 17, and the locking pin hole 7 is located behind the medicine dispensing channel. By inserting the locking pin 6 into the locking pin hole 7, the conical bevel body 5 is locked with the medicine dispensing upper part 18 and the medicine dispensing lower part 11.

[0072] The edge of the conical bevel body 5 is provided with a drug outlet selection port 17. When a drug is put into the conical bevel body 5, it will naturally fall to the bottom due to gravity. By rotating the rotating shaft 1, the drug falls to the drug outlet channel at the upper part of the drug dispensing part. The rotating shaft 1 is manually rotated to drive the conical bevel body 5, so that the drug outlet selection port 17 matches the drug outlet channel, and the card needle 6 is inserted into the card needle hole 7 for fixing.

[0073] like Figure 3 As shown, the medicine dispensing upper part 18 and the medicine dispensing lower part 11 are provided with grooves, and the size specifications of the grooves may be inconsistent, corresponding to medicines of different shapes, and when the grooves of corresponding specifications of the medicine dispensing upper part 18 and the medicine dispensing lower part 11 are combined together to form a medicine outlet channel;

[0074] like Figure 5 As shown, the medicine dispensing lower part 11 is provided with a medicine outlet 14, and the medicine dispensing lower part is driven by the rotating shaft 1, so that the medicine in the medicine dispensing lower part falls to the medicine outlet 14, and the medicine in the medicine dispensing channel of the medicine dispensing upper part 18 is blocked by the baffle, and the medicine dispensing upper part 18 is driven by the rotating shaft, so that the medicine in the medicine dispensing channel of the medicine dispensing upper part falls to the medicine dispensing channel of the medicine dispensing lower part 11;

[0075] The baffle groove 10 is provided in the medicine dispensing upper part 18 and the medicine dispensing lower part 11, and the baffle 12 is installed in the baffle groove 10, the purpose is to prevent all the medicines in the medicine dispensing channel from falling; the conical inclined plane body 5, the medicine dispensing upper part 18 and the medicine dispensing lower part 11 are driven by the rotating shaft 1, so that the medicine enters the medicine dispensing channel from the medicine dispensing selection port 17; through continuous rotation, the medicine in the medicine dispensing channel gradually accumulates, and when the medicine dispensing channel passes through the medicine dispensing port, the medicine in the medicine dispensing lower part 11 falls into the medicine dispensing box 4; because the baffle 12 is provided in the baffle groove 10 just above the medicine dispensing port 14, the medicine in the medicine dispensing upper part 18 will fall onto the baffle, and will not enter the medicine dispensing channel of the medicine dispensing lower part 11;

[0076] like Figure 4 As shown, the area of ​​the baffle 12 is smaller than the bottom area of ​​the medicine dispensing barrel 2, and the gap formed is only enough to pass one medicine, which can be in the shape of a capsule or a granule. When the baffle groove 10 is above the non-drug outlet, there is no baffle 12 to block it. By rotating, when a medicine in the medicine outlet channel in the medicine dispensing upper part 18 falls to the medicine outlet lower part 11, it rotates again, so that the medicine outlet channel in the medicine dispensing upper part 18 is misaligned with the gap formed by the baffle 12 and the medicine dispensing barrel 2, the size of the gap is reduced, and the medicine no longer falls. When the medicine outlet channel of the medicine dispensing lower part 11 passes through the medicine outlet 14, the medicine falls into the medicine box 4, and the above steps are repeated to achieve the single medicine drop;

[0077] Figure 6 As shown, a photoelectric sensor 13 is provided below the medicine outlet 14. In this embodiment, there are four photoelectric sensors 13. A CSI camera 15 is provided at the bottom of the medicine dispensing barrel 2.

[0078] The process of dispensing medicine is as follows Figure 6 As shown;

[0079] like Figure 7 As shown, an intelligent system based on Raspberry Pi includes the following steps:

[0080] S1, put the medicine into the medicine box 4, and use the upper CSI camera 15 to take pictures and samples;

[0081] S2. Obtain the grayscale mean value in the layer channel of each drug after photo sampling through the Raspberry Pi main control board. The specific steps are as follows:

[0082] S2.1. Use the Raspberry Pi main control board to perform layer separation on the photo to obtain the red layer, green layer, and blue layer respectively;

[0083] S2.2, using edge detection algorithm to detect the outline of the drug for each layer, and calculating the grayscale mean of the pixels within the outline;

[0084] S2.3. The calculated grayscale mean will be used as a training sample.

[0085] The training sample is represented as (x i ,y i ),i=1,2,3,…,n, where, y i is the type of drug, x i Testing samples;

[0086] S3, taking the grayscale mean in the layer channel of each drug as a training sample;

[0087] S4, such as Figure 8 As shown, a support vector machine algorithm is established, and the support vector machine algorithm is trained using training samples;

[0088] The support vector machine algorithm solves the maximum spacing hyperplane for the learning samples, and when they are linearly separable, finds the optimal classification hyperplane for two types of samples in the original space;

[0089] When the samples are not linearly separable, a slack variable is added and the samples of the low-dimensional input space are mapped to the high-dimensional space by using nonlinear mapping to make them linearly separable. In this way, the optimal classification hyperplane can be found in the feature space. This optimal classification hyperplane is the maximum spacing hyperplane. The key to SVM is to maximize this spacing to achieve effective classification.

[0090] The hyperplane is a geometric object with one dimension lower than the data space; specifically, the hyperplane is mathematically a (p-1)-dimensional plane, where p is the dimension of the data space, so the hyperplane is not necessarily a two-dimensional plane;

[0091] The specific steps of establishing a support vector machine algorithm and using training samples to train the support vector machine algorithm are as follows:

[0092] S4.1. Obtain the linear equation of the optimal hyperplane based on the training samples. The specific expression is as follows:

[0093] w T x+b=0

[0094] In the formula, w represents the hyperplane normal vector, b represents the intercept, T represents the training sample, and x represents the new input;

[0095] The training sample is {(x 1 ,y 1 ),(x 2 ,y 2 ),…,(x n ,y n ),}, where y i ∈{1,-1}, that is, the output of the function. To get a new input x, we need to infer y iIs it 1 or -1? We can define a decision function g(x)=sgn(f(x)), where sgn(f(x)) is a sign function, that is, it takes the value 1 when f(x)≥0, otherwise it takes the value -1. The linear equation of the optimal hyperplane is:

[0096] f(x)=w T ·x+b

[0097] In the formula, w represents the hyperplane normal vector, b represents the intercept, T represents the training sample, and x represents the new input;

[0098] S4.2. The optimal hyperplane is determined by determining the hyperplane normal vector w and the intercept b, and the problem is transformed. In this case, all training samples are required to satisfy |f(x)|≥1. When f(x)=1, it means that the sample is closest to the hyperplane.

[0099] Therefore, the correctly classified samples can be expressed as y i (w T ·x i +b)-1≥0,i=1,2,3,…,n, n represents the number of samples;

[0100] When the training sample satisfies y i (w T ·x i +b)-1=0, the training sample is called a "support vector"; and at this time, w T The hyperplane where x+b=1 is called the first hyperplane h 1 and satisfy w T The hyperplane where x+b=-1 is called the second hyperplane h 2 ,h 1 and h 2 They are collectively called support hyperplanes. They support two types of data respectively, and are located at h 1 and h 2 The hyperplane in the middle is the best choice to separate the two types of data. The distance between the two supporting hyperplanes is called "interval", represented by r. It can be said that one of the core of SVM is to maximize the interval r. The expression of r is:

[0101]

[0102] At this point, solving the hyperplane problem can be simplified to "find the minimum value of w, that is, make The Lagrange function is introduced to solve the problem of "minimum value". Among them, a i represents the Lagrange multiplier, ai=(a 1 ...a n ) T ∈R, and ai ≥0, take the partial derivative of the Lagrange function L(w,b,a) with respect to w and b and make it equal to 0. The specific expression is as follows:

[0103]

[0104] S4.3. Substitute the Lagrange function L(w,b,a) for the partial derivative of w and b into In the equation, eliminating w and b, we can get the Lagrange dual expression, which is as follows:

[0105]

[0106] Solve for a i The optimal solution Then solve for w * and b * , the specific expression is as follows:

[0107]

[0108] At this point, the SVM classification function can be obtained, and the specific expression is as follows:

[0109]

[0110] Classify unknown test sample data points through SVM classification function;

[0111] S5. Use the Raspberry Pi main control board to save photos of different types of medicines, record the names of the medicines, and upload them to the cloud platform;

[0112] like Fig. 9 , Fig.10 As shown, the MQTT communication protocol is adopted. The Raspberry Pi main control board transmits data to the device cloud, that is, the Alibaba Cloud platform, in the form of publishing topics, and obtains data through the device cloud subscription topic. The mobile terminal, that is, the WeChat applet obtains the uploaded data stream through the device cloud subscription topic, and issues instructions through the publishing topic to transmit it to the Raspberry Pi main control board through the device cloud, so as to realize the information exchange between the publishing topic of the Raspberry Pi main control board and the subscription topic of the mobile terminal, and the information exchange between the subscription topic of the Raspberry Pi main control board and the publishing topic of the mobile terminal;

[0113] like Fig.11 As shown, further, after the drug test is completed, the voice module starts to play the medication reminder. The user needs to say "open the medicine box" to the voice module to stop the medication reminder, and the servo behind the medicine box rotates 180°, and the medicine box can be taken out. After taking the medicine, the user needs to say "I have taken the medicine" to the voice module, and the Raspberry Pi will record the medication time and upload it to the server for the mobile terminal to obtain the medication record.

Claims

1. A smart medicine box based on Raspberry Pi, characterized in that: include: A rotating shaft (1), a medicine dispensing barrel (2), a housing (3), a medicine dispensing box (4), a conical inclined plane (5), a card pin (6), a card pin hole (7), and a preset medicine dispensing channel, wherein the medicine dispensing channel comprises at least two, a baffle groove (10), a medicine dispensing lower part (11), a baffle (12), a photoelectric sensor (13), a medicine dispensing port (14), a CSI camera (15), a steering gear (16), a medicine dispensing selection port (17), and a medicine dispensing upper part (18), wherein at least four medicine dispensing barrels (2 ), each medicine dispensing barrel (2) is composed of a rotating shaft (1), a conical inclined surface body (5), a medicine dispensing selection port (17), a clamping needle (6), a clamping needle hole (7), a medicine dispensing upper part (18), a medicine dispensing lower part (11), and a baffle groove (10), and the rotating shaft (1) sequentially penetrates and connects the conical inclined surface body (5), the medicine dispensing upper part (18), the baffle groove (10), and the medicine dispensing lower part (11), and an opening is opened at the bottom of the outer wall of the shell (3), and a medicine dispensing box (4) can be placed therein, and a steering gear (16) is arranged next to the medicine dispensing box (4).

2. The smart medicine box based on Raspberry Pi according to claim 1, characterized in that: A locking pin (6) is provided at the bottom of the conical bevel body (5), and a number of locking pin holes (7) equal to the number of drug outlet channels are evenly arranged at the top of the drug dispensing upper part (18). By inserting the locking pins (6) into the locking pin holes (7), the conical bevel body (5) is locked with the drug dispensing upper part (18) and the drug dispensing lower part (11).

3. The smart medicine box based on Raspberry Pi according to claim 1, characterized in that: The edge of the conical inclined surface (5) is provided with a medicine discharging selection port (17).

4. The smart medicine box based on Raspberry Pi according to claim 1, characterized in that: The outer wall of the medicine dispensing upper part (18) is provided with at least two medicine dispensing channels, and the medicine dispensing channels are located in front of the needle hole. The outer wall of the medicine dispensing lower part (11) is also provided with at least two medicine dispensing channels. By rotating the medicine dispensing upper part (18), medicine dispensing channels of different sizes correspond to each other one by one.

5. The smart medicine box based on Raspberry Pi according to claim 1, characterized in that: The medicine dispensing upper part (18) and the medicine dispensing lower part (11) are provided with a baffle groove (10), and a baffle (12) is installed in the baffle groove (10). The area of ​​the baffle (12) is smaller than the bottom area of ​​the medicine dispensing barrel 2, forming a gap to allow medicine to pass through.

6. The smart medicine box based on Raspberry Pi according to claim 1, characterized in that: The medicine outlet (14) is arranged below the medicine dispensing lower part (11), and each medicine outlet (14) is provided with a photoelectric sensor (13) below, and a CSI camera (15) is provided at the center of the bottom of the medicine dispensing barrel 2.

7. An intelligent system based on Raspberry Pi, characterized in that: The following steps are involved: S1. Put the medicine into the medicine box (4) and use the CSI camera (15) on the top to take pictures and samples; S2. Obtain the grayscale mean value in the layer channel of each drug after photographing and sampling through the Raspberry Pi main control board; S3, taking the grayscale mean in the layer channel of each drug as a training sample; S4, establishing a support vector machine algorithm, and using training samples to train the support vector machine algorithm; S5. Use the Raspberry Pi main control board to save photos of different types of medicines, record the names of the medicines, and upload them to the cloud platform.

8. The intelligent system based on Raspberry Pi according to claim 7, characterized in that: The method of obtaining the grayscale mean value in the layer channel of each drug after photographing and sampling by Raspberry Pi specifically includes the following steps: S2.

1. Use the Raspberry Pi main control board to perform layer separation on the photo to obtain the red layer, green layer, and blue layer respectively; S2.2, using edge detection algorithm to detect the outline of the drug for each layer, and calculating the grayscale mean of the pixels within the outline; S2.

3. The calculated grayscale mean will be used as a training sample.

9. The intelligent system based on Raspberry Pi according to claim 7, characterized in that: The specific expression of the support vector machine algorithm is as follows: In the formula, w represents the hyperplane normal vector, b represents the intercept, T represents the training sample, and x represents the new input. represents the optimal Lagrange multiplier, b * represents the optimal intercept solution, y i is the type of drug, x i Detection sample, sng[f(x)] represents the symbol function.