Giter VIP home page Giter VIP logo

firacolortracking's Introduction

FiraColorTracking

Proof of concept for a color blob follower lab exercise

Project implemented as a part of Programming of Autonomous Mobile Robots course at AGH University of Science and Technology.

Warning: This repository might and will contain work in progress as well as my vain attempts and utter failures. Proceed at your own risk.

Requirements

Android 4.1+ phone with camera, bluetooth, full battery and high-performance hardware

Setup

  1. Install OpenCV Manager on the device using Play Store or adb:

https://play.google.com/store/apps/details?id=org.opencv.engine&hl=en or http://sourceforge.net/projects/opencvlibrary/files/opencv-android/3.0.0/OpenCV-3.0.0-android-sdk-1.zip/download

Get device architecture:

adb shell getprop ro.product.cpu.abi

Install architecture:

<AndroidSDK>/platform-tools/adb install <OpenCVSDK>/apk/OpenCV_3.0.0_Manager(...).apk

when in doubt, see: http://docs.opencv.org/3.0.0/da/d2a/tutorial_O4A_SDK.html

  1. Open the project in Android Studio.
  2. Install all required SDK and tools as prompted by the IDE. Do not upgrade Gradle version in the project - this would imply a higher SDK version requirement.
  3. (Unix/Windows) CTRL+Shift+A -> SDK Manager -> SDK Tools -> choose "ConstraintLayout for Android" and "Solver for ConstraintLayout"
  4. Plug your device and run (Shift+F10).
  5. Pairing with FIRA can be troublesome. What works (usually) is to pair manually in Settings and then again in the app. Watch your notifications bar - the robot won't usually pair directly, but it will issue its own pairing request to your device. After successful pairing you will see a popup with robot bluetooth ID.
  6. Implement robot movement in pl.robolab.fira.colortracking.MainActivity#onCenterPoint or just run the example.

Usage

  • VOLUME_UP - movement test enable/disable
  • BACK - send stop command, exit on second
  • MENU - bluetooth command. On newer devices
  • touch - pick color range for tracking

Description

Provided application follows a very simple routine. For each frame:

  • 2x Imgproc.pyrDown - blurs an image and downsamples it. The function performs the downsampling step of the Gaussian pyramid construction.
  • Imgproc.cvtColor - converts to HSV.
  • Core.inRange - creates mask from lower to upper color bound.
  • Imgproc.dilate.
  • Imgproc.findContours with flags: CV_RETR_EXTERNAL retrieves only the extreme outer contours CV_CHAIN_APPROX_SIMPLE compresses horizontal, vertical, and diagonal segments and leaves only their end points. For example, an upper-right rectangular contour is encoded with 4 points.
  • Sort contours by size.
  • Filter to 0.1 * maxArea.
  • Imgproc.convexHull - The functions find the convex hull of a 2D point set using the Sklansky’s algorithm [Sklansky82] that has O(N logN) complexity in the current implementation.
  • Circle the middle point of the hull.
  • Execute user provided callback (pl.robolab.fira.colortracking.MainActivity#onCenterPoint)

firacolortracking's People

Contributors

ddworak avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.