Skip to content

Commit

Permalink
[Merge] - Pre-Release --> Release
Browse files Browse the repository at this point in the history
Major:
- Tutorial text update
- New Set of labelled images for the tutorial (Set3)
- Added labelled images processing utility if needed (/Labels_Processing)
- MacOs paths fix
- Files rename for clarity
- Reorganised general_InputOutput code and updated the code base accordingly
-
  • Loading branch information
Jacopin Eliott committed Apr 11, 2023
2 parents 83c5102 + 65db99c commit 21a530b
Show file tree
Hide file tree
Showing 69 changed files with 164,559 additions and 676 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
__pycache__/
*.py[cod]
*.py[cod]
Binary file modified BSAS/__pycache__/bsas.cpython-37.pyc
Binary file not shown.
Binary file modified Crops_Rows_Angle_Detection/__pycache__/CRAD.cpython-37.pyc
Binary file not shown.
Binary file added Documentation/Images/SimulationStepsDemo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
## Goal:
The goal is to count the plants on images of crop fields captured by a UAV.

## Methods:
A quick grasp of the methods are also available in the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s)
![](https://github.com/LittleCoinCoin/Plant_Counting/blob/Pre-Release/Documentation/Images/MAS_Hierarchy_Structure.png)
- The Multi-Agents System (MAS) is structured after a corporate hierarchy of 4 layers.
- Agents on one layer supervise a group of agents on the layer below them. The top 3 layers act
and give orgers to their subordinates based on the geometry of the field. For instance, a Row
Agent makes sure that the Pant Agents are staying aligned. The bottom layer consists in Pixels
Agents which react to white pixels in the image.
- At the end of the simulation, we consider that 1 Plant Agent = 1 actual plant on the image.
- The number of Plant Agents is regulated by the Row Agents which merge or initialize new
Plant Agents if they are too close or too far from each other respectively.
- The system ends its research when the number of Plant Agents has stabilized.

## Variables the user can change:
- *_path_input_rgb_img (string)*: directory of the original RGD images

- *_path_PreTreatment_and_FA (string)*: root directory of the outputs generated by the
pre-processing and Fourier Analysis steps

- *_session_number (int, optional with default value 1)*: the results of every run are
further organized in a session folder. This parameters controls the index of the folder.

- *_RAs_group_size (int, opional with default value 20)*: __VERY IMPORTANT PARAMETER.__ Controls
the size of the square shape area in which the Pixel Agents under the command of a Plant Agent
initialized. Two Plant Agents are merged when they are both included in the Pixel Agents area
of the other. Therefore, increasing *_RAs_group_size* will tend to promote merging and therefore
reducing the number of predicted plants. On the other hand, decreasing it will result in a higher
number of predicted plants. The default value of 20 proved satisfying in most situations tested
but do not hesitate to change this parameter's value if you observe consequent underestimation or
overestimation.

- *_RAs_group_steps (int, optional with default value 2)*: controls the spacing in between two
Pixel Agents under the command of the same Plant Agent.

________________________ _RAs_group_size ____________________________
| |
| |
.+------------------------------- North -------------------------------+
/ | |
/ | PX(i-1,i) |
/ | | |
/ | | |
/ | | |
/ | _RAs_group_steps_ |
/ | | |
/ | _RAs_group_steps_ | _RAs_group_steps_ |
/ W / \ | / \ E
_RAs_group_size e PX(i,i-1) PX(i,i) PX(i,i+1) a
\ s | s
\ t | t
\ | | |
\ | _RAs_group_steps_ |
\ | | |
\ | | |
\ | | |
\ | PX(i+1,i) |
\ | |
.+------------------------------- South -------------------------------+

- *_Simulation_steps(int, optional with default value 50)*: sets the maximal number of steps of the
simulation in case the number of Plant Agents do not stabilizes.

- _RALs_fuse_factor (float, optional with default value 0.5)*: threshold relatively to the
Inter Plant Critical Distance (IPCD, watch the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s) for more details) below which two Plant Agents
are merged irrespective of their overlapping Pixel Agents area.

- _RALs_fill_factor (float, optional with default value 1.5)*: threshold relatively to the
Inter Plant Critical Distance (IPCD, watch the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s) for more details) above which Plant Agents
are initialized in between two existing Plant Agents.
## Goal:
The goal is to count the plants on images of crop fields captured by a UAV.

## Methods:
A quick grasp of the methods are also available in the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s)
![](https://github.com/LittleCoinCoin/Plant_Counting/blob/Pre-Release/Documentation/Images/MAS_Hierarchy_Structure.png)
- The Multi-Agents System (MAS) is structured after a corporate hierarchy of 4 layers.
- Agents on one layer supervise a group of agents on the layer below them. The top 3 layers act
and give orgers to their subordinates based on the geometry of the field. For instance, a Row
Agent makes sure that the Pant Agents are staying aligned. The bottom layer consists in Pixels
Agents which react to white pixels in the image.
- At the end of the simulation, we consider that 1 Plant Agent = 1 actual plant on the image.
- The number of Plant Agents is regulated by the Row Agents which merge or initialize new
Plant Agents if they are too close or too far from each other respectively.
- The system ends its research when the number of Plant Agents has stabilized.

## Variables the user can change:
- *_path_input_rgb_img (string)*: directory of the original RGD images

- *_path_PreTreatment_and_FA (string)*: root directory of the outputs generated by the
pre-processing and Fourier Analysis steps

- *_session_number (int, optional with default value 1)*: the results of every run are
further organized in a session folder. This parameters controls the index of the folder.

- *_RAs_group_size (int, opional with default value 20)*: __VERY IMPORTANT PARAMETER.__ Controls
the size of the square shape area in which the Pixel Agents under the command of a Plant Agent
initialized. Two Plant Agents are merged when they are both included in the Pixel Agents area
of the other. Therefore, increasing *_RAs_group_size* will tend to promote merging and therefore
reducing the number of predicted plants. On the other hand, decreasing it will result in a higher
number of predicted plants. The default value of 20 proved satisfying in most situations tested
but do not hesitate to change this parameter's value if you observe consequent underestimation or
overestimation.

- *_RAs_group_steps (int, optional with default value 2)*: controls the spacing in between two
Pixel Agents under the command of the same Plant Agent.

________________________ _RAs_group_size ____________________________
| |
| |
.+------------------------------- North -------------------------------+
/ | |
/ | PX(i-1,i) |
/ | | |
/ | | |
/ | | |
/ | _RAs_group_steps_ |
/ | | |
/ | _RAs_group_steps_ | _RAs_group_steps_ |
/ W / \ | / \ E
_RAs_group_size e PX(i,i-1) PX(i,i) PX(i,i+1) a
\ s | s
\ t | t
\ | | |
\ | _RAs_group_steps_ |
\ | | |
\ | | |
\ | | |
\ | PX(i+1,i) |
\ | |
.+------------------------------- South -------------------------------+

- *_Simulation_steps(int, optional with default value 50)*: sets the maximal number of steps of the
simulation in case the number of Plant Agents do not stabilizes.

- _RALs_fuse_factor (float, optional with default value 0.5)*: threshold relatively to the
Inter Plant Critical Distance (IPCD, watch the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s) for more details) below which two Plant Agents
are merged irrespective of their overlapping Pixel Agents area.

- _RALs_fill_factor (float, optional with default value 1.5)*: threshold relatively to the
Inter Plant Critical Distance (IPCD, watch the [video](https://www.youtube.com/watch?v=85YllTyfxaQ&t=205s) for more details) above which Plant Agents
are initialized in between two existing Plant Agents.
43 changes: 15 additions & 28 deletions Fourier/FrequencyAnalysis.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 5 09:37:36 2020
@author: eliot
goal:
- Approximation of the position of the plants positions thanks to Fourier Analysis
Method
Expand Down Expand Up @@ -32,22 +28,6 @@
sys.path.append(os.path.abspath("../Utility"))
import general_IO as gIO

# =============================================================================
# Utility Functions Definition
# =============================================================================
def import_data(_path, _file_names, _import_function):
data = []
for _n in _file_names:
data += [_import_function(_path + "/" + _n)]
return data

def get_file_lines(path_csv_file):
file_object = open(path_csv_file, 'r')
file_content = file_object.readlines()
file_object.close()
return(file_content)


# =============================================================================
# Specific Function Definition
# =============================================================================
Expand Down Expand Up @@ -228,13 +208,13 @@ def All_Fourier_Analysis(_path_input_output,
subset_size = 4

################## Import Data
data_bsas_dir0 = import_data(path_input_bsas_dir0,
names_input_bsas_dir0[:subset_size],
get_file_lines)
data_bsas_dir0 = gIO.multi_read(path_input_bsas_dir0,
names_input_bsas_dir0[:subset_size],
gIO.read)

data_bsas_dir1 = import_data(path_input_bsas_dir1,
names_input_bsas_dir1[:subset_size],
get_file_lines)
data_bsas_dir1 = gIO.multi_read(path_input_bsas_dir1,
names_input_bsas_dir1[:subset_size],
gIO.read)

nb_images = len(data_bsas_dir0)

Expand Down Expand Up @@ -298,7 +278,7 @@ def All_Fourier_Analysis(_path_input_output,

################## Save the predictions in json file
_file_name="PredictedRows_Img_"+str(i)+"_"+str(nb_predictions)
gIO.WriteJson(path_output_FT_predictions, _file_name, predicted_FT)
gIO.write_json(path_output_FT_predictions, _file_name+".json", predicted_FT)



Expand All @@ -308,7 +288,14 @@ def All_Fourier_Analysis(_path_input_output,
# =============================================================================

if (__name__ == "__main__"):
# ========================== FOR NON-LABELLED IMAGES ======================== #
# =============================================================================
# All_Fourier_Analysis(_path_input_output="../Tutorial/Output_General/Set1",
# _session_number=1,
# _bin_div_X=2, _bin_div_Y=4)
# =============================================================================

All_Fourier_Analysis(_path_input_output="../Tutorial/Output_General/Set1",
# ========================== FOR LABELLED IMAGES ============================ #
All_Fourier_Analysis(_path_input_output="../Tutorial/Output_General/Set3",
_session_number=1,
_bin_div_X=2, _bin_div_Y=4)
Loading

0 comments on commit 21a530b

Please sign in to comment.