Skip to main content

A python library for single-object tracking.

Project description

rbobjecttracking is based on an algorithm I invented called RBOT. it stands for ROI Based Object Tracking.

using rbobjecttracking, you can get around 50-70 FPS on a CPU To use rbobjecttracking, first create your custom dataset using rbot.dataCollector.

from rbot.dataCollector import DataCollector # Import the DataCollector class

data_collector = DataCollector() # Create the DataCollector object
data_collector.collectData() # This will open a GUI window using customtkinter and opencv.

After filling in the text fields and collecting the image samples, train a small model using rbot.trainer.

from rbot.trainer import Trainer # Import the Trainer class

trainer = Trainer(dataset_path="<dataset name that you created>", img_size=(128, 128), model_path="<path you want to save your model>") # Create the Trainer object
                  
trainer.train() # This will train and save the model to your specified model path

Training should usually take around 10seconds to a minute on your GPU depending on your dataset size, and image size.

After training, you can need to get the color mask of the object with rbot.colorExtractor.

from rbot.colorExtractor import ColorRangeSelector # import the ColorRangeSelector class

rangeSelector = ColorRangeSelector() # Create the class object
rangeSelector.select_color_range() # call the function to select your object's color range

This will open a GUI with the masked webcam, and some sliders. You need to adjust the sliders so that everything but your object turns black in the webcam view.

After selecting your object's color range, you can then start the object detection with rbot.rbot

from rbot.rbot import RBOT # Import the RBOT class
import cv2 # Import opencv for accessing the webcam

rbot = RBOT(hsvValues="", image_size=(256, 256), minimum_confidence=0.9) # Create the RBOT object
cap = cv2.VideoCapture(0) # Access the webcam

while True:
    ret, frame = cap.read() # Get a frame from the webcam

    processed_frame = rbot.track_object(frame=frame, color=(0, 255, 0), width=2) # Process the frame

    cv2.imshow("processed frame", processed_frame) # Display the proccesed frame
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

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

rbobjecttracking-3.0.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

rbobjecttracking-3.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file rbobjecttracking-3.0.0.tar.gz.

File metadata

  • Download URL: rbobjecttracking-3.0.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for rbobjecttracking-3.0.0.tar.gz
Algorithm Hash digest
SHA256 f8e3bc78a89285d7cc50ab51a012ee968a13a84fd74c910c3128bd9c61514587
MD5 f49e254c9da0b7de29536fb001321600
BLAKE2b-256 3b3a69f29179ff7213089972bf02fb1ccb3b49fd50624c1dada77044ca0ccb24

See more details on using hashes here.

File details

Details for the file rbobjecttracking-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rbobjecttracking-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c9fc8264bf2fa352cedef4dccb28d54ad0d8ed47b05f1096ace5f788e9827f6
MD5 60c14db0ec58eb6116b4c9df6506c066
BLAKE2b-256 c94330f2643af2e2f61a00e6f1bdb53a0b7d9daf41db9500bedc716df425a58e

See more details on using hashes here.

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