Skip to main content

A toolkit for crop sensing using the ZED camera

Project description

About The Project

unimi_crop_sensing was created with the aim of offering a set of simple and intuitive operations to interact with the ZED camera. It consists of a toolkit for processing and segmenting images and point clouds acquired via the ZED stereo camera. The project is designed for precision agriculture applications, allowing you to identify plants in 2D and 3D, generate bounding boxes and communicate with a cobot through WebSocket in a ROS environment.

Main features

  • Green segmentation with Excess Green Index
  • Plant clustering via KMeans
  • 2D and 3D bounding box calculation on point cloud
  • Save .ply, images, normal map
  • WebSocket ROS (rosbridge) integration for communication on separate systems

Built With

Getting Started

Prerequisites

Make sure you have:

  • Python 3.9
  • ZED SDK properly installed and working and a connected ZED camera
  • ROS + rosbridge running if you use WebSocket
  • The libraries listed in requirements.txt

Installation

You can use unimi_crop_sensing as a Python package installable via PyPI. Install everything with:

pip install unimi_crop_sensing

⚠️ Pyzed 5.0 requires numpy 2.x, this conflicts with other project features, so if you encounter errors related to numpy, make sure you install a compatible version:

pip install "numpy<2"

Usage

This is an example of a script that uses every function to obtain spatial coordinates and point clouds of each plant within its range

# This function is used to test the functionalities of the crop sensing module
def main():
    
    # Get the current pose of the cobot
    pose = cobot_manager.get_cobot_pose(linux_ip)

    # Initialize the ZED camera
    zed = zed_manager.zed_init(pose)
    
    # Capture the environment with the ZED camera
    image, depth_map, normal_map, point_cloud = zed_manager.get_zed_image(zed, save=True)

    # Filter the plants from the background
    mask = find_plant.filter_plants(image, save_mask=True)
    
    # Divide the plants into clusters
    masks, bounding_boxes = find_plant.segment_plants(mask, plants_number)
    find_plant.save_clustered_image(image, bounding_boxes)

    # Extract the 3D points from the clusters
    for m in masks:
        bbxpts = find_plant.plot_3d_bbox(m, point_cloud)
        
    # Communicate the bounding boxes to the cobot (only if the cobot is operated in another machine)
    cobot_manager.send_cobot_map(linux_ip, bbxpts)

    # Create point cloud (this will create a .ply file by taking a video of the environment)
    create_plc.record_and_save(plant_name='piantina1', frames=300)

    zed.close()

Contact

francescobassam.morgigno@studenti.unimi.it

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unimi_crop_sensing-0.8.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unimi_crop_sensing-0.8-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file unimi_crop_sensing-0.8.tar.gz.

File metadata

  • Download URL: unimi_crop_sensing-0.8.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for unimi_crop_sensing-0.8.tar.gz
Algorithm Hash digest
SHA256 6eeca77c36b299b510a47bd17e0912b55d52de740dcdecf6c1beb75dbf74b4e3
MD5 dd34edc9a5d851fa835376cb151036eb
BLAKE2b-256 1168137dc660937cb71edf5484502f539e187f32c7069112574689bb2719d23b

See more details on using hashes here.

Provenance

The following attestation bundles were made for unimi_crop_sensing-0.8.tar.gz:

Publisher: release.yml on Hoppip48/unimi_crop_sensing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unimi_crop_sensing-0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for unimi_crop_sensing-0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 15729922dbe54d522151b630e0a0f0d9b9d86e4af010f99514af97d8bdf16279
MD5 633a6cb750c17bc2b6e38c999e67411c
BLAKE2b-256 ed27103a6ba6c527ffcba8a385ce63d4739b63aebee9fdea643e00c3d78aa554

See more details on using hashes here.

Provenance

The following attestation bundles were made for unimi_crop_sensing-0.8-py3-none-any.whl:

Publisher: release.yml on Hoppip48/unimi_crop_sensing

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page