<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>O. Petryk); oleg.pastuh@gmail.com (O. Pastukh)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>A system for monitoring self-tests for COVID-19 using neural convolutional deep networks</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Mykhaylo Petryk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oleksiy Tsebriy</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yurii Stoianov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oksana Petryk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oleh Pastukh</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Ternopil Ivan Puluj National Technical University</institution>
          ,
          <addr-line>Ruska 56 46000 Ternopil, Urkaine</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2024</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0001</lpage>
      <abstract>
        <p>The development methods are based on tools such as FastAPI, HTML, and Python, which guarantees efficient processing and analysis of biological data. The results of the work include algorithms and software implementation of a web application for self-testing for COVID-19 and a mobile application for the Android platform. The system is characterized by high accuracy and efficiency in determining test results, which makes it potentially useful for a wide range of medical research and improving biological sample collection systems.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;convolutional neural networks</kwd>
        <kwd>covid-19</kwd>
        <kwd>yolov5</kwd>
        <kwd>mediapipe face mesh</kwd>
        <kwd>fastapi1</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Automated collection of biological samples becomes particularly relevant in pandemic and
epidemic scenarios, particularly during the spread of COVID-19. Fast and effective detection
of infections and diseases is a key task for global health. The successful implementation of this
task directly affects the quality of medical diagnostics, allowing for timely detection of
diseases and effective treatment. Automating the sample collection process can significantly
improve accuracy and reduce the risk of errors, which is critical for medicine.</p>
      <p>The use of computer vision and machine learning technologies, such as MediaPipe Face
Mesh and YOLOv5, not only automates the sample collection process but also ensures high
accuracy and reliability of the results. This is especially important for the swabbing procedure,
which plays a key role in the diagnosis of diseases. Automation of this process not only
ensures patient safety and comfort but also significantly reduces the time of medical
intervention.</p>
      <p>In the global context, automation and the introduction of artificial intelligence are
important trends in medicine. These technologies are changing approaches to treatment and
diagnostics, making them more efficient and accessible. The main challenge remains
improving the accuracy of detectors and integrating the latest technologies with medical
practice. In this context, the introduction of new algorithms and methods for collecting
biological samples is of considerable practical value.</p>
      <p>The purpose of this work is to develop an innovative approach to the automated collection
of biological samples using advanced technologies that will increase the efficiency of
diagnostics and improve the quality of medical research.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Overview of the Subject Area</title>
      <p>
        This study takes a comprehensive approach that combines technological and scientific
methods to develop and improve an automated biological sample collection system [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>
        One example of automated biological sample collection is the use of an algorithm to detect
a smear in an image. This algorithm utilizes advanced technologies such as MediaPipe Face
Mesh [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] for face and nasal feature detection, YOLOv5 [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] for smear detection in an image,
OpenCV [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] for white line analysis in the region of interest, and Shapely [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] for nasal feature
polygon construction.
      </p>
      <p>
        Many works focus on the development of algorithms for detecting and classifying
biological objects in images, including smears. The use of deep learning methods, such as
convolutional neural networks (CNNs), has shown high accuracy in identifying various
elements in images, providing a basis for further research. But there are also challenges. For
example, the problem of determining the correctness of biological sample collection remains
relevant. Some works consider techniques for determining the angles and position of the face,
which can affect the detection accuracy. Studies [
        <xref ref-type="bibr" rid="ref6 ref7">6,7</xref>
        ] reveal key aspects of biological sample
collection and can serve as a foundation for further development and improvement of
methods in the field of automated biological sample collection.
      </p>
      <p>
        The MediaPipe Face Mesh library was used to detect landmarks face and nose elements [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
The object-oriented model YOLOv5 is used to detect swipe objects in images. OpenCV
functions are used for image processing and analysis: special attention is paid to the use of
Canny and HoughLinesP filtering to determine the contours of the swab and detect its end.
The Shapely library was used to create polygons and for creating polygons and interacting
with geometric objects.
      </p>
      <p>Methods for creating and comparing polygons to assess the correctness of swab insertion
into the nostril:
1. Data collection and processing. This includes collecting images from different angles,
and manual labeling of key elements (face, nose, tip of the swab).
2. Analysis and selection of algorithms. Evaluation. MediaPipe Face Mesh and YOLOv5
for face and swipe detection, and optimization of image processing through OpenCV
image processing via OpenCV.
3. Development and testing. Implementation of algorithms for searching face and swipe
detection in real-time, validation using real samples.
4. Integration and optimization. Combining algorithms into a system, optimization for
stable operation.
5. Validation and testing. Comparison of results with alternative methods, and testing of
the demo application.
6. Evaluation of the contribution. Analysis of the impact of algorithms on the process of
collecting on the process of collecting biospecimens.
7. Ethical aspects. Ensuring the confidentiality of patient data of patients and compliance
with ethical standards.</p>
      <p>This methodology covers all stages, from data collection to testing and implementation of
the developed algorithms in medical practice.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Methods and Technical Solutions for COVID-19 Test Control</title>
      <p>Methods and technical solutions for the development of an automated biological sample
collection system include the use of MediaPipe Face Mesh and YOLOv5 technologies for face
and swab identification (data labeling was performed using Label Studio). Image optimization
was performed using OpenCV, and the Shapely library was used to work with geometric
objects. These solutions ensure the high accuracy of the system. The interface for user
interaction is based on FastAPI (Fig. 1).</p>
      <p>
        MediaPipe Face Mesh was used to effectively detect the face and nose elements. It has the
main advantage of being able to accurately determine the shape and location of the face in the
image, taking into account its various aspects. This technology is able to detect even subtle
details such as moving facial lines or nose contours[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>Swipe detection with YOLOv5: The YOLOv5 model was used to accurately determine the
position and contour of the swab in the images, which ensured fast and efficient object
detection. Image optimization with OpenCV: OpenCV helped to improve swab tip detection
through Canny and HoughLinesP functions, which allowed to detect the contours and
direction of the swab, increasing detection accuracy. Polygon processing with Shapely: The
Shapely library was used to create and analyze polygons, identifying the nose elements and
the swab tip area, which improved interaction with geometric objects. Integration and
efficiency: The algorithms were integrated into a single system where MediaPipe Face Mesh
was used to determine the face and key points. Optimization of system performance and
stability ensured reliable real-time operation. Image preprocessing focused on the white lines
of the swab. Interaction with the user via FastAPI: FastAPI provided the development of an
intuitive web interface for presenting results and interacting with the system.</p>
      <sec id="sec-3-1">
        <title>3.1. Algorithm design</title>
        <p>The initial stage of the algorithm involves image analysis to determine the position and
orientation of the swab (Fig. 1). For this purpose, YOLOv5 is used to efficiently detect the swab
object in the photo. The YOLOv5 model was trained on an extended dataset that included
different positions and states of the swab.</p>
        <p>The YOLOv5 model is used to detect the swap object, which was previously trained on an
extended dataset.</p>
        <p>The YOLO (You Only Look Once) algorithm provides an efficient and accurate location and
outline of the swab in the image (Figure 2).</p>
        <p>Image preparation and processing: The image is processed to improve the accuracy of
swab detection. For this purpose, the OpenCV library is used to optimize and reduce noise.
The Canny and HoughLinesP methods are used to determine the contours and direction of the
swab (Fig. 2).</p>
        <p>Integration of swap detection results: The results of the swab detection are combined with
the subsequent stages of the algorithm. The coordinates and orientation of the swipe are used
to determine its position in space. Interaction with MediaPipe Face Mesh: The results of swipe
detection are integrated with data from MediaPipe Face Mesh to accurately determine the
relationship between the swipe and the face in the image. Analysis and filtering of results:
The results are analyzed to detect errors and correct unacceptable variants, for example, by
checking the shape and size of the swipe. An integrated algorithm provides high accuracy in
swab detection and positioning, which is critical for automated biological sample collection.</p>
        <p>MediaPipe Face Mesh is used to accurately detect the face and nasal features. Facial
landmarks are used to determine the direction of gaze and the area of the nose where the tip
of the swab should be located (Figure 3). Based on the swab detection and facial landmarks,
the position and orientation of the swab relative to the face and nose are accurately
determined. OpenCV is used to optimize image processing and determine the exact angle of
the swab.</p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Integration and testing</title>
        <p>All components of the algorithm were integrated into a single system and tested on a variety
of images and scenarios. Testing included trying the algorithm on images with different
lighting, angles, and backgrounds. The details of the image pre-filtering to detect the swab
line by emphasizing the white elements are shown in Figure 4.</p>
        <p>
          The results obtained in the process of detecting and collecting biological samples indicate
the high accuracy of the developed algorithm. The performance analysis indicates that the
algorithm is effective even in real-time, even with limited computing resources. Tests of the
algorithm on a variety of images, including variable illumination, different angles of
inclination, and a variety of backgrounds, confirm its stability and reliability in different
conditions [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ].
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions</title>
      <p>The development of the algorithm was an important step in automating the collection of
biological samples, characterized by high efficiency due to extensive data and powerful tools.
YOLOv5, MediaPipe Face Mesh, OpenCV, and Shapely technologies allowed us to create a
system for accurately determining the swab's position in real-time, which is critical for
medical applications.</p>
      <p>These systems have the potential not only to combat COVID-19, but also for diagnostics,
health monitoring, and scientific research. The success of the project opens up opportunities
for further improvement of the algorithms, adaptation to different imaging conditions, and
expansion of functionality.</p>
      <p>The project serves as a basis for future research in medical technology and deep learning,
which can significantly improve diagnostics and monitoring in modern medicine. Our work
demonstrates the potential of using deep learning and computer vision in medicine, and we
hope that this will contribute to the development of automated and accurate biological sample
collection systems.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Krizhevsky</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sutskever</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Hinton</surname>
            ,
            <given-names>G. E.</given-names>
          </string-name>
          <article-title>ImageNet Classification with Deep Convolutional Neural Networks</article-title>
          .
          <source>Advances in neural information processing systems</source>
          .
          <year>2012</year>
          . p.
          <fpage>1097</fpage>
          -
          <lpage>1105</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <article-title>[2] MediaPipe: A Framework for Building Perception Pipelines</article-title>
          . URL: https://google.github.io/mediapipe/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <article-title>[3] YOLOv5: Scalable Object Detection in Image and Video</article-title>
          . URL: https://arxiv.org/abs/2106.09920.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>[4] OpenCV: Open Source Computer Vision Library. URL: https://opencv.org/.</mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>[5] Shapely: Manipulation and analysis of geometric objects</article-title>
          . URL: https://pypi.org/project/Shapely/.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Automated</given-names>
            <surname>Biological Sample</surname>
          </string-name>
          <article-title>Collection using Convolutional Neural Networks: A Review</article-title>
          . URL: https://www.researchgate.net/publication/334417045_Automated_Biological_Sample_
          <article-title>Col lection_using_Convolutional_Neural_Networks_A_Review</article-title>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Goodfellow</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bengio</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Courville</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          <article-title>Deep Learning</article-title>
          . MIT Press.
          <year>2016</year>
          . 775 p.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>He</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhang</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ren</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Sun</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <article-title>Deep Residual Learning for Image Recognition</article-title>
          .
          <source>Proceedings of the IEEE conference on computer vision and pattern recognition</source>
          .
          <year>2016</year>
          . p.
          <fpage>770</fpage>
          -
          <lpage>778</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>LeCun</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bengio</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Hinton</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          <article-title>Deep learning</article-title>
          .
          <source>Nature</source>
          .
          <year>2015</year>
          . Т.
          <volume>521</volume>
          . № 7553. p.
          <fpage>436</fpage>
          -
          <lpage>444</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>