Disclosure of Invention
The invention aims to provide a membrane following guiding control system and method based on opencv, which can reduce the offset direction of a transplanter and damage the situation of ridge shape.
In order to achieve the above object, the present invention provides the following solutions:
the film following guiding control system based on opencv comprises a tobacco seedling transplanter, gear transmission, a servo motor, a control system and a camera, wherein the control system is arranged in front of the tobacco seedling transplanter, the servo motor is connected with a front wheel steering system of the tobacco seedling transplanter through the gear transmission, when the tobacco seedling transplanter works, the camera collects black and white film image information on a ridge in real time and simultaneously transmits the image information to the control system, and the control system adjusts the posture of the transplanter according to the image information to realize the ridge following guiding.
Optionally, the device further comprises a servo driver, wherein the servo driver is connected with the servo motor.
Optionally, the servo driver comprises a power supply, and the power supply is connected with the servo driver and the control system respectively.
Optionally, the control system employs raspberry group 5b.
Optionally, the power of the servo motor is 400w, and the voltage is 48v.
Optionally, the control system adjusts the posture of the transplanter according to the image information, so as to realize guiding along with ridges, and specifically comprises:
Obtaining a pulse width modulation signal according to the image information through a membrane following guiding control algorithm;
Controlling the servo motor to rotate according to the pulse width modulation signal;
And the servo motor rotates to drive the gear to drive, so that the posture of the transplanter is adjusted, and the guiding along with ridges is realized.
In order to achieve the above purpose, the present invention also provides the following solutions:
the membrane following guiding control method based on opencv comprises the following steps:
acquiring black and white film image information;
Obtaining a running result of the tobacco seedling transplanting machine according to the image information, wherein the running result comprises left deviation of running of the tobacco seedling transplanting machine, normal running of the tobacco seedling transplanting machine and right deviation of running of the tobacco seedling transplanting machine;
A film following guiding control algorithm is adopted according to the running result of the tobacco seedling transplanting machine, and a pulse width modulation signal is obtained;
and controlling the servo motor and the driving gear to work according to the pulse width modulation signal, and controlling the tobacco seedling transplanter to automatically turn right or adjust the gesture in a left-hand or right-hand manner so as to realize guiding along ridges.
Optionally, according to the image information, obtaining a running result of the tobacco seedling transplanter specifically includes:
setting a middle point in the middle of the whole image;
the positions of the two identified white membrane boundary points are converted, and then vertical lines are drawn to serve as a left boundary and a right boundary;
Judging the position relationship between the middle point and the left boundary as well as the right boundary to obtain a running result;
when the middle point is larger than the right boundary, determining that the tobacco seedling transplanting machine runs right offset;
When the middle point is between the left boundary and the right boundary, determining that the tobacco seedling transplanting machine runs normally;
and when the middle point is smaller than the left boundary, determining that the tobacco seedling transplanting machine runs left offset.
In order to achieve the above purpose, the present invention also provides the following solutions:
An electronic device includes a memory for storing a computer program and a processor that runs the computer program to cause the electronic device to perform an opencv-based membrane-associated control method.
In order to achieve the above purpose, the present invention also provides the following solutions:
A computer readable storage medium stores a computer program which when executed by a processor implements an opencv-based membrane associated steering control method.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects:
The invention provides a film following guiding control system based on opencv, which comprises a tobacco seedling transplanter, gear transmission, a servo motor, a control system and a camera, wherein the control system is arranged in front of the tobacco seedling transplanter, the servo motor is connected with a front wheel steering system of the tobacco seedling transplanter through the gear transmission, when the tobacco seedling transplanter works, the camera acquires black and white film image information on a ridge in real time and simultaneously transmits the image information to the control system, and the control system adjusts the posture of the transplanter according to the image information so as to realize the film following guiding. The invention can reduce the offset direction of the transplanting machine and damage the situation of ridge shape.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention aims to provide a membrane following guiding control system and method based on opencv, which can reduce the offset direction of a transplanter and damage the situation of ridge shape.
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Fig. 1 is a first structure diagram of a membrane following guiding control system based on opencv, and fig. 2 is a second structure diagram of a membrane following guiding control system based on opencv. As shown in figures 1 and 2, the film following guiding control system based on opencv comprises a tobacco seedling transplanting machine 1, a gear transmission 2, a servo motor 3, a servo driver 4, a power supply 5, a control system 6 and a camera 7, wherein the control system 6 is arranged in front of the tobacco seedling transplanting machine 1, the servo motor 3 is connected with a front wheel steering system of the tobacco seedling transplanting machine 1 through the gear transmission 2, front wheel steering can be directly controlled, when the tobacco seedling transplanting machine 1 works, the camera 7 acquires black and white film image information on a ridge in real time and simultaneously transmits the image information to the control system 6, and the control system 6 adjusts the posture of the transplanting machine according to the image information so as to realize the film following guiding. The servo driver 5 is connected with the servo motor 3. The power supply 5 is connected to the servo driver 3 and the control system, respectively. Fig. 3 is black and white film image information.
The control system 6 adjusts the posture of the transplanter according to the image information to realize guiding along with ridges, and specifically comprises the following steps:
Obtaining a pulse width modulation signal according to the image information through a membrane following guiding control algorithm;
controlling the servo motor 3 to rotate according to the pulse width modulation signal;
the servo motor 3 rotates to drive the gear transmission 2 to adjust the posture of the transplanter, so that the direction along with ridges is realized.
The control system employs raspberry group 5b. The power of the servo motor 3 is 400w and the voltage is 48v. The camera 7 captures the picture of the black and white film on the ridge in real time as shown in the right side of fig. 3, and simultaneously transmits picture information to a raspberry pie, wherein in the raspberry pie, the white film boundary position on the black and white film is firstly obtained by utilizing a vertical large prewitt operator, and the code is as follows:
defbj(img,s=101,bj1=0,bj2=0):
h,w=img.shape
he=np.zeros((h//2,s))
pjtd=np.zeros((2,w),np.float32)
s1=s//2
he[:,:s1]=1
he[:,s1+1:s]=-1
img1=np.zeros((h,w+s1*2))
The vertical large prewitt operator can be accurately positioned to the boundary of the white film under the condition of large noise by utilizing the characteristic features of the black and white film, and the maximum gradient change and the gradient change generated by some noise are reflected in fig. 4. The horizontal position of the two boundaries of the white film in the whole image can reflect the running state of the tobacco seedling transplanting machine 1, and the reflection is further embodied:
1. setting a point in the middle of the whole image;
2. the positions of the two identified white film boundary points are converted, and then vertical lines are drawn to serve as left and right boundaries;
Thus, the tobacco seedling transplanter 1 can be considered to be right-biased when the middle point is greater than the right boundary, the tobacco seedling transplanter 1 can be considered to be normal when the middle point is between the left boundary and the right boundary, and the tobacco seedling transplanter 1 can be considered to be left-biased when the middle point is less than the left boundary, as shown in fig. 5.
At this time, the judgment of the running state of the transplanter is completed, and the judgment information is converted into a PWM signal for controlling the servo motor 3, so that the transplanter can automatically turn right or adjust the posture in a left-hand or right-hand manner, and the ridge-following guiding is realized.
Compared with the prior art, the invention has the following advantages:
1. the control system can automatically guide along with the ridges, compared with the traditional mechanical guide, the control system is not contacted with the ridges, so that the ridges cannot be damaged, and compared with the manual guide, the control system can reduce labor force.
2. Compared with the chassis guidance of GPS navigation, the control system can be used for indoor or greenhouse and other shielded scenes, and normal work cannot be influenced due to signal shielding
3. Compared with an infrared navigation system, the control system can work under the influence of outdoor illumination, and has better adaptability to environmental influence.
4. The control system can be configured on the chassis of other agricultural machinery which works on black-white film ridges, and has certain universality.
Embodiment two:
FIG. 6 is a flow chart of a membrane following guiding control method based on opencv, as shown in FIG. 6, and the membrane following guiding control method based on opencv comprises the following steps:
step 101, obtaining black and white film image information;
102, obtaining a running result of the tobacco seedling transplanter according to the image information, wherein the running result comprises left deviation of running of the tobacco seedling transplanter, normal running of the tobacco seedling transplanter and right deviation of running of the tobacco seedling transplanter;
Step 103, adopting a film following guiding control algorithm according to the running result of the tobacco seedling transplanter to obtain a pulse width modulation signal;
and 104, controlling the servo motor and the driving gear to work according to the pulse width modulation signal, and controlling the tobacco seedling transplanter to automatically turn right or adjust the gesture in a left-hand or right-hand manner so as to realize ridge-following guiding.
The step 102 specifically includes:
Step 1021, setting a middle point in the middle of the whole image;
step 1022, transforming the positions of the two identified white film boundary points, and drawing vertical lines to serve as a left boundary and a right boundary;
Step 1023, judging the position relationship between the middle point and the left boundary and the right boundary to obtain a running result;
when the middle point is larger than the right boundary, determining that the tobacco seedling transplanting machine runs right offset;
When the middle point is between the left boundary and the right boundary, determining that the tobacco seedling transplanting machine runs normally;
and when the middle point is smaller than the left boundary, determining that the tobacco seedling transplanting machine runs left offset.
Embodiment III:
The present embodiment provides an electronic device, including a memory and a processor, where the memory is configured to store a computer program, and the processor runs the computer program to enable the electronic device to execute the opencv-based membrane associated guidance control method of the second embodiment.
Alternatively, the electronic device may be a server.
In addition, the embodiment of the invention also provides a computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the film following guiding control method based on opencv of the second embodiment is realized.
Embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
The principles and embodiments of the present invention have been described herein with reference to specific examples, which are intended to facilitate an understanding of the principles and concepts of the invention and are to be varied in scope and detail by persons of ordinary skill in the art based on the teachings herein. In view of the foregoing, this description should not be construed as limiting the invention.