Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • akhot2/group-01-phys371-sp2023
  • jl190/group-1-beetle-drone
2 results
Show changes
Commits on Source (17)
  • jl190's avatar
    Upload New File · e92dd32f
    jl190 authored
    e92dd32f
  • fresleven's avatar
    decrease unneeded images · 3e26243a
    fresleven authored
    3e26243a
  • akhot2's avatar
    Update file README.md · a236ddd1
    akhot2 authored
    a236ddd1
  • akhot2's avatar
    Update 3 files · 95855067
    akhot2 authored
    - /transfer/transfer.py
    - /crop/README.md
    - /Assemblies and Hardware/README.md
    95855067
  • akhot2's avatar
    Update file README.md · 32dfbb77
    akhot2 authored
    32dfbb77
  • akhot2's avatar
    Update 5 files · 19c4624b
    akhot2 authored
    - /crop/crop.ipynb
    - /Assemblies and Hardware/README.md
    - /crop/autocrop_folder.py
    - /crop/README.md
    - /README.md
    19c4624b
  • akhot2's avatar
    Update file README.md · 043a7fc4
    akhot2 authored
    043a7fc4
  • akhot2's avatar
    Update 14 files · c16eff7b
    akhot2 authored
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/10 beetles shadow + dirtier 2.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/10 beetles shadow + dirtier.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/10 beetles sun + dirtier 2.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/10 beetles sun+ dirtier.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/5 beetles (SUN).JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/5 beetles (not full grid).JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/6 beetles (1).JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/6 beetles dirt + shadow 2.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/6 beetles dirt + shadow.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/6 beetles dirt + sun.JPG
    - /yolov5_model/runs/detect/arduino_640_yolov5x_img1280/6 beetles.JPG
    - /README.md
    - /crop/README.md
    - /yolov5_model/runs/detect/README.md
    c16eff7b
  • akhot2's avatar
    Update 47 files · bf9a0a3d
    akhot2 authored
    - /yolov5_model/runs/val/wrong_1beetle/F1_curve.png
    - /yolov5_model/runs/val/wrong_1beetle/PR_curve.png
    - /yolov5_model/runs/val/wrong_1beetle/P_curve.png
    - /yolov5_model/runs/val/wrong_1beetle/R_curve.png
    - /yolov5_model/runs/val/wrong_1beetle/confusion_matrix.png
    - /yolov5_model/runs/val/wrong_1beetle/val_batch0_labels.jpg
    - /yolov5_model/runs/val/wrong_1beetle/val_batch0_pred.jpg
    - /yolov5_model/runs/val/wrong_1beetle/val_batch1_labels.jpg
    - /yolov5_model/runs/val/wrong_1beetle/val_batch1_pred.jpg
    - /yolov5_model/runs/val/wrong_1beetle/val_batch2_labels.jpg
    - /yolov5_model/runs/val/wrong_1beetle/val_batch2_pred.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/F1_curve.png
    - /yolov5_model/runs/val/many_small_bugs_final/PR_curve.png
    - /yolov5_model/runs/val/many_small_bugs_final/P_curve.png
    - /yolov5_model/runs/val/many_small_bugs_final/R_curve.png
    - /yolov5_model/runs/val/many_small_bugs_final/confusion_matrix.png
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch0_labels.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch0_pred.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch1_labels.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch1_pred.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch2_labels.jpg
    - /yolov5_model/runs/val/many_small_bugs_final/val_batch2_pred.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/weights/best.pt
    - /yolov5_model/runs/train/many_small_bugs_final/weights/last.pt
    - /yolov5_model/runs/train/many_small_bugs_final/F1_curve.png
    - /yolov5_model/runs/train/many_small_bugs_final/PR_curve.png
    - /yolov5_model/runs/train/many_small_bugs_final/P_curve.png
    - /yolov5_model/runs/train/many_small_bugs_final/R_curve.png
    - /yolov5_model/runs/train/many_small_bugs_final/confusion_matrix.png
    - /yolov5_model/runs/train/many_small_bugs_final/events.out.tfevents.1681314803.hal-dgx.163563.0
    - /yolov5_model/runs/train/many_small_bugs_final/hyp.yaml
    - /yolov5_model/runs/train/many_small_bugs_final/labels.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/labels_correlogram.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/opt.yaml
    - /yolov5_model/runs/train/many_small_bugs_final/results.csv
    - /yolov5_model/runs/train/many_small_bugs_final/results.png
    - /yolov5_model/runs/train/many_small_bugs_final/train_batch0.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/train_batch1.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/train_batch2.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch0_labels.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch0_pred.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch1_labels.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch1_pred.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch2_labels.jpg
    - /yolov5_model/runs/train/many_small_bugs_final/val_batch2_pred.jpg
    - /yolov5_model/data/beetles_real.yaml
    - /crop/README.md
    bf9a0a3d
  • akhot2's avatar
    Update 2 files · c2e27570
    akhot2 authored
    - /Assemblies and Hardware/Arduino/PHYS371_Group1_main.ino
    - /Assemblies and Hardware/README.md
    c2e27570
  • jl190's avatar
    Replace README.md · d92b49ae
    jl190 authored
    d92b49ae
  • jl190's avatar
    Replace README.md · 4821fbfc
    jl190 authored
    4821fbfc
  • jl190's avatar
    Add new directory · de80911f
    jl190 authored
    de80911f
  • jl190's avatar
    Upload New File · e223903c
    jl190 authored
    e223903c
  • jl190's avatar
    Replace README.md · 6d811cbd
    jl190 authored
    6d811cbd
  • jl190's avatar
    Replace README.md · bb27a791
    jl190 authored
    bb27a791
  • akhot2's avatar
    Update file README.md · 8596b7ed
    akhot2 authored
    8596b7ed
Showing
with 2551 additions and 74 deletions
#include <Wire.h>
#include <Adafruit_BME680.h>
#include <SD.h>
#include <ArduCAM.h>
//Ultrasonic sensor pins
#define trigPin 30
#define echoPin 31
File dataFile;
// Define hardware serial pins
#define SERIAL_PORT Serial2
// Define data structure
struct GPSData {
float latitude;
float longitude;
float altitude;
float speed;
};
#define SEALEVELPRESSURE_HPA (1013.25) // Define the standard sea level pressure in hPa
Adafruit_BME680 bme; // Create a BME680 object
const int SD_CS = 53;
const int CAM_CS = 49;
ArduCAM myCAM( OV2640, CAM_CS );
void setup() {
Serial.begin(9600);
// Start hardware serial for GPS
SERIAL_PORT.begin(9600);
uint8_t vid, pid;
uint8_t temp;
Wire.begin();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
if (!bme.begin()) {
Serial.println("Could not find a valid BME680 sensor, check wiring!");
while (1);
}
if (!SD.begin(SD_CS)) {
Serial.println("SD initialization failed!");
return;
}
Serial.println("SD initialization successful.");
dataFile = SD.open("data.csv", FILE_WRITE);
if (dataFile) {
dataFile.println("Temperature (C), Humidity (%), Pressure (hPa), Altitude (m), Distance (cm) ,Latitude ,Longitude ,Altitude , Picture");
dataFile.close();
}
else {
Serial.println("Could not open data.csv");
}
Serial.println(F("ArduCAM Start!"));
//set the CS as an output:
pinMode(CAM_CS,OUTPUT);
digitalWrite(CAM_CS, HIGH);
// initialize SPI:
SPI.begin();
//Reset the CPLD
myCAM.write_reg(0x07, 0x80);
delay(100);
myCAM.write_reg(0x07, 0x00);
delay(100);
while(1){
//Check if the ArduCAM SPI bus is OK
myCAM.write_reg(ARDUCHIP_TEST1, 0x55);
temp = myCAM.read_reg(ARDUCHIP_TEST1);
if (temp != 0x55){
Serial.println(F("SPI interface Error!"));
delay(1000);continue;
} else {
Serial.println(F("SPI interface OK."));
break;
}
}
while(1){
//Check if the camera module type is OV2640
myCAM.wrSensorReg8_8(0xff, 0x01);
myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid);
myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid);
if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){
Serial.println(F("Can't find OV2640 module!"));
delay(1000);continue;
}
else{
Serial.println(F("OV2640 detected."));break;
}
}
myCAM.set_format(JPEG);
myCAM.InitCAM();
myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);
myCAM.OV2640_set_Light_Mode(Sunny);
delay(1000);
}
String picname = "";
void loop() {
float distance = getDistance();
if (distance > 25 & distance < 35) {
GPSData data = readGPSData();
float temperature = bme.readTemperature();
float humidity = bme.readHumidity();
float pressure = bme.readPressure() / 100.0F;
float altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
Serial.print("Temperature = ");
Serial.print(temperature);
Serial.println(" *C");
Serial.print("Humidity = ");
Serial.print(humidity);
Serial.println(" %");
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" hPa");
Serial.print("Altitude = ");
Serial.print(altitude);
Serial.println(" m");
Serial.print("Distance = ");
Serial.print(distance);
Serial.println(" cm");
delay(1000);
if (SD.exists("data.csv")) {
dataFile = SD.open("data.csv", FILE_WRITE);
if (dataFile) {
dataFile.print(temperature);
dataFile.print(",");
dataFile.print(humidity);
dataFile.print(",");
dataFile.print(pressure);
dataFile.print(",");
dataFile.print(altitude);
dataFile.print(",");
dataFile.print(distance);
// Write GPS data to file
dataFile.print(data.latitude, 6);
dataFile.print(",");
dataFile.print(data.longitude, 6);
dataFile.print(",");
dataFile.print(data.altitude, 2);
dataFile.print(",");
dataFile.println(picname);
dataFile.close();
}
else {
Serial.println("Could not open data.csv");
}
}
else {
Serial.println("data.csv does not exist.");
}
myCAMSaveToSDFile();
} else {
Serial.print("Incorrect Distance, distance is ");
Serial.println((String)distance);
}
}
float getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
float duration = pulseIn(echoPin, HIGH);
float distance = duration * 0.034 / 2;
return distance;
}
void myCAMSaveToSDFile(){
char str[8];
byte buf[256];
static int i = 0;
static int k = 0;
uint8_t temp = 0,temp_last=0;
uint32_t length = 0;
bool is_header = false;
File outFile;
//Flush the FIFO
myCAM.flush_fifo();
//Clear the capture done flag
myCAM.clear_fifo_flag();
//Start capture
myCAM.start_capture();
Serial.println(F("start Capture"));
while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK));
Serial.println(F("Capture Done."));
length = myCAM.read_fifo_length();
Serial.print(F("The fifo length is :"));
Serial.println(length, DEC);
if (length >= MAX_FIFO_SIZE) //384K
{
Serial.println(F("Over size."));
return ;
}
if (length == 0 ) //0 kb
{
Serial.println(F("Size is 0."));
return ;
}
//Construct a file name
k = k + 1;
itoa(k, str, 10);
strcat(str, ".jpg");
picname = str;
Serial.println(picname);
//Open the new file
outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC);
if(!outFile){
Serial.println(F("File open faild"));
return;
}
myCAM.CS_LOW();
myCAM.set_fifo_burst();
while ( length-- )
{
temp_last = temp;
temp = SPI.transfer(0x00);
//Read JPEG data from FIFO
if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while,
{
buf[i++] = temp; //save the last 0XD9
//Write the remain bytes in the buffer
myCAM.CS_HIGH();
outFile.write(buf, i);
//Close the file
outFile.close();
Serial.println(F("Image save OK."));
is_header = false;
i = 0;
}
if (is_header == true)
{
//Write image data to buffer if not full
if (i < 256)
buf[i++] = temp;
else
{
//Write 256 bytes image data to file
myCAM.CS_HIGH();
outFile.write(buf, 256);
i = 0;
buf[i++] = temp;
myCAM.CS_LOW();
myCAM.set_fifo_burst();
}
}
else if ((temp == 0xD8) & (temp_last == 0xFF))
{
is_header = true;
buf[i++] = temp_last;
buf[i++] = temp;
}
}
}
GPSData readGPSData() {
GPSData data;
// Wait until GPS data is available
while (!SERIAL_PORT.available()) {
delay(100);
}
// Parse GPS data
String line = SERIAL_PORT.readStringUntil('\n');
if (line.startsWith("$GPGGA")) {
// Extract latitude, longitude, altitude, and speed from GPS data
String parts[15];
int index = 0;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < line.length(); i++) {
if (line[i] == ',') {
endIndex = i;
parts[index] = line.substring(startIndex, endIndex);
startIndex = endIndex + 1;
index++;
}
}
data.latitude = parts[2].toFloat();
data.longitude = parts[4].toFloat();
data.altitude = parts[9].toFloat();
data.speed = parts[7].toFloat();
}
return data;
}
No preview for this file type
This diff is collapsed.
The different files provided under different subdirectories contain the files necessary to construct the drone attachment. The content of each file is summarized below.
## Assemblies
- `Camera_Assembly.zip`: Solidworks Pack-and-Go file of the Camera Case
- `PCB_Assembly.zip`: Solidworks Pack-and-Go file of the PCB Case
To access, unzip the respective folder and open the assembly file. Individual parts are also included in the folder and can be accessed inside.
## Drawings
- `Camera_Enclosure.SLDDRW`: Solidworks Assembly Drawing (SLDDRW) of the Camera Case
- `pcb_assembly.SLDDRW`: Solidworks Assembly Drawing (SLDDRW) of the PCB Case
To access, first download the respective Pack-and-Go file in the Assemblies Directory.
## Arduino
- `PHYS371_Group1_main.ino`: Performs data acquisition of the image, time, temperature, and more and saves it to an SD card using the Arduino Mega 2560
## PCB File(s)
- `Beetle_PCB.brd`: EAGLE autodesk Board (.brd) of the PCB Design
\ No newline at end of file
# GROUP-01-PHYS371-SP2023
This was a group project for PHYS371 at the University of Illinois at Urbana-Champaign. This repository contains the necessary code and documents the results of implementing the YOLOv5 model to identify western corn rootworm beetles on yellow sticky traps. The architecture of YOLOv5 is summarized in the [GitHub repository](https://github.com/ultralytics/yolov5).
# Preparing the repository
To train/retrain models and run the notebooks provided with this repository, one needs to create the right environment and install certain dependencies. First `cd` to the project's top directory and do
`export PROJPATH=$PWD`
## Getting started
### Arduino Code and Drone Attachment
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
The code and files for the data acquisition from the arduino, the design of the PCB, and the enclosure files, are stored in the [`Assemblies and Hardware`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/Assemblies%20and%20Hardware) directory. More information about these files is explained in the `README` file provided in [`Assemblies and Hardware`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/Assemblies%20and%20Hardware) directory.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
### Download Data
The dataset used by these studies has been made available to use by Professor Spencer of the University of Illinois at Urbana-Champaign It is available at https://universe.roboflow.com/wcr-beetle-detection/wcr-beetle-traps. Please use the steps provided on the Roboflow website to download the latest version of the dataset. We used the validation part of this dataset as the test images for our paper. Some of these images were incorrectly cropped, and so we discarded them from our results.
### Make necessary directories
Run the following commands to make the necessary directories
```
cd existing_repo
git remote add origin https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023.git
git branch -M main
git push -uf origin main
cd $PROJPATH
mkdir -p crop/data/train/images
mkdir -p crop/data/train/labels
mkdir -p crop/data/val/images
mkdir -p crop/data/val/labels
mkdir -p crop/data/test/images
mkdir -p crop/data/test/labels
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
### Setup necessary environment!
The dependencies for the cropping and simulated data are encompassed in the YOLOv5 model requirements. Run the following commands to set up the environment:
```
cd $PROJPATH
cd yolov5_model
pip install -r requirements.txt
```
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
### Data pre-processing
To preprocess the data for the `YOLOv5` models, please look at the `README` file in [`crop`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/crop) folder.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
# Training your own models
For each model architecture, we have trained a number of alternate variants and they are hosted in the [`yolov5_model/runs/train`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/yolov5_model/runs/train) directory. If you are interested in training your own models, please follow the instructions in the `README` file given in the [`yolov5_model`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/yolov5_model) directory. Please use the `beetles.yaml` as the `.yaml` file to train your own model. An example of training the model is:
```
cd $PROJPATH
cd yolov5_model
python train.py --img 1280 --batch 16 --epochs 100 --data beetles.yaml --weights yolov5x.pt --name NAME --workers 30
```
The model would be then stored in the `yolov5_model/runs/train/NAME` folder.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
# Reproducing image classification results
**They rely on avaliability of the pretrained models and the datasets in the way they have been setup in the previous section**. The tested images in the paper are stored in [`yolov5_model/runs/detect`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/tree/main/yolov5_model/runs/detect) directory. You can test unlabeled images by
```
cd $PROJPATH
cd yolov5_model
python test.py --img 1280 --source path/to/images/ --weights path/to/weights/best.pt --name NAME --workers 30
```
For full data acquisition, you can use the [`transfer.py`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/blob/main/transfer/transfer.py) file to output the number of predicted beetles as well as the confidence level into an [`output.csv`](https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/-/blob/main/transfer/output.csv) file. To run this, run the following commands:
```
cd $PROJPATH
cd transfer
python transfer.py
```
# Reference
The model and drone attachment in this repository are compiled and explained in this paper: [Building an Arduino Drone Attachment to Detect Western Corn Rootworm Beetles Using YOLOv5](https://drive.google.com/file/d/167-oGDc3cTERrExamo15tIQeFQ6fNDwl/view?usp=sharing)
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
To cite this work, please use the following `bibtex` entry:
```
@misc{khot_lin_pasq_pavan_2023,
title={Building an Arduino Drone Attachment to Detect Western Corn Rootworm Beetles Using YOLOv5},
author={Khot, Ayush and Lin, Jeremiah and Pasquesi, Samuel and Pavithran, Pavan},
year={2023},
url={https://gitlab.engr.illinois.edu/akhot2/group-01-phys371-sp2023/}
}
```
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
Please use the contact information given in https://universe.roboflow.com/wcr-beetle-detection/wcr-beetle-traps to gain permission to use the dataset in research. To cite this dataset, please use the `bibtex` entry given on the website.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
# Source Code
Existing resources from publicly available repositories have been adapted to implement the image cropping and YOLOv5 model. We are greatly thankful to the authors of the following works for making these repositories and resources publicly available.
## License
For open source projects, say how it is licensed.
- Part of the image cropping code is obtained from: https://stackoverflow.com/questions/60941012/how-do-i-find-corners-of-a-paper-when-there-are-printed-corners-lines-on-paper-i
- Implementation of YOLOv5 has been largely adopted from: https://github.com/ultralytics/yolov5
- Part of the arduino code has been obtained from the examples for the Adafruit libaries
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
# Contact:
For comments, feedback, and suggestions: Ayush Khot (akhot2@illinois.edu), Jeremiah Lin (jl190@illinois.edu), Samuel Pasquesi (smp6@illinois.edu), and Pavan Pavithran (pavanp2@illinois.edu)
arduino_imgs/10 beetles shadow + dirtier 2.JPG

132 KiB

arduino_imgs/10 beetles shadow + dirtier.JPG

127 KiB

arduino_imgs/10 beetles sun + dirtier 2.JPG

159 KiB

arduino_imgs/10 beetles sun+ dirtier.JPG

154 KiB

arduino_imgs/5 beetles (SUN).JPG

138 KiB

arduino_imgs/5 beetles (not full grid).JPG

117 KiB

arduino_imgs/6 beetles (1).JPG

130 KiB

arduino_imgs/6 beetles dirt + shadow 2.JPG

118 KiB

arduino_imgs/6 beetles dirt + shadow.JPG

117 KiB

arduino_imgs/6 beetles dirt + sun.JPG

140 KiB

arduino_imgs/6 beetles.JPG

108 KiB

arduino_imgs/7 beetles (SUN 2).JPG

122 KiB

arduino_imgs/7 beetles (SUN).JPG

125 KiB

The different files and directories contain the images and code necessary to construct the western corn rootworm (WCR) simulated dataset using the images given in the [Roboflow dataset](https://universe.roboflow.com/wcr-beetle-detection/wcr-beetle-traps). The content of each file is summarized below.
- `beetles`: Directory of cropped WCR beetles taken from the cropped traps
- `cropped_imgs`: Directory of cropped traps, containing both WCR beetles and insects
- `imgs`: Directory of uncropped traps, containing both WCR beetles and insects
- `non_beetles`: Directory of cropped various insects, not including WCR beetles, taken from the cropped traps
- `SimData.ipynb`: Constructs the simulated dataset using the cropped traps, beetles, and insects in the various folders
- `autocrop.py`: Performs cropping of an image using Otsu's Method, cropping only one image. To crop an image, setup the required environment and run the following command:
```
python3 autocrop.py imgpath destpath [sensitivity=110] [debug=False]
```
The available options are:
```
imgpath path to image file
destpath path to destination file, including new filename
sensitivity sensitivity of foreground vs background
debug saves additional images to folder (polygon and mask of foreground pixels)
```
*Note*: To perform autocropping, delete lines 111 and 133. These were implemented to be able to be used in `transfer.py`.
- `autocrop_folder.py`: Performs cropping of an image using Otsu's Method, cropping a whole folder. To crop a folder, setup the required environment and run the following command:
```
python3 autocrop_folder.py imgfolder destfolder [sensitivity=110] [debug=False]
```
The available options are:
```
imgfolder path to the folder of images
destfolder path to destination folder
sensitivity sensitivity of foreground vs background
debug saves additional images to folder (polygon and mask of foreground pixels)
```
*Note*: When one file fails to autcrop due to needing a higher or lower sensitivity, the whole program stops. In this case, it is better to move it out of the folder and correctly crop it with a new sensitivity using `autocrop.py` and `debug=True`. Then, you can use `autocrop_folder.py` again.