Close
0%
0%

Detecting COVID-19 with OpenCV Classifiers

PC, Raspberry Pi and Jetson Nano: 1) Detecting COVID-19 in X-ray with OpenCV; and 2) Detecting COVID-19 Virus Cells with OpenCV

Public Chat
Similar projects worth following
Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The disease was first identified in December 2019 in Wuhan, the capital of China's Hubei province, and has since spread globally, resulting in the ongoing 2019–20 coronavirus pandemic. Common symptoms include fever, cough, and shortness of breath mainly. https://en.wikipedia.org/wiki/Coronavirus_disease_2019

The time from exposure to onset of symptoms is typically around five days but may range from two to fourteen days. While the majority of cases result in mild symptoms, some progress to viral pneumonia and multi-organ failure. To make this project I was inspired by the next work: https://www.pyimagesearch.com/2020/03/16/detecting-covid-19-in-x-ray-images-with-keras-tensorflow-and-deep-learning/

Goals:

  • 1 --> Make the Classifier: covid-x-ray.xml
  • 2 --> Make the Classifier: covid-virus.xml
  • 3 --> Testing the Classifiers on the PC
  • 4 --> Testing the Classifiers on the Raspberry Pi 3B+
  • 5 --> Testing the Classifiers on the NVIDIA Jetson Nano Kit

1.- Make the Classifier: covid-x-ray.xml

Referencehttps://github.com/sauhaardac/Haar-Training/tree/master/training

We can make our own classifiers for recognition of lungs damaged by COVID-19 virus cells. Following are the steps covered in the next sections to be successful in your classifier.

  • A --> Collecting Image Database
  • B --> Arranging Negative Images
  • C --> Crop & Mark Positive Images
  • D --> Creating a vector of positive images
  • E --> Haar-Training
  • F --> Creating the XML File

Notes: 1) In the download section you can get all the files that I will mention below, or you can do click here: https://github.com/guillengap/covid-19-opencv ; and 2) Once downloaded, we will use the files shown in the folder: Y-ray

--> Step A: Collecting Image Database

I recommend you to collect 100 positive images and 100 negative images at last. I suggest you check out https://github.com/ieee8023/covid-chestxray-dataset

The positive images are those images that contain the object (e.g. lungs damaged), and negatives are those ones which do not contain the object . Having more number of positive and negative images will normally cause a more accurate classifier.

Negative images
Negative images
Positive images
Positive images

--> Step B: Arranging Negative Images

Put your background images in folder …\training\negative and run the batch file:

create_list.bat

Running this batch file, you will get a text file each line looks as below:

Bg file
                                                              bg file

Later, we need this negative data file for training the classifier.

--> Step C: Crop & Mark Positive Images

We continue with Objectmaker which is straight forward.

In folder ..\training\positive\rawdata put you positive images

In folder ..\training\positive there is a file objectmaker.exe that we need it for marking the objects in positive images.

How to mark objects? Running the file objectmaker.exe you will see two windows like below: one shows the loaded image, and the other one shows the image name.

Click at the top left corner of the object area, and hold the mouse left-key down. While keeping the left-key down, drag the mouse to the bottom right corner of the object.

Now you could be able to see a rectangle that surrounds the object. If you are not happy with your selection press any key (except Spacebar and Enter) to undo your selection, and try to draw another rectangle again.

If you are happy with the selected rectangle, press SPACE. After that, the rectangle position and its size will appear on the left window.

Repeat steps if there are multiple objects in the current folder. When you finished with the current image, press ENTER to load the next image.

Repeat steps until the entire positive images load one by one, and finished, and a file named info.txt would be created. Within the info.txt there would be some information like below:

Info file
                              Info file

--> Step D: Creating a vector of positive images

The next step is packing the object images into a vector-file....

Read more »

Virus-Cells.zip

Section 2.- Make the Classifier: covid-virus.xml

x-zip-compressed - 11.62 MB - 05/20/2020 at 22:51

Download

X-ray.zip

Section 1.- Make the Classifier: covid-x-ray.xml

x-zip-compressed - 18.09 MB - 05/20/2020 at 22:42

Download

schematicdiagram_main.jpg

Schematic diagram

JPEG Image - 401.17 kB - 05/20/2020 at 18:58

Preview
Download

covid_virus.xml

Classifier tested on my Windows 10 PC, and my Raspberry Pi 3B+ and Jetson Nano boards.

XML - Extensible Markup Language - 109.83 kB - 05/20/2020 at 18:56

Download

covid_virus.py

Code tested on my Windows 10 PC, and my Raspberry Pi 3B+ and Jetson Nano boards.

py - 384.00 bytes - 05/20/2020 at 18:55

Download

View all 7 files

  • 1 × NVIDIA Jetson Nano Developer Kit
  • 1 × Raspberry Pi 3B+
  • 1 × TFT LCD Touch 2.4" Shield
  • 1 × Battery 5V 2A
  • 1 × Raspberry Pi Keyboard

View all 6 components

  • 1
    Notes:

    Software apps and online services:

    • Raspberry Pi Raspbian
    • OpenCV
    • OpenCV
    • Python 3.7.3 and/or Python 2.7.14
    • Anaconda 2020.02 for Windows Installer
    • NVIDIA JetPack

    Hand tools and fabrication machines:

    • PC Windows 10

View all instructions

Enjoy this project?

Share

Discussions

Anthony Constantinou wrote 05/25/2020 at 12:00 point

Anthony Constantinou says "COVID-19 symtoms, diagnosis and treatment all are available now, though there are no particular medicine or vaccine out there to treat infected person, but with some available medicine and standard treatments, patients get recovered too. Boost your immunity and do follow social distancing, sanitizing and hand-washing regularly."

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates