Cotton Gin Stand Machine-Vision Inspection and Removal System for Plastic Contamination: Software Design
Abstract
:1. Introduction
2. Machine-Vision Plastic Detection–Removal System
- Machine-vision plastic detection system that analyzes each image for plastic and notes the location where plastic was detected.
- Camera-computer node housing that utilizes pneumatic air for cooling and to keep the camera lens clear in the high dust environment of a cotton gin.
- Electronic drivers to convert the embedded processor’s low-voltage, low-current digital input–output signals to 12-volt direct current (VDC) with sufficient current capacity to drive a pneumatic solenoid.
- Manifold of pneumatic solenoids used to provide compressed air to air-knives located at the base of the feeder apron.
- Bank of air-knives that provide a strong burst of air to eject the detected plastic from the main cotton flow.
System Performance as Measured in the Commercial Field Trials
3. Machine-Vision Plastic Detection–Removal Software
3.1. Background Development Tools
- Asynchronous functions responding to events, such as:
- ○
- Completion of image processing,
- ○
- Firing solenoids for plastic-detection events
- ○
- Checking the SQL database for new user-inputs etc.
- QT timers.
3.2. Node Control Interface
3.3. User Interface
3.4. Software Design
- “IPAddress”: holds IP Address of backup database.
- “Run_Classifier”: switch to run classifier builder routine.
- “AddTo_Classifier”: switch to append to an existing classifier, or if “0”, create a new classifier using only images in the classifier build directory (when running classifier builder routine).
- “Use_Air_Knives”: switch to enable actuation of air-knives upon detection of plastic.
- “AirKnife_PulseTest”: turn on routine for testing air-knives (multi-level value that both enables air-knife pulse test as well as instructs which air-knives are triggered during pulse test. This is binary “OR” mapping for each solenoid 1–4 as {sol_1 = 1, sol_2 = 2, sol_3 = 4, sol_4 = 8}. Example for testing sol 3 and 4, the mapping would set AirKnife_PulseTest = 0x0C (in hexadecimal).
- “AirKnife_PulseDelay_ms”: configuration setting that sets how long, in milliseconds, to delay before turning on air-knife after plastic-detection event has occurred.
- “AirKnife_PulseOn_ms”: configuration setting that determines how long air-knife pulse lasts for each plastic-detection event.
- “minBlobSize”: determines how large an area a detected plastic object must be before it is recognized as a valid object to remove via air-knife pulse.
- “Roi_StartX”: left-side x-coordinate, in pixels, in the captured image where pixels are to be analyzed. Forms the left side of the Region-Of-Interest.
- “Roi_StopX”: right-side x-coordinate, in pixels, in the captured image where pixels are to be analyzed. Forms the right-side of the Region-Of-Interest.
- “Roi_StartY”: top-side x-coordinate, in pixels, in the captured image where pixels are to be analyzed. Forms the top side of the Region-Of-Interest.
- “Roi_StopX”: bottom-side x-coordinate, in pixels, in the captured image where pixels are to be analyzed. Forms the bottom-side of the Region-Of-Interest.
- “Gain”: camera gain setting.
- “Exposure”: camera exposure setting.
- “Use_Daylight_ColorBalance”: use camera default Daylight lighting color-balance mode.
- “Use_Fluorescence_ColorBalance”: use camera default Fluorescent lighting color-balance mode.
- “Awb_r”: manual setting for custom white-balance, sets White-balance red-cast.
- “Awb_b”: manual setting for custom white-balance, sets White-balance blue-cast.
- “TimeToSavePic_mins”: number of minutes to save pictures when saving calibration images.
- “Number_of_pics_to_Take”: number of pictures to save, when saving calibration images.
- “Enable_Input_PicCaptures”: switch to save images, uses either “Number_of_pics_to_Take” or “TimeToSavePic_mins” to control how may images are saved.
- “SoftwareStart_PicCaptures”: use software trigger to start pic capture saving routine.
Air-Knife Control
3.5. Lab Color Space
3.6. Negative Classifier Look-Up Table
3.7. Building the Negative Classifier
- Without cotton flowing, capture 10–20 images and then build a “new” classifier (this initial classifier build will add all colors required to allow software to ignore the feeder apron).
- The next step is to set the software to capture 40–60 images or so, at a rate of 1 per second, while cotton is flowing. Once these cotton images are captured, the technician examines each image to ensure no plastic was inadvertently captured in any of these images. Once the cotton image dataset is verified, the build classifier routine is engaged, this time in “append” mode. In append mode the classifier adds in all the cotton colors so that the classifier now also ignores cotton.
- <Optional> If conditions of the cotton changes, becomes yellow-spotted, or has an unusual amount of green-leaf in it or has additional cotton by-products that are causing too many false-positives, step 2 can be re-run to add in these extra-colors to the classifier, thereby tuning the system to avoid these new objects and prevent mis-firing on these false-positive triggers. For ease of use, for every detection event, the software stores both the raw image as well as the binary classified image for later review so that technicians can assess what is causing the false-positive triggering.
- <Optional> The software also has the capability to reduce the active region of interest in the images. This can be useful to employ in case where a pivot seam, or other object in the field of view, is causing false triggers.
3.8. Image Processing for Plastic Detection
- Three stages of dilation–erosion (to fill voids between neighboring lit pixels).
- Median filter (to reject any leftover shot-noise).
- Object clustering using contour analysis.
- Objects were then size-excluded on the basis of a threshold minimum size (Figure 18).
3.9. Image Capture Driver
3.10. Open-Source Libraries
- OpenCV (machine-vision library; originally written by Intel Corp. Research).
- WiringPi (provides high-speed C++ interface library utilized to control BCM2711 digital output ports that were used as inputs to a custom electronics solenoid driver board; artwork is shown in Figure 15. A separate manuscript will follow this paper, describing the electronic sub-system).
4. Software Design Summary
Conclusions
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Appendix A. Database Command Variables, Used to Control Software
References
- Pelletier, M.G.; Holt, G.A.; Wanjura, J.D. A Cotton Module Feeder Plastic Contamination Inspection System. AgriEngineering 2020, 2, 280–293. [Google Scholar] [CrossRef]
- Devine, J. (Cotton Incorporated Economist, Cary, NC, USA). Interview Conducted, 6 January 2020.
- Barnes, E.; Morgan, G.; Hake, K.; Devine, J.; Kurtz, R.; Ibendahl, G.; Sharda, A.; Rains, G.; Snider, J.; Maja, J.M.; et al. Opportunities for Robotic Systems and Automation in Cotton Production. AgriEngineering 2021, 3, 339–362. [Google Scholar] [CrossRef]
- Blake, C. Plastic Contamination Threatens U.S. Cotton Industry; Southwest Farm Press: Irving, TX, USA, 2013; Available online: https://www.farmprogress.com/node/319085 (accessed on 5 July 2020).
- Adams, G. A Very Serious Matter. Cotton Farming. 3 August 2017. Available online: https://www.cottonfarming.com/cottons-agenda/a-very-serious-matter/ (accessed on 5 July 2020).
- Ramkumar, S. Plastic Contamination Not Just a Cotton Problem. Cotton Grower. 13 September 2018. Available online: https://www.cottongrower.com/opinion/plastic-contamination-not-just-a-cotton-problem/ (accessed on 5 July 2020).
- O’Hanlan, M. With Cotton Harvest Underway, FARMERS fear Grocery Bags, Plastic Contamination. Victoria Advocate. 25 August 2019. Available online: https://www.victoriaadvocate.com/news/local/with-cotton-harvest-underway-farmers-fear-grocery-bags-plastic-contamination/article_9f8c90b0-c438-11e9-9c61-03c92ae351a7.html (accessed on 5 July 2020).
- Adams, G. A Reputation at Stake. Cotton Farming. 1 October 2019. Available online: https://www.cottonfarming.com/cottons-agenda/a-reputation-at-stake/ (accessed on 5 July 2020).
- Pelletier, M.G.; Holt, G.A.; Wanjura, J.D. A Plastic Contamination Image Dataset for Deep Learning Model Development and Training. AgriEngineering 2020, 2, 317–321. [Google Scholar] [CrossRef]
- QT Company. QT Version 5.5; QT Group Plc: Helsinki, Finland, 2014; Available online: https://www.qt.io (accessed on 6 August 2019).
- Schanda, J. Colorimetry Understanding the CIE System; Wiley-Interscience; John Wiley & Sons, Inc.: Hoboken, NJ, USA, 2007; p. 61. ISBN 978-0-470-04904-4. [Google Scholar]
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Pelletier, M.G.; Holt, G.A.; Wanjura, J.D. Cotton Gin Stand Machine-Vision Inspection and Removal System for Plastic Contamination: Software Design. AgriEngineering 2021, 3, 494-518. https://doi.org/10.3390/agriengineering3030033
Pelletier MG, Holt GA, Wanjura JD. Cotton Gin Stand Machine-Vision Inspection and Removal System for Plastic Contamination: Software Design. AgriEngineering. 2021; 3(3):494-518. https://doi.org/10.3390/agriengineering3030033
Chicago/Turabian StylePelletier, Mathew G., Greg A. Holt, and John D. Wanjura. 2021. "Cotton Gin Stand Machine-Vision Inspection and Removal System for Plastic Contamination: Software Design" AgriEngineering 3, no. 3: 494-518. https://doi.org/10.3390/agriengineering3030033