null Skip to main content

[ Sequence Target Tracker Browser Based App ]

List of items used:

PN00421 - Speed Controller
PN01003 - 5RPM Gear Motor
PN00318F - Female bullet connector wires
PN00218-CYT8 - Arduino UNO clone

Installation required:

Arduino UNO code

Web app to use:

sequence_target_tracker.html

You may save it to your local machine to run with your browser (Chrome, Chromium, Edge).

The MAKERMOTOR Vision Sequencer is a web-based application designed to facilitate the creation and management of target tracking sequences using MAKERMOTOR products. It allows users to define a series of visual targets, configure their tracking parameters, and control the sequence's execution with customizable settings.

Key Features:

  • Target Definition: Users can add multiple visual targets by selecting objects within a video feed.

  • Sequence Configuration: Customize the order of targets, set movement directions (clockwise or counter-clockwise), adjust speeds, and define stopping points.

  • Camera Settings: Adjust parameters like color match sensitivity and minimum size to optimize target detection.

  • Execution Modes: Choose between running the sequence once, a fixed number of times, or in an infinite loop.

  • Arduino Integration: While the app is compatible with Arduino for hardware control, it also offers a test mode for visual-only simulations.

  • Save and Load: Save sequences along with snapshots of the current setup for future use or modification.

This tool is ideal for developers and hobbyists looking to implement precise visual tracking sequences in their projects, offering both flexibility and control in designing automated tracking behaviors.

# Arduino-Controlled Color Tracker

This project combines computer vision-based color tracking with an Arduino Uno for physical motor control. It detects and tracks colored objects in real-time from a webcam and uses the tracking data to control a motor through an Arduino.

## New Features

**New advanced implementation with improved browser compatibility and multi-target tracking:**

- Advanced multi-target sequential tracking

- Improved camera switching that works on all browsers

- Simplified Arduino commands using single integer values (-255 to 255)

- Configurable tracking parameters per target

- Direction and speed control for each target

- Sequence-based target tracking with save/load functionality

## Project Components

- **sequence_target_tracker.html**: Latest implementation with target sequence tracking, save/load functionality, and improved UI

## Hardware Requirements

- Arduino Uno or compatible board

- Motor driver/controller (L298N or similar H-bridge)

- DC motor

- Webcam (built-in or external)

- Computer with Chrome, Edge, Chromium or Opera browser (required for Web Serial API support)

## Wiring Instructions

Connect your Arduino and motor controller as follows:

1. **Arduino to Motor Controller:**

   - Arduino Digital Pin 9 → Motor Controller IN1 input (PWM)

   - Arduino Digital Pin 8 → Motor Controller IN2 input (Direction)

   - Arduino GND → Motor Controller GND

2. **Motor Controller to Motor:**

   - Follow your specific motor controller's instructions for connecting to the DC motor

## Software Setup

### Arduino Setup:

1. Open the Arduino IDE

2. Load the `motor_controller_arduino/motor_controller_arduino.ino` sketch. You may download the code HERE.

3. Upload to your Arduino

### Web Application:

1. Open `sequence_target_tracker.html` (latest) in Chrome, Edge, or Opera browser. 

2. Allow camera access when prompted

3. Set the pointer marker by clicking on your pointer object

4. Add target markers by clicking on colored objects in the video

5. Configure each target's direction, speed, and stop threshold

6. For sequence tracker: click on target cards to add them to your sequence

7. Click "Connect to Arduino" and select your Arduino from the port list

8. Press "Start Sequence" or "Start Tracking" to begin motor control

## Target Tracker Usage

### Sequence Target Tracker (Latest Version):

- Create and follow an ordered sequence of colored targets

- Advanced features:

  - Save and load sequences with snapshots

  - Configurable loop settings (run once, fixed count, infinite)

  - Test mode without Arduino (visual tracking only)

  - Pause time between targets

  - Improved UI with target cards and sequence preview

### Target Setup:

- Click on objects in the video to create tracking targets

- Each target has configurable:

  - Direction (Clockwise/Counter-clockwise)

  - Speed (25%, 50%, 75%, 100%)

  - Stop threshold (distance in pixels)

- Click on target cards to add them to the sequence

- Rearrange sequence by removing and re-adding targets

### Tracking Mode:

- The system tracks targets in the defined sequence

- Only one target is "active" at a time (highlighted in green)

- When an active target is reached (distance below threshold), it's marked as completed

- The system automatically moves to the next target in sequence after a configurable pause

- The motor rotates based on the active target's position and configuration:

  - Target to the right: Rotate counter-clockwise

  - Target to the left: Rotate clockwise

  - Speed is determined by target's configuration

### Arduino Control:

- Simple integer values control the motor:

  - Positive values (1-255): Clockwise rotation

  - Negative values (-1 to -255): Counter-clockwise rotation

  - Zero: Stop motor

## Troubleshooting

- **Arduino Not Detected**: Make sure you're using Chrome, Edge, or Opera browser and have the correct drivers installed

- **Tracking Not Working**: Adjust lighting conditions and try different color thresholds

- **Camera Switching Issues**: Use the new improved_camera_switching.html or advanced_multi_tracker.html which work on all browsers

- **Motor Not Responding**: Check wiring and verify the Arduino is receiving commands (LED will blink when commands are processed)

## System Diagram

```

┌───────────────────┐                    ┌───────────────────┐                  ┌─────────────┐

                                                                                     

    Web Camera    │───► Captured ───►    Web Browser     │───► Serial ───►    Arduino   │──┐

                        Frames          Color Tracker         Commands        Uno      

└───────────────────┘                    └───────────────────┘                  └─────────────┘ 

                                                                                                

                                                                                                

                                                                                     ┌─────────────────┐         ┌─────────┐

                                                                                       Motor Driver    │──PWM──► │        

                                                                                       Controller     │──DIR──► │  Motor 

                                                                                     └─────────────────┘         └─────────┘

```

## How The Sequence Target Tracker Works

1. **Marker Setup**:

   - The user sets a pointer marker (typically attached to the motor)

   - Multiple target markers are created by clicking on colored objects

   - Targets are added to a sequence in the desired order

2. **Color Detection**: The web app captures frames from the webcam and identifies regions matching the selected color markers.

3. **Sequential Tracking**:

   - The system focuses on one target at a time, following the defined sequence

   - The system can loop through the sequence once, a specified number of times, or infinitely

4. **Position Analysis**:

   - The pointer's position relative to the current target is calculated

   - Distance between pointer and target determines motor speed

5. **Motor Control**: Commands are sent to the Arduino based on the current target's settings:

   - Direction is set by the target's configuration

   - Speed is determined by the target's speed setting and distance

   - When close to the target, speed is reduced for precision

6. **Target Completion**:

   - When a target is reached (distance below threshold), it's marked as completed

   - The system pauses for a configurable time period

   - The system then automatically moves to the next target in the sequence

7. **Sequence Management**:

   - Sequences can be saved to JSON files with snapshots for future use

   - Saved sequences can be loaded, including all target settings

8. **Arduino Processing**: The Arduino receives simple integer commands (-255 to 255) via serial connection and controls the motor accordingly.

Disclaimer

This application is part of an open-source project provided for educational and experimental purposes only. By using this software, you acknowledge that it is provided "as is" without any warranties or guarantees of performance, safety, or fitness for a particular purpose. Users are solely responsible for ensuring that any implementation complies with local laws, safety standards, and best engineering practices.

Open Source

As an open-source tool, it is governed by its applicable open-source license. Users must adhere to the terms of this license, which includes proper attribution, sharing of derivative works under the same terms, and not misrepresenting the origin of the software. Contributions, modifications, and redistributions are welcome, provided they align with the spirit and rules of open-source collaboration.